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);
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);
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 */
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 */