clean up event generation a little: suppress unnecessary events and generate new...
authorLennart Poettering <lennart@poettering.net>
Sat, 12 Aug 2006 02:19:36 +0000 (02:19 +0000)
committerLennart Poettering <lennart@poettering.net>
Sat, 12 Aug 2006 02:19:36 +0000 (02:19 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1212 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/pulsecore/sink-input.c
src/pulsecore/sink.c
src/pulsecore/source-output.c
src/pulsecore/source.c

index b89210f..701d7f6 100644 (file)
@@ -437,6 +437,12 @@ void pa_sink_input_set_name(pa_sink_input *i, const char *name) {
     assert(i);
     assert(i->ref >= 1);
 
+    if (!i->name && !name)
+        return;
+
+    if (i->name && name && !strcmp(i->name, name))
+        return;
+    
     pa_xfree(i->name);
     i->name = pa_xstrdup(name);
 
index eecf89c..d1d9785 100644 (file)
@@ -446,11 +446,16 @@ pa_usec_t pa_sink_get_latency(pa_sink *s) {
 void pa_sink_set_owner(pa_sink *s, pa_module *m) {
     assert(s);
     assert(s->ref >= 1);
-           
+
+    if (s->owner == m)
+        return;
+    
     s->owner = m;
 
     if (s->monitor_source)
         pa_source_set_owner(s->monitor_source, m);
+
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
 }
 
 void pa_sink_set_volume(pa_sink *s, pa_mixer_t m, const pa_cvolume *volume) {
index 1ffaeda..36ea420 100644 (file)
@@ -208,6 +208,12 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) {
 void pa_source_output_set_name(pa_source_output *o, const char *name) {
     assert(o);
     assert(o->ref >= 1);
+
+    if (!o->name && !name)
+        return;
+
+    if (o->name && name && !strcmp(o->name, name))
+        return;
     
     pa_xfree(o->name);
     o->name = pa_xstrdup(name);
index f9c0703..903de88 100644 (file)
@@ -225,8 +225,12 @@ void pa_source_post(pa_source*s, const pa_memchunk *chunk) {
 void pa_source_set_owner(pa_source *s, pa_module *m) {
     assert(s);
     assert(s->ref >= 1);
+
+    if (m == s->owner)
+        return;
     
     s->owner = m;
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
 }
 
 pa_usec_t pa_source_get_latency(pa_source *s) {