Skip to content

Fix crash when enumerating sample rates with pa_devs - #1199

Open
philburk wants to merge 1 commit into
masterfrom
fix_maxchans_1198
Open

philburk wants to merge 1 commit into
masterfrom
fix_maxchans_1198

Conversation

@philburk

Copy link
Copy Markdown
Collaborator

Pipewire can only handle a max of 64 channels.

PipeWire's SPA library defines SPA_AUDIO_MAX_CHANNELS as 64 (#define SPA_AUDIO_MAX_CHANNELS 64u).

When examples/pa_devs.c passes deviceInfo->maxInputChannels (128) into TestParameters(), alsa_snd_pcm_hw_params( pcm, hwParams ) at line 1959 triggers pcm_pipewire.c to configure a PipeWire stream with 128 channels, overflowing 64-element channel arrays in alsa-pipewire.

Fixes #1198

Pipewire can only handle a max of 64 channels.

PipeWire's SPA library defines SPA_AUDIO_MAX_CHANNELS as 64 (#define
SPA_AUDIO_MAX_CHANNELS 64u). When examples/pa_devs.c passes
deviceInfo->maxInputChannels (128) into TestParameters(),
alsa_snd_pcm_hw_params( pcm, hwParams ) at line 1959 triggers
pcm_pipewire.c to configure a PipeWire stream with 128 channels,
overflowing 64-element channel arrays in alsa-pipewire.

Fixes #1198
@philburk

Copy link
Copy Markdown
Collaborator Author

I did the same experiment using Ubuntu 26.04 running on a Parallels VM.
It crashed the same in pipewire.
The PR #1198 fixed the crash.

@philburk

philburk commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Do ALL plugins have the 64 channel restriction? Or just pipewire?
Can we detect pipewire plugins and treat separately.

@philburk

philburk commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Gemini says:

Different plugins have different intrinsic limits when queried via snd_pcm_hw_params_get_channels_max:

ALSA plug / route (sysdefault, plughw, and default when wrapped by plug): Does not restrict channels to the slave's limit; it reports 10000 max channels because plug can duplicate/route channels in software. (That is why sysdefault and default hit PortAudio's if (isPlug && maxChans > 64) clamp.)

PipeWire (pipewire): Bounded by SPA_AUDIO_MAX_CHANNELS = 64. (When default wraps pipewire via plug, plug reports 10000, which previously got clamped to 128 and overflowed PipeWire's 64-channel SPA arrays.)

PulseAudio (pulse / libpulse): Bounded by PA_CHANNELS_MAX = 32 (defined in /usr/include/pulse/sample.h:128).
Hardware-backed plugins (dmix, front, surround40, surround51, surround71): Report their slave/topology channel count (e.g., 2 or 8), so they are already below 64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

segmentation fault in pa_devs on Ubuntu using master, failed on pipewire

1 participant