summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2016-12-08 01:59:02 +0200
committerTanu Kaskinen <tanuk@iki.fi>2016-12-20 01:34:32 +0200
commit539eb5c24418e3e473656da2f8ea5727754da037 (patch)
treeeaae32417438e17bc1e34f788042b4e43336bfe7
parent74ff1153425c927e6dfd198cbf1e0d6edfbfa873 (diff)
sink, source: unify stream "attached" flag checking
The "attached" flag is only used for asserting that the stream is in the expected state when attaching or detaching. Sometimes the flag was checked and updated before calling the attach or detach callback, and sometimes after. I think it makes more sense to always check it before calling the callback.
-rw-r--r--src/pulsecore/sink.c12
-rw-r--r--src/pulsecore/source.c6
2 files changed, 9 insertions, 9 deletions
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index a745f09b6..3a2dd6c81 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2536,14 +2536,14 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
* sink input handling a few lines down at
* PA_SINK_MESSAGE_START_MOVE, too. */
+ pa_assert(i->thread_info.attached);
+ i->thread_info.attached = false;
+
if (i->detach)
i->detach(i);
pa_sink_input_set_state_within_thread(i, i->state);
- pa_assert(i->thread_info.attached);
- i->thread_info.attached = false;
-
/* Since the caller sleeps in pa_sink_input_unlink(),
* we can safely access data outside of thread_info even
* though it is mutable */
@@ -2635,12 +2635,12 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
}
}
- if (i->detach)
- i->detach(i);
-
pa_assert(i->thread_info.attached);
i->thread_info.attached = false;
+ if (i->detach)
+ i->detach(i);
+
/* Let's remove the sink input ...*/
pa_hashmap_remove_and_free(s->thread_info.inputs, PA_UINT32_TO_PTR(i->index));
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 4615702bf..51b7fd9da 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -2062,12 +2062,12 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
pa_source_output_set_state_within_thread(o, o->state);
- if (o->detach)
- o->detach(o);
-
pa_assert(o->thread_info.attached);
o->thread_info.attached = false;
+ if (o->detach)
+ o->detach(o);
+
if (o->thread_info.direct_on_input) {
pa_hashmap_remove(o->thread_info.direct_on_input->thread_info.direct_outputs, PA_UINT32_TO_PTR(o->index));
o->thread_info.direct_on_input = NULL;