PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.51k stars 307 forks source link

Rejecting ALSA devices with high max number of channels is wrong #797

Open s09bQ5 opened 1 year ago

s09bQ5 commented 1 year ago

Describe the bug I have a very normal audio setup without fancy new stuff like PulseAudio or PipeWire. Just plain ALSA. There is no special configuration. I use the default configs installed with alsa-lib. The default config makes the default audio device a softvol+dmix ALSA plugin combination that mixes the audio from all applications in software to be output by the HDA on board soundchip.

The plugins don't limit the number of channels they can accept. libasound limits the number of channels to 10000 when the plugin/hardware does not impose another limit.

Since b3f637f55e74c7b8fd05ebdfb04a2c8547e316ba PortAudio rejects all devices that allow more than 1024 channels, which breaks sound for me.

To Reproduce

  1. Install Linux without PulseAudio or PipeWire
  2. Try to play sound

Expected behavior The default ALSA device is used

FillInDevInfo: Filling device info for: default
GropeDevice: collecting info ..
GropeDevice: Limiting number of plugin channels to 128
GropeDevice: collecting info ..
GropeDevice: Limiting number of plugin channels to 128
Default input device: default
Default output device: default
FillInDevInfo: Adding device default: 13

Actual behavior The default ALSA device is rejected

FillInDevInfo: Filling device info for: default
GropeDevice: collecting info ..
GropeDevice: maxChans = 10000, which is unreasonably high
FillInDevInfo: Failed groping default for capture

Desktop (please complete the following information):

philburk commented 1 year ago

The PR is #729

We still want to catch broken devices, which is sometimes indicated by crazy high max channels.

We could change kReasonableMaxChannels from 1024 to 20000. We should also change the name to "kAcceptableMaxChannels".

After we accept devices with that high number of channels, should we then limit the number of channels that PortAudio will use to 1024?

s09bQ5 commented 1 year ago

The libasound limit appears to be applied only to plugins. In case of #594 it might have been a raw hardware device that reported this high maximum.

PortAudio already limits ALSA plugins to 128 channels. What is the worst thing that could happen if we accept all devices (plugin and raw hw) regardless of maximum number of channels and limit all of them to 128? Are there sound cards with more than 128 channels? Pro audio cards for studios maybe?

s09bQ5 commented 1 year ago

The RME HDSPe MADI FX has 390 channels, so raising the limit a little would make sense if we apply it also to hw devices.

RossBencina commented 1 year ago

If a hardware device supports (say) 390 channels, then presumably we need to allow for plugins that somehow adapt against that device, so the plugin channel limit should at a minimum be whatever hardware channel count we will tolerate.

RossBencina commented 6 months ago

@s09bQ5 We're working on finalising the v19.8 release and this seems like a regression that we must fix. Are you still around to test a fix? Do you have a specific proposed fix?