mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
register sink/source name as first step when creating a new sink/source so that we can hand the valid name string to the hook functions; se tup props for monitor sources correctly; fix implicit flag setting logic
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2260 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
aad9d39838
commit
07f5c1d8e4
2 changed files with 36 additions and 40 deletions
|
|
@ -118,9 +118,22 @@ pa_sink* pa_sink_new(
|
||||||
|
|
||||||
pa_assert(core);
|
pa_assert(core);
|
||||||
pa_assert(data);
|
pa_assert(data);
|
||||||
|
pa_assert(data->name);
|
||||||
|
|
||||||
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_NEW], data) < 0)
|
s = pa_msgobject_new(pa_sink);
|
||||||
|
|
||||||
|
if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_SINK, s, data->namereg_fail))) {
|
||||||
|
pa_xfree(s);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_sink_new_data_set_name(data, name);
|
||||||
|
|
||||||
|
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_NEW], data) < 0) {
|
||||||
|
pa_xfree(s);
|
||||||
|
pa_namereg_unregister(core, name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
|
pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
|
||||||
pa_return_null_if_fail(data->name && pa_utf8_valid(data->name) && data->name[0]);
|
pa_return_null_if_fail(data->name && pa_utf8_valid(data->name) && data->name[0]);
|
||||||
|
|
@ -142,13 +155,9 @@ pa_sink* pa_sink_new(
|
||||||
if (!data->muted_is_set)
|
if (!data->muted_is_set)
|
||||||
data->muted = FALSE;
|
data->muted = FALSE;
|
||||||
|
|
||||||
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_FIXATE], data) < 0)
|
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_FIXATE], data) < 0) {
|
||||||
return NULL;
|
|
||||||
|
|
||||||
s = pa_msgobject_new(pa_sink);
|
|
||||||
|
|
||||||
if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_SINK, s, data->namereg_fail))) {
|
|
||||||
pa_xfree(s);
|
pa_xfree(s);
|
||||||
|
pa_namereg_unregister(core, name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,11 +221,12 @@ pa_sink* pa_sink_new(
|
||||||
pa_source_new_data_set_channel_map(&source_data, &s->channel_map);
|
pa_source_new_data_set_channel_map(&source_data, &s->channel_map);
|
||||||
source_data.name = pa_sprintf_malloc("%s.monitor", name);
|
source_data.name = pa_sprintf_malloc("%s.monitor", name);
|
||||||
source_data.driver = data->driver;
|
source_data.driver = data->driver;
|
||||||
|
source_data.module = data->module;
|
||||||
|
|
||||||
d = pa_sprintf_malloc("Monitor Source of %s", s->name);
|
d = pa_sprintf_malloc("Monitor Source of %s", s->name);
|
||||||
pa_proplist_sets(data->proplist, PA_PROP_DEVICE_DESCRIPTION, d);
|
pa_proplist_sets(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, d);
|
||||||
pa_xfree(d);
|
pa_xfree(d);
|
||||||
pa_proplist_sets(data->proplist, PA_PROP_DEVICE_CLASS, "monitor");
|
pa_proplist_sets(source_data.proplist, PA_PROP_DEVICE_CLASS, "monitor");
|
||||||
|
|
||||||
s->monitor_source = pa_source_new(core, &source_data, 0);
|
s->monitor_source = pa_source_new(core, &source_data, 0);
|
||||||
|
|
||||||
|
|
@ -281,15 +291,8 @@ void pa_sink_put(pa_sink* s) {
|
||||||
|
|
||||||
pa_assert(!s->min_latency || !s->max_latency || s->min_latency <= s->max_latency);
|
pa_assert(!s->min_latency || !s->max_latency || s->min_latency <= s->max_latency);
|
||||||
|
|
||||||
if (s->get_volume && s->set_volume)
|
if (!(s->flags & PA_SINK_HW_VOLUME_CTRL))
|
||||||
s->flags |= PA_SINK_HW_VOLUME_CTRL;
|
s->flags |= PA_SINK_DECIBEL_VOLUME;
|
||||||
else
|
|
||||||
s->flags = (s->flags & ~PA_SINK_HW_VOLUME_CTRL) | PA_SINK_DECIBEL_VOLUME;
|
|
||||||
|
|
||||||
if (s->get_mute && s->set_mute)
|
|
||||||
s->flags |= PA_SINK_HW_MUTE_CTRL;
|
|
||||||
else
|
|
||||||
s->flags &= ~PA_SINK_HW_MUTE_CTRL;
|
|
||||||
|
|
||||||
pa_assert_se(sink_set_state(s, PA_SINK_IDLE) == 0);
|
pa_assert_se(sink_set_state(s, PA_SINK_IDLE) == 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,18 @@ pa_source* pa_source_new(
|
||||||
|
|
||||||
pa_assert(core);
|
pa_assert(core);
|
||||||
|
|
||||||
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_NEW], data) < 0)
|
s = pa_msgobject_new(pa_source);
|
||||||
|
|
||||||
|
if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_SOURCE, s, data->namereg_fail))) {
|
||||||
|
pa_xfree(s);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_NEW], data) < 0) {
|
||||||
|
pa_xfree(s);
|
||||||
|
pa_namereg_unregister(core, name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
|
pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
|
||||||
pa_return_null_if_fail(data->name && pa_utf8_valid(data->name) && data->name[0]);
|
pa_return_null_if_fail(data->name && pa_utf8_valid(data->name) && data->name[0]);
|
||||||
|
|
@ -133,13 +143,9 @@ pa_source* pa_source_new(
|
||||||
if (!data->muted_is_set)
|
if (!data->muted_is_set)
|
||||||
data->muted = FALSE;
|
data->muted = FALSE;
|
||||||
|
|
||||||
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], data) < 0)
|
if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], data) < 0) {
|
||||||
return NULL;
|
|
||||||
|
|
||||||
s = pa_msgobject_new(pa_source);
|
|
||||||
|
|
||||||
if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_SOURCE, s, data->namereg_fail))) {
|
|
||||||
pa_xfree(s);
|
pa_xfree(s);
|
||||||
|
pa_namereg_unregister(core, name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,21 +252,8 @@ void pa_source_put(pa_source *s) {
|
||||||
|
|
||||||
pa_assert(!s->min_latency || !s->max_latency || s->min_latency <= s->max_latency);
|
pa_assert(!s->min_latency || !s->max_latency || s->min_latency <= s->max_latency);
|
||||||
|
|
||||||
if (s->get_volume && s->set_volume)
|
if (!(s->flags & PA_SOURCE_HW_VOLUME_CTRL))
|
||||||
s->flags |= PA_SOURCE_HW_VOLUME_CTRL;
|
s->flags |= PA_SOURCE_DECIBEL_VOLUME;
|
||||||
else {
|
|
||||||
s->get_volume = NULL;
|
|
||||||
s->set_volume = NULL;
|
|
||||||
s->flags = (s->flags & ~PA_SOURCE_HW_VOLUME_CTRL) | PA_SOURCE_DECIBEL_VOLUME;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->get_mute && s->set_mute)
|
|
||||||
s->flags |= PA_SOURCE_HW_MUTE_CTRL;
|
|
||||||
else {
|
|
||||||
s->get_mute = NULL;
|
|
||||||
s->set_mute = NULL;
|
|
||||||
s->flags &= ~PA_SOURCE_HW_MUTE_CTRL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pa_assert_se(source_set_state(s, PA_SOURCE_IDLE) == 0);
|
pa_assert_se(source_set_state(s, PA_SOURCE_IDLE) == 0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue