Bug 252761 - multichannel USB audio device reports only 2 channels via SNDCTL_AUDIOINFO
Summary: multichannel USB audio device reports only 2 channels via SNDCTL_AUDIOINFO
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-17 01:04 UTC by Ed Maste
Modified: 2021-01-20 18:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2021-01-17 01:04:08 UTC
After attaching an 18-in / 18-out device:

ugen0.7: <BEHRINGER X18/XR18> at usbus0
uaudio0 on uhub0
uaudio0: <X18/XR18> on usbus0
uaudio0: Play[0]: 48000 Hz, 18 ch, 32-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 48000 Hz, 18 ch, 32-bit S-LE PCM format, 2x8ms buffer.
uaudio0: MIDI sequencer.
pcm2: <USB audio> on uaudio0
uaudio0: No HID volume keys found.

SNDCTL_AUDIOINFO reports min_channels = 2, max_channels = 2


pcm/dsp.c::dsp_oss_audioinfo() only reports 1 or 2 for min/max it appears:

                        for (i = 0; caps->fmtlist[i]; i++) {
                                fmts |= caps->fmtlist[i];
                                if (AFMT_CHANNEL(caps->fmtlist[i]) > 1) {
                                        minch = (minch == 0) ? 2 : minch;
                                        maxch = 2;
                                } else {
                                        minch = 1;
                                        maxch = (maxch == 0) ? 1 : maxch;
                                }
                        }
Comment 1 Hans Petter Selasky freebsd_committer 2021-01-18 15:50:53 UTC
FreeBSD OSS use stereo mode by default, unless you set
"dev.pcm.<n>.play.vchanformat" and "dev.pcm.<n>.rec.vchanformat". If there is more than 8 channels, then only bitperfect mode is supported.

Maybe the audioinfo could need an update in that regards. I think we support up to 127 channels, limited by AFMT.

--HPS
Comment 2 Ed Maste freebsd_committer 2021-01-18 16:18:46 UTC
Indeed, this attaches with bitperfect mode enabled
dev.pcm.2.bitperfect: 1

The 2nd problem I encountered is Audacity's OSS support via PortAudio does not support beyond S16_NE.

I will try (sometime) to have a look at improving audioinfo reporting in this case.
Comment 3 Ed Maste freebsd_committer 2021-01-20 03:43:53 UTC
I've submitted a few pull requests to PortAudio related to the work that prompted this PR:

https://github.com/PortAudio/portaudio/pull/448
https://github.com/PortAudio/portaudio/pull/449
https://github.com/PortAudio/portaudio/pull/450

with these applied as well as addition of cases for AFMT_S32_NE I can now record from the XR18 in 2 channel mode with bitperfect=1.

Attempting to record in 18 channel mode results in a PA assertion:

21:42:13: Debug: GetBestRate() suggested rate 48000 Hz
21:42:13: Debug: GetBestRate() Returning 48000 Hz
Assertion failed: (firstChannel + channelCount <= bp->inputChannelCount), function PaUtil_SetInterleavedInputChannels, file src/common/pa_process.c, line 482.
Abort trap (core dumped)
Comment 4 Ed Maste freebsd_committer 2021-01-20 17:48:14 UTC
Looks like PA OSS only tries up to 16 channels:

https://github.com/PortAudio/portaudio/blob/master/src/hostapi/oss/pa_unix_oss.c#L358

    /* Negotiate for the maximum number of channels for this device. PLB20010927
     * Consider up to 16 as the upper number of channels.
     * Variable maxNumChannels should contain the actual upper limit after the call.
     * Thanks to John Lazzaro and Heiko Purnhagen for suggestions.
     */
    maxNumChannels = 0;
    for( numChannels = 1; numChannels <= 16; numChannels++ )
    {
Comment 5 Ed Maste freebsd_committer 2021-01-20 18:10:37 UTC
That's not directly the cause of the assertion though, the values involved in the assertion expression:
firstChannel=0
channelCount=18
bp->inputChannelCount=2