From f4f01f6833b30841e026febe0d831b7b3489b981 Mon Sep 17 00:00:00 2001 From: Georg Chini Date: Wed, 29 Mar 2017 07:11:50 +0200 Subject: loopback: Fix corking logic of module-loopback When moving from a user suspended source or sink to an idle suspended source or sink the sink input or source output would not be uncorked because we did not check for the suspend cause. Uncorking also would not be possible in that situation because the state change callback of the source output or sink input is called before the new source or sink is attached, leading to a crash of pulseaudio due to a cork() call without valid source or sink. The previous patch fixes this problem, therefore sink input or source output can now also be uncorked when the destination is idle suspended. --- src/modules/module-loopback.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c index 4456b559..5dcefbaa 100644 --- a/src/modules/module-loopback.c +++ b/src/modules/module-loopback.c @@ -565,8 +565,10 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) { set_source_output_latency(u, dest); update_effective_source_latency(u, dest, u->sink_input->sink); + /* Uncork the sink input unless the destination is suspended for other + * reasons than idle. */ if (pa_source_get_state(dest) == PA_SOURCE_SUSPENDED) - pa_sink_input_cork(u->sink_input, true); + pa_sink_input_cork(u->sink_input, (dest->suspend_cause != PA_SUSPEND_IDLE)); else pa_sink_input_cork(u->sink_input, false); @@ -904,8 +906,10 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) { set_sink_input_latency(u, dest); update_effective_source_latency(u, u->source_output->source, dest); + /* Uncork the source output unless the destination is suspended for other + * reasons than idle */ if (pa_sink_get_state(dest) == PA_SINK_SUSPENDED) - pa_source_output_cork(u->source_output, true); + pa_source_output_cork(u->source_output, (dest->suspend_cause != PA_SUSPEND_IDLE)); else pa_source_output_cork(u->source_output, false); -- cgit v1.2.3