sink, source: Don't finish move if unlink happens after pa_*_move_all_start()
authorGeorg Chini <georg@chini.tk>
Sun, 3 Dec 2017 21:29:09 +0000 (22:29 +0100)
committerGeorg Chini <georg@chini.tk>
Sun, 3 Dec 2017 21:29:09 +0000 (22:29 +0100)
When a sink input was unlinked between the calls to pa_sink_move_all_start() and
pa_sink_move_all_finish(), pa_sink_move_all_finish() tried to finish the move
of the already unlinked sink input, which lead to an assertion in
pa_sink_input_finish_move(). The same applies for the source side.

This patch fixes the problem by checking the state of the sink input or
source output in pa_*_move_all_finish().

Bug report: https://bugs.freedesktop.org/show_bug.cgi?id=103752

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

index 017b953..39bf18f 100644 (file)
@@ -920,9 +920,11 @@ void pa_sink_move_all_finish(pa_sink *s, pa_queue *q, bool save) {
     pa_assert(q);
 
     while ((i = PA_SINK_INPUT(pa_queue_pop(q)))) {
-        if (pa_sink_input_finish_move(i, s, save) < 0)
-            pa_sink_input_fail_move(i);
+        if (PA_SINK_INPUT_IS_LINKED(i->state)) {
+            if (pa_sink_input_finish_move(i, s, save) < 0)
+                pa_sink_input_fail_move(i);
 
+        }
         pa_sink_input_unref(i);
     }
 
index d579c35..6099c10 100644 (file)
@@ -860,9 +860,11 @@ void pa_source_move_all_finish(pa_source *s, pa_queue *q, bool save) {
     pa_assert(q);
 
     while ((o = PA_SOURCE_OUTPUT(pa_queue_pop(q)))) {
-        if (pa_source_output_finish_move(o, s, save) < 0)
-            pa_source_output_fail_move(o);
+        if (PA_SOURCE_OUTPUT_IS_LINKED(o->state)) {
+            if (pa_source_output_finish_move(o, s, save) < 0)
+                pa_source_output_fail_move(o);
 
+        }
         pa_source_output_unref(o);
     }