From d04ee917143f2b62ddd86a02fbfd9c341109f3b2 Mon Sep 17 00:00:00 2001 From: Martin Geier Date: Fri, 13 Jun 2025 12:33:35 +0200 Subject: [PATCH] plugins: alsa: increase follower write synchronization when htimestamps are enabled alsa_write_sync can insert or remove some data from alsa when resynchronization is needed. Avail and delay are equal when high precision timestamps are not allowed. When the high precision timestamps are enabled, the delay is avail adjusted to current_time. Signed-off-by: Martin Geier --- spa/plugins/alsa/alsa-pcm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 9d823d9d2..73df819ba 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -3020,10 +3020,10 @@ static int alsa_write_sync(struct state *state, uint64_t current_time) state->name, avail, delay, target, state->threshold, suppressed); - if (avail > target) - snd_pcm_rewind(state->hndl, avail - target); - else if (avail < target) - spa_alsa_silence(state, target - avail); + if (delay > target) + snd_pcm_rewind(state->hndl, delay - target); + else if (delay < target) + spa_alsa_silence(state, target - delay); avail = target; } spa_dll_init(&state->dll);