[alsa-devel] [PATCH] control, hw, rawmidi: accept control device node as card identifier when opening

Lennart Poettering mznyfn at 0pointer.de
Tue May 12 14:29:42 CEST 2009

On Tue, 12.05.09 08:09, Jaroslav Kysela (perex at perex.cz) wrote:

> On Tue, 12 May 2009, Lennart Poettering wrote:
> > Heya!
> >
> > Traditionally low-level ALSA devices are opened with device strings like
> > 'hw:CARD' where CARD is either a numeric index or a card name. This
> > patch introduces a third syntax that allows you to specify the file name
> > of the control device node. The purpose for this is to make ALSA a bit
> > more like other Linux devices and allow implementaiton of udev device
> > symlinks similar to how disks are currently handled, with
> > /dev/disk/by-path/xxxx /dev/disk/by-id/xxxx and so on.
> >
> > With this patch this line:
> >
> >  aplay -f CD -D hw:/dev/snd/controlC0 < /dev/urandom
> >
> > becomes equivalent to this line:
> >
> >  aplay -f CD -D hw:0 < /dev/urandom
> >
> > A more useful example is this:
> >
> >  aplay -f CD -D hw:/dev/snd/by-path/pci-0000:00:1a.7-usb-0:2:1.2
> >
> > (this line requires a a few additional udev rules)
> >
> > This only works for control devices nodes, not for PCM or any other
> > device nodes. Since the control device node is used as 'entry point'
> > when opening PCM devices this is no limitation.
> NAK. Passing control device to open() functions is not a good idea. 

Why? Please elaborate!

The whole point of this patch is to allow users to write struff like
hw:/dev/snd/by-path/pci-0000:00:1a.7-usb-0:2:1.2 whereever they could
otherwise write hw:0. Why is that a bad idea?

> The snd_card_get_index() function might be extended to allow /dev
> style argument. Returned card index can be used as argument for hw:
> devices without this massive change.

This is no improvement at all, because no application does that. The
point of the patch was to improve the flexibility for all


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

More information about the Alsa-devel mailing list