From: Jaroslav Kysela Date: Mon, 30 Nov 2026 20:54:39 +0000 (+0100) Subject: pcm_meter: reset s16 scope format state on disable and DSD state on reset X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=7647c08e50124b9062d0b214bc20b26f8cf05e0f;p=alsa-lib.git pcm_meter: reset s16 scope format state on disable and DSD state on reset Clear silent/dsd_bits/dsd_shift in s16_disable so a re-enable starts clean, and zero the DSD EMA accumulators in s16_reset so the level does not carry a stale value across an xrun restart. Signed-off-by: Jaroslav Kysela --- diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c index bfced627..6eaa816a 100644 --- a/src/pcm/pcm_meter.c +++ b/src/pcm/pcm_meter.c @@ -1215,6 +1215,11 @@ static void s16_disable(snd_pcm_scope_t *scope) s16->buf = NULL; free(s16->buf_areas); s16->buf_areas = 0; + /* Clear the format-derived state too, so a re-enable with a different + * format starts clean instead of inheriting a stale decode path. */ + s16->silent = 0; + s16->dsd_bits = 0; + s16->dsd_shift = 0; } static void s16_close(snd_pcm_scope_t *scope) @@ -1305,6 +1310,11 @@ static void s16_reset(snd_pcm_scope_t *scope) { snd_pcm_scope_s16_t *s16 = scope->private_data; snd_pcm_meter_t *meter = s16->pcm->private_data; + /* Drop the DSD EMA accumulators so the level does not carry a stale + * value across a reset (e.g. an xrun restart). */ + if (s16->dsd_states) + memset(s16->dsd_states, 0, + meter->gen.slave->channels * sizeof(*s16->dsd_states)); s16->old = meter->now; }