sink: Unlink monitor source before unlinking sink
authorGeorg Chini <georg@chini.tk>
Sun, 31 Jan 2021 19:08:11 +0000 (20:08 +0100)
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>
Mon, 1 Feb 2021 16:03:46 +0000 (16:03 +0000)
Unlinking the monitor source after unlinking the sink leads to a crash when the monitor
source is master of a virtual source. Changing the unlink order fixes the problem.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/493>

src/pulsecore/sink.c

index e8aeb17..90dc250 100644 (file)
@@ -784,6 +784,10 @@ void pa_sink_unlink(pa_sink* s) {
         j = i;
     }
 
+    /* Unlink monitor source before unlinking the sink */
+    if (s->monitor_source)
+        pa_source_unlink(s->monitor_source);
+
     if (linked)
         /* It's important to keep the suspend cause unchanged when unlinking,
          * because if we remove the SESSION suspend cause here, the alsa sink
@@ -795,9 +799,6 @@ void pa_sink_unlink(pa_sink* s) {
 
     reset_callbacks(s);
 
-    if (s->monitor_source)
-        pa_source_unlink(s->monitor_source);
-
     if (linked) {
         pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
         pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_UNLINK_POST], s);