[pulseaudio-discuss] [PATCH 07/13] loopback: Refactor latency initialization

Alexander E. Patrakov patrakov at gmail.com
Sun Nov 22 05:26:31 PST 2015

22.11.2015 17:21, Georg Chini wrote:
> The other big problem is that you cannot determine the number
> of cycles you will need to correct the initial latency error because
> this error is unknown before the first adjustment cycle.

You can circumvent this problem by sending zeros instead of the actual 
data until you correct the initial latency error well enough. And, 
because we are sending zeros, nobody cares if there are big frequency 
steps. So one cycle is always enough to correct the initial latency 
error once it is known, and then we can unmute the sound.

> When you calculate that safety margin you also have to consider
> that the controller might overshoot, so you temporarily could
> get less latency than you requested.

This is definitely impossible with the controller in PATCH 04/13 
modified so that min_cycles is always 1. Indeed, by design, such 
controller corrects exactly 100% of the latency error in one step, 
without paying attention that it might be noticeable. And with 
min_cycles > 1, it corrects less than 100% of the error, so cannot make 
the situation any worse than it is. I.e. here overshoot would mean 
correcting less than 0% or more than 100% of the error, and it just 
can't happen.

OTOH, the PI-controller that I am currently working on can indeed 
overshoot. I think a good idea would be to detect situations where the 
latency error is excessive or would be excessive during the next step, 
and correct this situation with your controller with min_cycles = 1, 
instead of my controller. That's, without paying attention to artifacts.

I will post this controller (and, as requested, perform measurements 
with the trivial resampler) in the near future.

Alexander E. Patrakov

More information about the pulseaudio-discuss mailing list