[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:32:30 CEST 2009
On Tue, 12.05.09 13:40, Jaroslav Kysela (perex at perex.cz) wrote:
>
> On Tue, 12 May 2009, Jaroslav Kysela 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. 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.
> >
> > http://git.alsa-project.org/?p=alsa-lib.git;a=commit;h=33ab0b5381c87e151e87e5000964edd868484886
>
> I just noticed that snd_card_get_index() is used to parse "card"
> configuration item when it's string, so control device name can be passed
> instead card identification to all open() functions in alsa-lib with my
> above patch, too. But it's preferred to use direct card index to reduce
> control device open/close sequences.
With my original patch there are no superfluous opens.
Lennart
--
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
More information about the Alsa-devel
mailing list