alsa: clamp elapsed time to delay

If the elapsed time is larger than the delay, we are dealing with
an older timestamp.

Fixes #597
This commit is contained in:
Wim Taymans 2021-01-20 11:54:19 +01:00
parent 384b8a4593
commit 675a12ef33

View file

@ -192,6 +192,8 @@ static int snd_pcm_pipewire_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delay
clock_gettime(CLOCK_MONOTONIC, &ts);
diff = SPA_TIMESPEC_TO_NSEC(&ts) - pw->time.now;
elapsed = (pw->time.rate.denom * diff) / (pw->time.rate.num * SPA_NSEC_PER_SEC);
if (elapsed > pw->time.delay)
elapsed = pw->time.delay;
}
filled = pw->time.delay + snd_pcm_ioplug_hw_avail(io, pw->hw_ptr, io->appl_ptr);