* pcm_meter: let the s16 scope degrade instead of killing the caller
[not found] <alsa-project/alsa-lib/pr/516@alsa-project.org>
@ 2026-07-21 21:56 ` GitHub pull_request - opened
2026-07-27 7:42 ` GitHub pull_request - edited
1 sibling, 0 replies; 2+ messages in thread
From: GitHub pull_request - opened @ 2026-07-21 21:56 UTC (permalink / raw)
To: alsa-devel
alsa-project/alsa-lib pull request #516 was opened from Gjuju:
## The bug
`s16_enable()` returns `-EINVAL` for any format it cannot convert to S16 — the DSD
formats, the 3-byte packed ones (`S24_3LE`/`S24_3BE`/`S20_3LE`), float.
`snd_pcm_scope_enable()` records that as "not enabled" and carries on:
```c
err = scope->ops->enable(scope);
scope->enabled = (err >= 0);
```
But every *other* scope stays enabled, and scopes reach the s16 buffer through
`snd_pcm_scope_s16_get_channel_buffer()`, which asserts on exactly the pointer
`s16_enable()` never allocated:
```
pcm_meter.c:1224: snd_pcm_scope_s16_get_channel_buffer: Assertion 's16->buf_areas' failed.
```
The application dies. This is not hypothetical and not third-party only: alsa-lib's own
`src/pcm/scopes/level.c` calls the accessor the same way, so the library aborts its own
caller. Downstream, `libpeppyalsa` (the VU-meter scope used by moOde audio player) makes
a music player abort mid-playback the moment a DSD track starts.
Note the failure is *not* DSD-specific — any format outside the 17 the switch lists
triggers it, including `S24_3LE`, which plenty of USB DACs expose natively. A chain that
happens to have a `plug` in front of the meter is merely lucky.
## The fix
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 —
which matters, since returning `NULL` instead would only move an unfixed caller from
`SIGABRT` to `SIGSEGV`. The condition is now reported once through `SNDERR()` instead of
being swallowed.
## Testing
x86-64, Debian 13, USB DAC with a native DSD path, moOde audio player with its VU meter
scope in the chain. Playing a DSD64 `.dsf` with `dop=no`:
- **before**: MPD aborts on the assertion, the UI reports "Socket open failed"
- **after**: the DAC receives `DSD_U32_BE @ 88200` bit-perfect, MPD stays up
(`NRestarts: 0`), needles read zero, and the log carries
`s16 scope: no S16 conversion for format DSD_U32_BE, scopes will read silence`
## Left alone
The neighbouring `S16` + `MMAP_NONINTERLEAVED` branch assigns `s16->buf` and then also
returns `-EINVAL`, reaching the same dead end. It looks unfinished rather than
deliberate, so this patch does not touch it — happy to follow up if you can confirm the
intent.
Request URL : https://github.com/alsa-project/alsa-lib/pull/516
Patch URL : https://github.com/alsa-project/alsa-lib/pull/516.patch
Repository URL: https://github.com/alsa-project/alsa-lib
^ permalink raw reply [flat|nested] 2+ messages in thread
* pcm_meter: let the s16 scope degrade instead of killing the caller
[not found] <alsa-project/alsa-lib/pr/516@alsa-project.org>
2026-07-21 21:56 ` pcm_meter: let the s16 scope degrade instead of killing the caller GitHub pull_request - opened
@ 2026-07-27 7:42 ` GitHub pull_request - edited
1 sibling, 0 replies; 2+ messages in thread
From: GitHub pull_request - edited @ 2026-07-27 7:42 UTC (permalink / raw)
To: alsa-devel
alsa-project/alsa-lib pull request #516 was edited from Gjuju:
## The bug
`s16_enable()` returns `-EINVAL` for any format it cannot convert to S16 — the DSD
formats, the 3-byte packed ones (`S24_3LE`/`S24_3BE`/`S20_3LE`), float.
`snd_pcm_scope_enable()` records that as "not enabled" and carries on:
```c
err = scope->ops->enable(scope);
scope->enabled = (err >= 0);
```
But every *other* scope stays enabled, and scopes reach the s16 buffer through
`snd_pcm_scope_s16_get_channel_buffer()`, which asserts on exactly the pointer
`s16_enable()` never allocated:
```
pcm_meter.c:1224: snd_pcm_scope_s16_get_channel_buffer: Assertion 's16->buf_areas' failed.
```
The application dies. This is not hypothetical and not third-party only: alsa-lib's own
`src/pcm/scopes/level.c` calls the accessor the same way, so the library aborts its own
caller. Any out-of-tree scope reaching the buffer through the same documented accessor
fails identically, and a music player aborts mid-playback the moment a DSD track starts.
Note the failure is *not* DSD-specific — any format outside the 17 the switch lists
triggers it, including `S24_3LE`, which plenty of USB DACs expose natively. A chain that
happens to have a `plug` in front of the meter is merely lucky.
## The fix
Allocate the buffer anyway and leave it zeroed, so the accessor always returns valid
memory and the s16 buffer carries silence for a format the conversion cannot express.
Callers need no change, and none can be made to abort — which matters, since returning
`NULL` instead would only move an unfixed caller from `SIGABRT` to `SIGSEGV`. The
condition is now reported once through `SNDERR()` instead of being swallowed.
## Testing
x86-64, Debian 13, USB DAC with a native DSD path, MPD playing a DSD64 `.dsf` with
`dop=no` through a `type meter` PCM with a scope attached:
- **before**: MPD aborts on the assertion and playback dies
- **after**: the DAC receives `DSD_U32_BE @ 88200` bit-perfect, MPD stays up and is
never restarted, the s16 buffer is exposed zero-filled, and the log carries
`s16 scope: no S16 conversion for format DSD_U32_BE, scopes will read silence`
## Left alone
The neighbouring `S16` + `MMAP_NONINTERLEAVED` branch assigns `s16->buf` and then also
returns `-EINVAL`, reaching the same dead end. It looks unfinished rather than
deliberate, so this patch does not touch it — happy to follow up if you can confirm the
intent.
Request URL : https://github.com/alsa-project/alsa-lib/pull/516
Patch URL : https://github.com/alsa-project/alsa-lib/pull/516.patch
Repository URL: https://github.com/alsa-project/alsa-lib
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-27 7:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <alsa-project/alsa-lib/pr/516@alsa-project.org>
2026-07-21 21:56 ` pcm_meter: let the s16 scope degrade instead of killing the caller GitHub pull_request - opened
2026-07-27 7:42 ` GitHub pull_request - edited
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.