From 64c1b62aa8f766e5c55e98d9403401c712944d65 Mon Sep 17 00:00:00 2001 From: Jonas Holmberg Date: Wed, 11 May 2022 17:41:56 +0200 Subject: [PATCH] alsa-pcm: Do not log warning when resync was expected Log as info instead of warning when alsa sync was expected. --- spa/plugins/alsa/alsa-pcm.c | 22 ++++++++++++++++++---- spa/plugins/alsa/alsa-pcm.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 1dbbcb910..61101f34d 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -1791,9 +1791,11 @@ static int update_time(struct state *state, uint64_t current_time, snd_pcm_sfram if (err > state->max_error) { err = state->max_error; state->alsa_sync = true; + state->alsa_sync_warning = (diff == 0); } else if (err < -state->max_error) { err = -state->max_error; state->alsa_sync = true; + state->alsa_sync_warning = (diff == 0); } if (!follower || state->matching) @@ -1901,8 +1903,14 @@ int spa_alsa_write(struct state *state) return res; if (SPA_UNLIKELY(state->alsa_sync)) { - spa_log_warn(state->log, "%s: follower delay:%ld target:%ld thr:%u, resync", - state->props.device, delay, target, state->threshold); + if (SPA_UNLIKELY(state->alsa_sync_warning)) { + spa_log_warn(state->log, "%s: follower delay:%ld target:%ld thr:%u, resync", + state->props.device, delay, target, state->threshold); + state->alsa_sync_warning = false; + } else + spa_log_info(state->log, "%s: follower delay:%ld target:%ld thr:%u, resync", + state->props.device, delay, target, state->threshold); + if (delay > target) snd_pcm_rewind(state->hndl, delay - target); else if (delay < target) @@ -2139,8 +2147,14 @@ int spa_alsa_read(struct state *state) avail = delay; if (state->alsa_sync) { - spa_log_warn(state->log, "%s: follower delay:%lu target:%lu thr:%u, resync", - state->props.device, delay, target, threshold); + if (SPA_UNLIKELY(state->alsa_sync_warning)) { + spa_log_warn(state->log, "%s: follower delay:%lu target:%lu thr:%u, resync", + state->props.device, delay, target, threshold); + state->alsa_sync_warning = false; + } else + spa_log_info(state->log, "%s: follower delay:%lu target:%lu thr:%u, resync", + state->props.device, delay, target, threshold); + if (delay < target) max_read = target - delay; else if (delay > target) diff --git a/spa/plugins/alsa/alsa-pcm.h b/spa/plugins/alsa/alsa-pcm.h index 65ed51a82..6f16e3696 100644 --- a/spa/plugins/alsa/alsa-pcm.h +++ b/spa/plugins/alsa/alsa-pcm.h @@ -192,6 +192,7 @@ struct state { uint32_t duration; unsigned int alsa_started:1; unsigned int alsa_sync:1; + unsigned int alsa_sync_warning:1; unsigned int alsa_recovering:1; unsigned int following:1; unsigned int matching:1;