From a595d3dddb05b521bf3b56c55f854b5c9d471ec9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 18 Oct 2023 14:49:46 +0200 Subject: [PATCH] alsa: after a resync, reset the dll Otherwise we might still be overcompensating for the previous errors and generate more errors. Fixes #3584 --- spa/plugins/alsa/alsa-pcm.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index bb4bea2dc..b37fa151f 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2438,18 +2438,20 @@ static int alsa_write_sync(struct state *state, uint64_t current_time) else lev = SPA_LOG_LEVEL_INFO; - if ((suppressed = spa_ratelimit_test(&state->rate_limit, current_time)) >= 0) { - spa_log_lev(state->log, lev, "%s: follower avail:%lu delay:%ld " - "target:%ld thr:%u, resync (%d suppressed)", - state->name, avail, delay, - target, state->threshold, suppressed); - } + if ((suppressed = spa_ratelimit_test(&state->rate_limit, current_time)) < 0) + lev = SPA_LOG_LEVEL_DEBUG; + + spa_log_lev(state->log, lev, "%s: follower avail:%lu delay:%ld " + "target:%ld thr:%u, resync (%d suppressed)", + 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); avail = target; + spa_dll_init(&state->dll); state->alsa_sync = false; } else state->alsa_sync_warning = true; @@ -2698,11 +2700,12 @@ static int alsa_read_sync(struct state *state, uint64_t current_time) else lev = SPA_LOG_LEVEL_INFO; - if ((suppressed = spa_ratelimit_test(&state->rate_limit, current_time)) >= 0) { - spa_log_lev(state->log, lev, "%s: follower delay:%ld target:%ld thr:%u, " - "resync (%d suppressed)", state->name, delay, - target, state->threshold, suppressed); - } + if ((suppressed = spa_ratelimit_test(&state->rate_limit, current_time)) < 0) + lev = SPA_LOG_LEVEL_DEBUG; + + spa_log_lev(state->log, lev, "%s: follower delay:%ld target:%ld thr:%u " + "resample:%d, resync (%d suppressed)", state->name, delay, + target, state->threshold, state->resample, suppressed); if (avail < target) max_read = target - avail; @@ -2711,6 +2714,7 @@ static int alsa_read_sync(struct state *state, uint64_t current_time) avail = target; } state->alsa_sync = false; + spa_dll_init(&state->dll); } else state->alsa_sync_warning = true;