[pulseaudio-discuss] [PATCH v6 16/25] loopback: Reset sink input rate when source or sink changes

Tanu Kaskinen tanuk at iki.fi
Tue Aug 16 17:07:10 UTC 2016


On Sun, 2016-06-05 at 21:05 +0200, Georg Chini wrote:
> When source or sink changes, the sink input rate has to be reset to
> the initial value.

This sentence doesn't really add anything to the commit title ("Reset
sink input rate when source or sink changes"). It would be better if
the commit message said *why* the rate has to be reset.

> 
> ---
>  src/modules/module-loopback.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/src/modules/module-loopback.c b/src/modules/module-
> loopback.c
> index c54b531..c773a98 100644
> --- a/src/modules/module-loopback.c
> +++ b/src/modules/module-loopback.c
> @@ -539,7 +539,12 @@ static bool
> source_output_may_move_to_cb(pa_source_output *o, pa_source *dest) {
>      if (!u->sink_input || !u->sink_input->sink)
>          return true;
>  
> -    return dest != u->sink_input->sink->monitor_source;
> +    /* We may still be adjusting, so reset rate to default before
> moving the source */
> +    if (dest != u->sink_input->sink->monitor_source) {
> +        pa_sink_input_set_rate(u->sink_input, u->source_output-
> >sample_spec.rate);
> +        return true;
> +    }
> +    return false;

This is not the right place to reset the rate. Even if we return true
here, it doesn't mean that the stream will actually be moved, so we may
end up resetting the rate needlessly.

Also, "we may still be adjusting" doesn't make much sense to me. Do you
mean that after the rate stabilizes, we wouldn't necessarily have to
reset the rate? Why not?

-- 
Tanu


More information about the pulseaudio-discuss mailing list