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.
This commit is contained in:
Georg Chini 2017-03-29 07:11:50 +02:00
parent 3650346f70
commit f4f01f6833

View file

@ -565,8 +565,10 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) {
set_source_output_latency(u, dest); set_source_output_latency(u, dest);
update_effective_source_latency(u, dest, u->sink_input->sink); 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) 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 else
pa_sink_input_cork(u->sink_input, false); 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); set_sink_input_latency(u, dest);
update_effective_source_latency(u, u->source_output->source, 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) 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 else
pa_source_output_cork(u->source_output, false); pa_source_output_cork(u->source_output, false);