[pulseaudio-discuss] Audio cards with subdevices

Lennart Poettering lennart at poettering.net
Sat May 2 07:34:24 PDT 2009


On Sat, 02.05.09 14:02, Daniel Mack (daniel at caiaq.de) wrote:

> 
> On Fri, May 01, 2009 at 05:20:23PM +0200, Lennart Poettering wrote:
> > > In my test environment, I have a card with two subdevices.
> > > It lists as follows using 'aplay -l':
> > > 
> > > card 0: DJ [Audio 4 DJ], device 0: Audio 4 DJ [Audio 4 DJ]
> > >   Subdevices: 1/2
> > >   Subdevice #0: subdevice #0
> > >   Subdevice #1: subdevice #1
> > 
> > PA knows nothing about subdevices. What a subdevice is is highly
> > dependant on the card and on the driver and there is no way to find
> > out from userspace what they actually mean and are mapped to. We only
> > access cards via "front:", "surround51:", "iec985:" and similar
> > high-level access methods which hide those internals to us and map
> > to right low-level channels.
> 
> Hmm, but it would be possible to iterate over all the subdevices and see
> what kind of channels there are in each one, right?

No. To my knowledge ALSA has no API for that.

> The soundcard connected in this case exports a stereo pair in each
> subdevice, and users can decided to use the second one by using ALSA's
> '-D hw:0,0,1'. I carefully thought about how to export all channels of
> the hardware in the driver when I wrote it, and the most logical view on
> he hardware features is seeing them as group of stereo input and ouputs.
> Things like "front:", "surround51:", "iec985:" are not appropriate, this
> is just not what it does.

So these two subdevices are completely independant? I.e. can be
independantly configured as if they were two seperate sound cards?
>From PA's perspective the most natural way to expose them to user
space would be in two different cards then. But I guess from the
drivers perspective that doesn't make much sense.

How do they appear in "aplay -L"?

I think the problem is simply that ALSA doesn't really cater for these
setups. We cannot autodetect these cases. Device enumeration is
(together with mixer handling) one of the weakest points in ALSA.

> > For your card how would you expect PA to wrap the subdevices on
> > your specific card?
> 
> I would expect it to display all streams of all subdevices, so I can
> address them individually, move a client from one to the next, select
> one stereo pair of one particular subdevice as default, mute them and
> set the volume seperately etc.

Hmm, so you have two sets of controls too?

Unfortunately ALSA has no way to find the right mixer controls for a
specific PCM playback channel. The only option we have is assuming that
PCM and Master actually control the PCM volume. If you have multiple
independant streams this wouldn't work, because we wouldn't know which
slider maps to the second stream.

I am currently pondering to make the set of device strings and mixer
paths PA probes for and uses configurable via config
files. That would then allow easy extension which could be used by
vendors to define weirder setups to probe for, and also allow proper
i18n of mixer controls. I am not really sure though yet about this,
because this honestly something that should be fixed on the ALSA
level, and adding another mixer mapping layer on top of ctl, hctl,
mixer, smixer smells really really foul.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4



More information about the pulseaudio-discuss mailing list