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

Georg Chini georg at chini.tk
Wed Aug 17 04:54:50 UTC 2016


On 17.08.2016 00:35, Tanu Kaskinen wrote:
> On Tue, 2016-08-16 at 20:51 +0200, Georg Chini wrote:
>> On 16.08.2016 19:07, Tanu Kaskinen wrote:
>>> On Sun, 2016-06-05 at 21:05 +0200, Georg Chini wrote:
>>>> ---
>>>>    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.
>> It is not a big problem, if the rate is reset unnecessarily, it will quickly
>> go back to the equilibrium value. It might however be a problem,
>> if we are switching source or sink rapidly and are still getting rid of
>> the initial latency error from the previous switch. Then the rate has
>> not yet reached the equilibrium and may be far from the nominal
>> rate. (this is what I mean with "still adjusting").
>> So it is important to switch the rate back to nominal __before__
>> switching to a new sink or source.
> Is there some problem with using the moving callback?
>
I think there was, but I cannot remember. I will test it out when I send
the next version.


More information about the pulseaudio-discuss mailing list