alsa-project / alsa-lib

The Advanced Linux Sound Architecture (ALSA) - library
GNU Lesser General Public License v2.1
357 stars 176 forks source link

`USB-Audio`: Wrong S/PDIF (`iec958`) input and output #292

Open sibzou opened 1 year ago

sibzou commented 1 year ago

I am new to the Linux sound system. As I understand, USB sound cards doesn't directly tell the kernel or alsa-lib how many S/PDIF inputs and outputs they have. But they obviously tell their "brand name" like "Plantronics USB Headset" or "HP Digital Stereo Headset" for example.

To present the correct number of S/PDIF inputs and outputs to the rest of the userspace, alsa-lib seems to maintain a kind of known devices database in src/conf/cards/USB-Audio.conf.

If a USB card brand is not known in this file, alsa-lib always present a single S/PDIF input and a single S/PDIF output. If the index of this card is 1 for example, snd_pcm_open(&pcm, "iec958:1", SND_PCM_STREAM_PLAYBACK, 0) and snd_pcm_open(&pcm, "iec958:1", SND_PCM_STREAM_CAPTURE, 0) will always return 0 even if the USB device doesn't have a real S/PDIF input or output.

My question is why this is the default behavior? We are in a "every USB cards have S/PDIF, except those who are known in USB-Audio.conf" logic. I think it should be "None USB card has S/PDIF except those who are known for it in USB-Audio.conf" because USB devices without S/PDIF are much more common.

Cf https://bugs.launchpad.net/ubuntu/+source/alsa-lib/+bug/1002952

Thank you!

perexg commented 1 year ago

At first, it's a bit late to change this configuration scheme now. If we revert the database as you suggest, the hardware with S/PDIF will not work (regression), because there's no collection of this data. I think that the point was to enable all features by default. @tiwai ?

We are moving to UCM anyway, so we can be more careful there.

sibzou commented 1 year ago

there's no collection of this data

So you confirm that we can't know how many S/PDIF inputs and outputs a device have other than by having an internal database that maps his name to this number of inputs/outputs?

We are moving to UCM anyway, so we can be more careful there.

I don't know UCM well, how it helps to be more careful?