sink, source: add missing stream "attached" flag handling
authorTanu Kaskinen <tanuk@iki.fi>
Wed, 7 Dec 2016 23:59:03 +0000 (01:59 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 19 Dec 2016 23:35:58 +0000 (01:35 +0200)
The functions that call attach()/detach() for all streams on a sink or
source didn't update the "attached" flag accordingly. Since the flag is
only used in assertions, this omission didn't cause any harm in normal
use.

src/pulsecore/sink.c
src/pulsecore/source.c

index 3a2dd6c..475e03b 100644 (file)
@@ -2931,9 +2931,13 @@ void pa_sink_detach_within_thread(pa_sink *s) {
     pa_sink_assert_io_context(s);
     pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
 
-    PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state)
+    PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state) {
+        pa_assert(i->thread_info.attached);
+        i->thread_info.attached = false;
+
         if (i->detach)
             i->detach(i);
+    }
 
     if (s->monitor_source)
         pa_source_detach_within_thread(s->monitor_source);
@@ -2948,9 +2952,13 @@ void pa_sink_attach_within_thread(pa_sink *s) {
     pa_sink_assert_io_context(s);
     pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
 
-    PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state)
+    PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state) {
+        pa_assert(!i->thread_info.attached);
+        i->thread_info.attached = true;
+
         if (i->attach)
             i->attach(i);
+    }
 
     if (s->monitor_source)
         pa_source_attach_within_thread(s->monitor_source);
index 51b7fd9..3c4a3cf 100644 (file)
@@ -2288,9 +2288,13 @@ void pa_source_detach_within_thread(pa_source *s) {
     pa_source_assert_io_context(s);
     pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
 
-    PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state)
+    PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state) {
+        pa_assert(o->thread_info.attached);
+        o->thread_info.attached = false;
+
         if (o->detach)
             o->detach(o);
+    }
 }
 
 /* Called from IO thread */
@@ -2302,9 +2306,13 @@ void pa_source_attach_within_thread(pa_source *s) {
     pa_source_assert_io_context(s);
     pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
 
-    PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state)
+    PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state) {
+        pa_assert(!o->thread_info.attached);
+        o->thread_info.attached = true;
+
         if (o->attach)
             o->attach(o);
+    }
 }
 
 /* Called from IO thread */