[pulseaudio-discuss] [PATCH v6 16/25] loopback: Reset sink input rate when source or sink changes
Georg Chini
georg at chini.tk
Tue Aug 16 18:51:59 UTC 2016
On 16.08.2016 19:07, Tanu Kaskinen wrote:
> 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.
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.
> 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?
>
"Still adjusting" means that the rate is far from the equilibrium rate.
More information about the pulseaudio-discuss
mailing list