alsa-plugin: fix delay reporting

The delay should be calculated based on the amount of samples available
to the application, not the hardware.

This overreported the delay.

See #1697
This commit is contained in:
Wim Taymans 2021-11-24 12:19:22 +01:00
parent d8e24fca1c
commit 301e729864

View file

@ -223,7 +223,7 @@ static int snd_pcm_pipewire_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delay
diff = SPA_TIMESPEC_TO_NSEC(&ts) - pw->time.now;
elapsed = (pw->time.rate.denom * diff) / (pw->time.rate.num * SPA_NSEC_PER_SEC);
}
filled = pw->time.delay + snd_pcm_ioplug_hw_avail(io, pw->hw_ptr, io->appl_ptr);
filled = pw->time.delay + snd_pcm_ioplug_avail(io, pw->hw_ptr, io->appl_ptr);
if (io->stream == SND_PCM_STREAM_PLAYBACK)
*delayp = filled - SPA_MIN(elapsed, filled);