[pulseaudio-commits] r1203 - in /trunk/src/pulsecore: sink.c sink.h source.c source.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Fri Aug 11 10:53:35 PDT 2006


Author: lennart
Date: Fri Aug 11 19:53:34 2006
New Revision: 1203

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1203&root=pulseaudio&view=rev
Log:
* introduce new functions pa_sink_set_description() and pa_source_set_description() for changing the description of a sink/source
* allow sinks without monitor sources attached

Modified:
    trunk/src/pulsecore/sink.c
    trunk/src/pulsecore/sink.h
    trunk/src/pulsecore/source.c
    trunk/src/pulsecore/source.h

Modified: trunk/src/pulsecore/sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/sink.c?rev=1203&root=pulseaudio&r1=1202&r2=1203&view=diff
==============================================================================
--- trunk/src/pulsecore/sink.c (original)
+++ trunk/src/pulsecore/sink.c Fri Aug 11 19:53:34 2006
@@ -118,12 +118,19 @@
     pa_sample_spec_snprint(st, sizeof(st), spec);
     pa_log_info(__FILE__": created %u \"%s\" with sample spec \"%s\"", s->index, s->name, st);
 
-    n = pa_sprintf_malloc("%s_monitor", name);
-    s->monitor_source = pa_source_new(core, driver, n, 0, spec, map);
-    assert(s->monitor_source);
+    n = pa_sprintf_malloc("%s.monitor", name);
+    
+    if (!(s->monitor_source = pa_source_new(core, driver, n, 0, spec, map)))
+        pa_log_warn(__FILE__": failed to create monitor source.");
+    else {
+        char *d;
+        s->monitor_source->monitor_of = s;
+        d = pa_sprintf_malloc("Monitor Source of %s", s->name);
+        pa_source_set_description(s->monitor_source, d);
+        pa_xfree(d);
+    }
+
     pa_xfree(n);
-    s->monitor_source->monitor_of = s;
-    s->monitor_source->description = pa_sprintf_malloc("Monitor source of sink '%s'", s->name);
     
     pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_NEW, s->index);
     
@@ -144,7 +151,8 @@
         j = i;
     }
 
-    pa_source_disconnect(s->monitor_source);
+    if (s->monitor_source)
+        pa_source_disconnect(s->monitor_source);
 
     pa_idxset_remove_by_data(s->core->sinks, s, NULL);
 
@@ -168,8 +176,10 @@
 
     pa_log_info(__FILE__": freed %u \"%s\"", s->index, s->name); 
 
-    pa_source_unref(s->monitor_source);
-    s->monitor_source = NULL;
+    if (s->monitor_source) {
+        pa_source_unref(s->monitor_source);
+        s->monitor_source = NULL;
+    }
     
     pa_idxset_free(s->inputs, NULL, NULL);
 
@@ -304,7 +314,9 @@
     }
 
     inputs_drop(s, info, n, result->length);
-    pa_source_post(s->monitor_source, result);
+
+    if (s->monitor_source)
+        pa_source_post(s->monitor_source, result);
 
     r = 0;
 
@@ -358,7 +370,9 @@
                                 s->sw_muted);
     
     inputs_drop(s, info, n, target->length);
-    pa_source_post(s->monitor_source, target);
+
+    if (s->monitor_source)
+        pa_source_post(s->monitor_source, target);
 
     r = 0;
 
@@ -513,3 +527,27 @@
     } else
         return s->sw_muted;
 }
+
+void pa_sink_set_description(pa_sink *s, const char *description) {
+    assert(s);
+    assert(s->ref >= 1);
+
+    if (!description && !s->description)
+        return;
+
+    if (description && s->description && !strcmp(description, s->description))
+        return;
+    
+    pa_xfree(s->description);
+    s->description = pa_xstrdup(description);
+
+    if (s->monitor_source) {
+        char *n;
+    
+        n = pa_sprintf_malloc("Monitor Source of %s", s->description? s->description : s->name);
+        pa_source_set_description(s->monitor_source, n);
+        pa_xfree(n);
+    }
+        
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+}

Modified: trunk/src/pulsecore/sink.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/sink.h?rev=1203&root=pulseaudio&r1=1202&r2=1203&view=diff
==============================================================================
--- trunk/src/pulsecore/sink.h (original)
+++ trunk/src/pulsecore/sink.h Fri Aug 11 19:53:34 2006
@@ -100,4 +100,6 @@
 void pa_sink_set_mute(pa_sink *sink, pa_mixer_t m, int mute);
 int pa_sink_get_mute(pa_sink *sink, pa_mixer_t m);
 
+void pa_sink_set_description(pa_sink *s, const char *description);
+
 #endif

Modified: trunk/src/pulsecore/source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/source.c?rev=1203&root=pulseaudio&r1=1202&r2=1203&view=diff
==============================================================================
--- trunk/src/pulsecore/source.c (original)
+++ trunk/src/pulsecore/source.c Fri Aug 11 19:53:34 2006
@@ -313,3 +313,19 @@
     } else
         return s->sw_muted;
 }
+
+void pa_source_set_description(pa_source *s, const char *description) {
+    assert(s);
+    assert(s->ref >= 1);
+
+    if (!description && !s->description)
+        return;
+
+    if (description && s->description && !strcmp(description, s->description))
+        return;
+    
+    pa_xfree(s->description);
+    s->description = pa_xstrdup(description);
+
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+}

Modified: trunk/src/pulsecore/source.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/source.h?rev=1203&root=pulseaudio&r1=1202&r2=1203&view=diff
==============================================================================
--- trunk/src/pulsecore/source.h (original)
+++ trunk/src/pulsecore/source.h Fri Aug 11 19:53:34 2006
@@ -100,4 +100,7 @@
 void pa_source_set_mute(pa_source *source, pa_mixer_t m, int mute);
 int pa_source_get_mute(pa_source *source, pa_mixer_t m);
 
+void pa_source_set_description(pa_source *s, const char *description);
+
+
 #endif




More information about the pulseaudio-commits mailing list