[pulseaudio-discuss] [PATCH 02/21 v2] loopback: Initialize latency at startup and during source/sink changes

Tanu Kaskinen tanuk at iki.fi
Sat Feb 25 19:29:35 UTC 2017


On Sat, 2017-02-25 at 19:21 +0200, Tanu Kaskinen wrote:
> On Sat, 2017-02-25 at 14:01 +0100, Georg Chini wrote:
> > On 25.02.2017 13:51, Tanu Kaskinen wrote:
> > > The second adjustment does the right thing regardless of whether the
> > > first adjustment was done or not, so why not skip the first adjustment
> > > altogether?
> > 
> > Because it might be the case that we are only switching the source OR the
> > sink and if we are changing both or starting up, we don't know which will
> > come first.
> 
> So you're saying that skipping the first adjustment as I suggested
> can't be done? I think this should do the trick:
> 
> if (pop_adjust) {
>     /* Final adjustment. */
>     offset = sink_latency + source_latency;
>     memblockq_adjust(offset, true);
>     pop_adjust = false;
> } else if (!pop_called) {
>     /* Waiting for the sink to start. */
>     offset = 0;
>     memblockq_adjust(offset, false);
> }
> push_called = true;

That doesn't handle correctly the case where just the source changes.
The first if condition needs to be changed to

if (pop_adjust || (pop_called && !push_called))

-- 
Tanu

https://www.patreon.com/tanuk


More information about the pulseaudio-discuss mailing list