[pulseaudio-commits] r2260 - in /branches/glitch-free/src/pulsecore: sink.c source.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Fri Apr 11 10:05:51 PDT 2008


Author: lennart
Date: Fri Apr 11 19:05:46 2008
New Revision: 2260

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2260&root=pulseaudio&view=rev
Log:
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

Modified:
    branches/glitch-free/src/pulsecore/sink.c
    branches/glitch-free/src/pulsecore/source.c

Modified: branches/glitch-free/src/pulsecore/sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/sink.c?rev=2260&root=pulseaudio&r1=2259&r2=2260&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/sink.c (original)
+++ branches/glitch-free/src/pulsecore/sink.c Fri Apr 11 19:05:46 2008
@@ -118,9 +118,22 @@
 
     pa_assert(core);
     pa_assert(data);
-
-    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_NEW], data) < 0)
+    pa_assert(data->name);
+
+    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;
+    }
+
+    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->name && pa_utf8_valid(data->name) && data->name[0]);
@@ -142,13 +155,9 @@
     if (!data->muted_is_set)
         data->muted = FALSE;
 
-    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))) {
+    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_FIXATE], data) < 0) {
         pa_xfree(s);
+        pa_namereg_unregister(core, name);
         return NULL;
     }
 
@@ -212,11 +221,12 @@
     pa_source_new_data_set_channel_map(&source_data, &s->channel_map);
     source_data.name = pa_sprintf_malloc("%s.monitor", name);
     source_data.driver = data->driver;
+    source_data.module = data->module;
 
     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_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);
 
@@ -281,15 +291,8 @@
 
     pa_assert(!s->min_latency || !s->max_latency || s->min_latency <= s->max_latency);
 
-    if (s->get_volume && s->set_volume)
-        s->flags |= PA_SINK_HW_VOLUME_CTRL;
-    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;
+    if (!(s->flags & PA_SINK_HW_VOLUME_CTRL))
+        s->flags |= PA_SINK_DECIBEL_VOLUME;
 
     pa_assert_se(sink_set_state(s, PA_SINK_IDLE) == 0);
 

Modified: branches/glitch-free/src/pulsecore/source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/source.c?rev=2260&root=pulseaudio&r1=2259&r2=2260&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/source.c (original)
+++ branches/glitch-free/src/pulsecore/source.c Fri Apr 11 19:05:46 2008
@@ -110,8 +110,18 @@
 
     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;
+    }
+
+    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->name && pa_utf8_valid(data->name) && data->name[0]);
@@ -133,13 +143,9 @@
     if (!data->muted_is_set)
         data->muted = FALSE;
 
-    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))) {
+    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], data) < 0) {
         pa_xfree(s);
+        pa_namereg_unregister(core, name);
         return NULL;
     }
 
@@ -246,21 +252,8 @@
 
     pa_assert(!s->min_latency || !s->max_latency || s->min_latency <= s->max_latency);
 
-    if (s->get_volume && s->set_volume)
-        s->flags |= PA_SOURCE_HW_VOLUME_CTRL;
-    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;
-    }
+    if (!(s->flags & PA_SOURCE_HW_VOLUME_CTRL))
+        s->flags |= PA_SOURCE_DECIBEL_VOLUME;
 
     pa_assert_se(source_set_state(s, PA_SOURCE_IDLE) == 0);
 




More information about the pulseaudio-commits mailing list