[pulseaudio-discuss] [PATCH 2/2] loopback: Fix corking logic of module-loopback
Tanu Kaskinen
tanuk at iki.fi
Tue Mar 28 19:44:55 UTC 2017
On Sun, 2017-03-26 at 21:40 +0200, Georg Chini wrote:
> 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 4456b55..5dcefba 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);
Looks good to me.
--
Tanu
https://www.patreon.com/tanuk
More information about the pulseaudio-discuss
mailing list