]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm_meter: reset s16 scope format state on disable and DSD state on reset
authorJaroslav Kysela <perex@perex.cz>
Mon, 30 Nov 2026 20:54:39 +0000 (21:54 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 30 Nov 2026 20:58:01 +0000 (21:58 +0100)
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 <perex@perex.cz>
src/pcm/pcm_meter.c

index bfced6274cc14792d43003bce048f8424f320883..6eaa816a3da55a14d3cd2928980f9c12bbb5b8fb 100644 (file)
@@ -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;
 }