From dacbeca77e24e3ea33053a580c1f6118160ae7f4 Mon Sep 17 00:00:00 2001 From: Jonas Holmberg Date: Wed, 21 Sep 2022 16:39:31 +0200 Subject: [PATCH] alsa-pcm: Change resync warning logic Log follower resync messages with info level until there has been a successful read or write to get rid of the initial warning when starting a stream. --- spa/plugins/alsa/alsa-pcm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 5f851bebe..d0cdb3e58 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -1887,15 +1887,14 @@ static int update_time(struct state *state, uint64_t current_time, snd_pcm_sfram state, follower, state->last_threshold, state->threshold, diff, err); state->last_threshold = state->threshold; state->alsa_sync = true; + state->alsa_sync_warning = false; } 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) @@ -2014,10 +2013,9 @@ int spa_alsa_write(struct state *state) if (SPA_UNLIKELY(state->alsa_sync)) { enum spa_log_level lev; - if (SPA_UNLIKELY(state->alsa_sync_warning)) { + if (SPA_UNLIKELY(state->alsa_sync_warning)) lev = SPA_LOG_LEVEL_WARN; - state->alsa_sync_warning = false; - } else + else lev = SPA_LOG_LEVEL_INFO; if ((missed = ratelimit_test(&state->rate_limit, current_time)) >= 0) { @@ -2032,7 +2030,8 @@ int spa_alsa_write(struct state *state) spa_alsa_silence(state, target - delay); delay = target; state->alsa_sync = false; - } + } else + state->alsa_sync_warning = true; } total_written = 0; @@ -2248,10 +2247,9 @@ int spa_alsa_read(struct state *state) if (state->alsa_sync) { enum spa_log_level lev; - if (SPA_UNLIKELY(state->alsa_sync_warning)) { + if (SPA_UNLIKELY(state->alsa_sync_warning)) lev = SPA_LOG_LEVEL_WARN; - state->alsa_sync_warning = false; - } else + else lev = SPA_LOG_LEVEL_INFO; if ((missed = ratelimit_test(&state->rate_limit, current_time)) >= 0) { @@ -2266,7 +2264,8 @@ int spa_alsa_read(struct state *state) snd_pcm_forward(state->hndl, delay - target); delay = target; state->alsa_sync = false; - } + } else + state->alsa_sync_warning = true; if (avail < state->read_size) max_read = 0; @@ -2555,6 +2554,7 @@ int spa_alsa_start(struct state *state) reset_buffers(state); state->alsa_sync = true; + state->alsa_sync_warning = false; state->alsa_recovering = false; state->alsa_started = false;