]> git.alsa-project.org Git - alsa-lib.git/commit
pcm_meter: let the s16 scope degrade instead of killing the caller
authorJulien Gainza <gainza.julien@gmail.com>
Tue, 21 Jul 2026 21:50:05 +0000 (23:50 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 30 Nov 2026 20:57:49 +0000 (21:57 +0100)
commit71a6acc650fe72a72b7ba8819e7e52f16dde45bb
treed92ce7c42a1d35f25bfea700454252ce8a252c04
parentaf0cba2f2df4b4b387695d401cdae7c76116ff50
pcm_meter: let the s16 scope degrade instead of killing the caller

s16_enable() returns -EINVAL for any format it cannot convert to S16 -
DSD, the 3-byte packed formats, float. snd_pcm_scope_enable() records
that as "not enabled" and carries on, so the buffer is never allocated.

Any other scope stays enabled, though, and scopes reach the s16 buffer
through snd_pcm_scope_s16_get_channel_buffer(), which asserts on exactly
that never-allocated pointer. The application dies. Our own level scope
does this, so alsa-lib kills its own caller; the same happens to
libpeppyalsa, where a DSD track aborts the music player mid-playback.

Allocate the buffer anyway and leave it zero, so a scope reads silence on
a format the s16 conversion cannot see. Callers need no change and none
can be made to abort. The condition is reported once through SNDERR
rather than being swallowed.

The neighbouring S16/MMAP_NONINTERLEAVED branch returns -EINVAL after
assigning s16->buf and reaches the same dead end; it is left alone here
because its intent is unclear.
Signed-off-by: Julien Gainza <gainza.julien@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Closes: https://github.com/alsa-project/alsa-lib/pull/516
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_meter.c