sink: Unlink monitor source before unlinking sink

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>
This commit is contained in:
Georg Chini 2021-01-31 20:08:11 +01:00 committed by PulseAudio Marge Bot
parent 597a1eb1ba
commit 12cf6da242

View 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);