control, hw, rawmidi: accept control device node as card identifier when opening
PATCH 1/1 control, hw, rawmidi: accept control device node as card identifier when opening
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.
Lennart
--- include/pcm_plugin.h | 4 ++- src/control/cards.c | 20 ++++++++++-- src/control/control_hw.c | 69 +++++++++++++++++++++++++++++++++---------- src/control/control_local.h | 3 +- src/pcm/pcm_hw.c | 29 ++++++++++++------ src/rawmidi/rawmidi_hw.c | 30 ++++++++++++------ src/rawmidi/rawmidi_local.h | 6 ++- 7 files changed, 118 insertions(+), 43 deletions(-)
include/pcm_plugin.h +3 -1
@@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /** * \file include/pcm_plugin.h * \brief Common PCM plugin code
@@ -66,7 +67,8 @@ typedef int snd_pcm_route_ttable_entry_t;* Hardware plugin */ int snd_pcm_hw_open (snd_pcm_t **pcmp,const char *name, -int card,int device,int subdevice, +int card,const char *control_device_node, +int device,int subdevice,snd_pcm_stream_t stream,int mode,int mmap_emulation,int sync_ptr_ioctl); int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
src/control/cards.c +17 -3
@@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /** * \file control/cards.c * \brief Basic Soundcard Operations
@@ -127,12 +128,25 @@ int snd_card_get_index(const char *string)return card;return err; } + +if (string[0 ] =='/' ) { + err =snd_ctl_hw_open (&handle,NULL ,-1 , string,0 ); + +if (err <0 ) +return err; + + card =snd_ctl_hw_card (handle); +snd_ctl_close (handle); + +return card; + } +for (card =0 ; card <32 ; card++) {#ifdef SUPPORT_ALOAD if (!snd_card_load (card))continue ;#endif -if (snd_ctl_hw_open (&handle,NULL , card,0 ) <0 ) +if (snd_ctl_hw_open (&handle,NULL , card,NULL ,0 ) <0 )continue ;if (snd_ctl_card_info (handle, &info) <0 ) {snd_ctl_close (handle);
@@ -159,7 +173,7 @@ int snd_card_get_name(int card, char **name)if (name ==NULL )return -EINVAL ; -if ((err =snd_ctl_hw_open (&handle,NULL , card,0 )) <0 ) +if ((err =snd_ctl_hw_open (&handle,NULL , card,NULL ,0 )) <0 )return err;if ((err =snd_ctl_card_info (handle, &info)) <0 ) {snd_ctl_close (handle);
@@ -186,7 +200,7 @@ int snd_card_get_longname(int card, char **name)if (name ==NULL )return -EINVAL ; -if ((err =snd_ctl_hw_open (&handle,NULL , card,0 )) <0 ) +if ((err =snd_ctl_hw_open (&handle,NULL , card,NULL ,0 )) <0 )return err;if ((err =snd_ctl_card_info (handle, &info)) <0 ) {snd_ctl_close (handle);
src/control/control_hw.c +53 -16
125 lines not on this page · raw message
src/control/control_local.h +2 -1
@@ -95,6 +95,7 @@ struct _snd_hctl {int snd_ctl_new (snd_ctl_t **ctlp,snd_ctl_type_t type,const char *name);int _snd_ctl_poll_descriptor (snd_ctl_t *ctl);#define _snd_ctl_async_descriptor _snd_ctl_poll_descriptor -int snd_ctl_hw_open (snd_ctl_t **handle,const char *name,int card,int mode); +int snd_ctl_hw_open (snd_ctl_t **handle,const char *name,int card,const char *devnode,int mode); +int snd_ctl_hw_card (snd_ctl_t *handle);int snd_ctl_shm_open (snd_ctl_t **handlep,const char *name,const char *sockname,const char *sname,int mode);int snd_ctl_async (snd_ctl_t *ctl,int sig,pid_t pid);
src/pcm/pcm_hw.c +19 -10
@@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /** * \file pcm/pcm_hw.c * \ingroup PCM_Plugins
@@ -1260,7 +1261,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,* \brief Creates a new hw PCM * \param pcmp Returns created PCM handle * \param name Name of PCM -* \param card Number of card +* \param card Number of card (must be -1 if control_device_node is non-NULL) +* \param control_device_node Control device node in the file system (must be NULL if card is != -1) * \param device Number of device * \param subdevice Number of subdevice * \param stream PCM Stream
@@ -1273,7 +1275,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,* changed in future. */ int snd_pcm_hw_open (snd_pcm_t **pcmp,const char *name, -int card,int device,int subdevice, +int card,const char *control_device_node, +int device,int subdevice,snd_pcm_stream_t stream,int mode, int mmap_emulation ATTRIBUTE_UNUSED,int sync_ptr_ioctl)
@@ -1288,9 +1291,11 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,assert (pcmp); -if ((ret =snd_ctl_hw_open (&ctl,NULL , card,0 )) <0 ) +if ((ret =snd_ctl_hw_open (&ctl,NULL , card, control_device_node,0 )) <0 )return ret; + card =snd_ctl_hw_card (ctl); +switch (stream) {case SND_PCM_STREAM_PLAYBACK : filefmt =SNDRV_FILE_PCM_STREAM_PLAYBACK ;
@@ -1399,7 +1404,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, {snd_config_iterator_t i, next;long card =-1 , device =0 , subdevice =-1 ; -const char *str; +const char *str, *devnode =NULL ;int err, sync_ptr_ioctl =0 ;int rate =0 , channels =0 ;snd_pcm_format_t format =SND_PCM_FORMAT_UNKNOWN ;
@@ -1428,10 +1433,14 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,SNDERR ("Invalid type for %s" , id);return -EINVAL ; } - card =snd_card_get_index (str); -if (card <0 ) { -SNDERR ("Invalid value for %s" , id); -return card; +if (str[0 ] =='/' ) + devnode = str; +else { + card =snd_card_get_index (str); +if (card <0 ) { +SNDERR ("Invalid value for %s" , id); +return card; + } } }continue ;
@@ -1498,11 +1507,11 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,SNDERR ("Unknown field %s" , id);return -EINVAL ; } -if (card <0 ) { +if (card <0 && !devnode) {SNDERR ("card is not defined" );return -EINVAL ; } - err =snd_pcm_hw_open (pcmp, name, card, device, subdevice, stream, + err =snd_pcm_hw_open (pcmp, name, card, devnode, device, subdevice, stream, mode | (nonblock ?SND_PCM_NONBLOCK :0 ),0 , sync_ptr_ioctl);if (err <0 )
src/rawmidi/rawmidi_hw.c +20 -10
@@ -1,4 +1,5 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +* * RawMIDI - Hardware * Copyright (c) 2000 by Jaroslav Kysela <[email protected]> * Abramo Bagnara <[email protected]>
@@ -170,7 +171,9 @@ static const snd_rawmidi_ops_t snd_rawmidi_hw_ops = {int snd_rawmidi_hw_open (snd_rawmidi_t **inputp,snd_rawmidi_t **outputp, -const char *name,int card,int device,int subdevice, +const char *name, +int card,const char *control_device_node, +int device,int subdevice,int mode) {int fd, ver, ret;
@@ -186,9 +189,12 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, *inputp =NULL ;if (outputp) *outputp =NULL ; - -if ((ret =snd_ctl_hw_open (&ctl,NULL , card,0 )) <0 ) + +if ((ret =snd_ctl_hw_open (&ctl,NULL , card, control_device_node,0 )) <0 )return ret; + + card =snd_ctl_hw_card (ctl); +sprintf (filename,SNDRV_FILE_RAWMIDI , card, device); __again:
@@ -330,7 +336,7 @@ int _snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, {snd_config_iterator_t i, next;long card =-1 , device =0 , subdevice =-1 ; -const char *str; +const char *str, *devnode =NULL ;int err;snd_config_for_each (i, next, conf) {snd_config_t *n =snd_config_iterator_entry (i);
@@ -345,9 +351,13 @@ int _snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, err =snd_config_get_string (n, &str);if (err <0 )return -EINVAL ; - card =snd_card_get_index (str); -if (card <0 ) -return card; +if (str[0 ] =='/' ) + devnode = str; +else { + card =snd_card_get_index (str); +if (card <0 ) +return card; + } }continue ; }
@@ -365,8 +375,8 @@ int _snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, }return -EINVAL ; } -if (card <0 ) +if (card <0 && !devnode)return -EINVAL ; -return snd_rawmidi_hw_open (inputp, outputp, name, card, device, subdevice, mode); +return snd_rawmidi_hw_open (inputp, outputp, name, card, devnode, device, subdevice, mode); }SND_DLSYM_BUILD_VERSION (_snd_rawmidi_hw_open,SND_RAWMIDI_DLSYM_VERSION );
src/rawmidi/rawmidi_local.h +4 -2
@@ -1,4 +1,4 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * Rawmidi interface - local header file * Copyright (c) 2000 by Abramo Bagnara <[email protected]> *
@@ -51,7 +51,9 @@ struct _snd_rawmidi { };int snd_rawmidi_hw_open (snd_rawmidi_t **input,snd_rawmidi_t **output, -const char *name,int card,int device,int subdevice, +const char *name, +int card,const char *control_device_node, +int device,int subdevice,int mode); int snd_rawmidi_virtual_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
Signature · 10 lines
1.6.2.2 Lennart -- Lennart Poettering Red Hat, Inc. lennart [at] poettering [dot] net ICQ# 11060553 http://0pointer.net/lennart/ GnuPG 0x1A015CC4
Quoted 20 lines · Lennart Poettering
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/xxxxand so on.With this patch this line:
aplay -f CD -D hw:/dev/snd/controlC0 <
/dev/urandombecomes equivalent to this line:
aplay -f CD -D hw:0 <
/dev/urandomA more useful example is this:
Quoted 7 lines
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
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
Quoted 30 lines · Jaroslav Kysela
Quoted 20 lines · Lennart Poettering
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/xxxxand so on.With this patch this line:
aplay -f CD -D hw:/dev/snd/controlC0 <
/dev/urandombecomes equivalent to this line:
aplay -f CD -D hw:0 <
/dev/urandomA more useful example is this:
Quoted 7 lines
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.
Quoted 6 lines
NAK. Passing control device to
open()functions is not a good idea. Thesnd_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.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
Quoted 38 lines · Jaroslav Kysela
Quoted 35 lines · Jaroslav Kysela
Quoted 20 lines · Lennart Poettering
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/xxxxand so on.With this patch this line:
aplay -f CD -D hw:/dev/snd/controlC0 <
/dev/urandombecomes equivalent to this line:
aplay -f CD -D hw:0 <
/dev/urandomA more useful example is this:
Quoted 7 lines
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. Thesnd_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.
Quoted 7 lines
Quoted 1 line
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 allopen()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
Signature · 3 lines
Lennart Poettering Red Hat, Inc. lennart [at] poettering [dot] net http://0pointer.net/lennart/ GnuPG 0x1A015CC4
Quoted 1 line · Lennart Poettering
With my original patch there are no superfluous opens.
If application uses more *open() calls from alsa-lib for one card (for example to open ctl handle and pcm handle), it's better to obtain card index at first, because each conversion requires one or more (card id) open/close sequence for control device to get card_info. Providing direct card index eliminates this conversion. It's just suggested optimization.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
Quoted 10 lines · Jaroslav Kysela
Quoted 1 line · Lennart Poettering
With my original patch there are no superfluous opens.
If application uses more
*open()calls from alsa-lib for one card (for example to open ctl handle and pcm handle), it's better to obtain card index at first, because each conversion requires one or more (card id) open/close sequence for control device to getcard_info. Providing direct card index eliminates this conversion. It's just suggested optimization.
I think if apps want to open ctl and hw at the same time the most elegant way would be this:
<snip>snd_pcm_open(&pcm, "hw:/dev/snd/by-path/yaddayadda", ...); snd_pcm_info(pcm, &info);snd_ctl_open(&ctl, snprint("hw:%i", snd_pcm_info_get_card(info))); </snip>
With my patch that costs exactly two open() calls. It's also more flexible since it will handle arbitrary device strings, doesn't need to hardcode "hw:".
You seem to suggest this:
<snip>
i = snd_card_index("hw:/dev/snd/by-path/yaddayadda"); snd_hw_open(&hw, snprint("hw:%i", i)); snd_ctl_open(&ctl, snprint("hw:%i", i)); </snip>
Which your patch that costs three open()s. And hardcodes "hw".
I really would like to know why my patch was so bad?
Lennart
Signature · 3 lines
Lennart Poettering Red Hat, Inc. lennart [at] poettering [dot] net http://0pointer.net/lennart/ GnuPG 0x1A015CC4
Quoted 22 lines · Lennart Poettering
Quoted 10 lines · Jaroslav Kysela
Quoted 1 line · Lennart Poettering
With my original patch there are no superfluous opens.
If application uses more
*open()calls from alsa-lib for one card (for example to open ctl handle and pcm handle), it's better to obtain card index at first, because each conversion requires one or more (card id) open/close sequence for control device to getcard_info. Providing direct card index eliminates this conversion. It's just suggested optimization.I think if apps want to open ctl and hw at the same time the most elegant way would be this:
<snip>
snd_pcm_open(&pcm, "hw:/dev/snd/by-path/yaddayadda", ...);snd_pcm_info(pcm, &info);snd_ctl_open(&ctl, snprint("hw:%i", snd_pcm_info_get_card(info))); </snip>
Quoted 3 lines
With my patch that costs exactly two
open()calls. It's also more flexible since it will handle arbitrary device strings, doesn't need to hardcode "hw:".
The mentioned code will work with my patch as well. There is no difference, because extended snd_card_get_index() is called from _*open() callbacks when card argument is a string.
Quoted 4 lines
You seem to suggest this:
<snip>
i =snd_card_index("hw:/dev/snd/by-path/yaddayadda");
It should be: i = snd_card_index("/dev/snd/by-path/yaddayadda");
Quoted 1 line
snd_hw_open(&hw, snprint("hw:%i", i));
You mean probably snd_pcm_open() here.
Quoted 4 lines
snd_ctl_open(&ctl, snprint("hw:%i", i));
</snip>Which your patch that costs three open()s.
It's similar to your patch. Two open calls. snd_pcm_open() does not use ctl device if a direct card index is specified.
Quoted 1 line
And hardcodes "hw".
It's not relevant. Your code also hardcodes "hw" (and application should decide if hw: is a proper interface not alsa-lib - any defined device which accepts the card argument will work).
Quoted 1 line
I really would like to know why my patch was so bad?
I do not think that an addition of extra argument to open() calls is good in this case. The card identification for open() calls is string anyway, because you may use syntax like 'hw:FirstHDACard' - see 'cat /proc/asound/cards' for string identification. All other extensions should be in the configuration area (in .conf files or configuration parsing code).
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
Quoted 7 lines · Jaroslav Kysela
Quoted 3 lines
With my patch that costs exactly two
open()calls. It's also more flexible since it will handle arbitrary device strings, doesn't need to hardcode "hw:".The mentioned code will work with my patch as well. There is no difference, because extended
snd_card_get_index()is called from _*open() callbacks when card argument is a string.
Yes, it will work. But at the price of one extra open.
Quoted 6 lines
Quoted 4 lines
You seem to suggest this:
<snip>
i =snd_card_index("hw:/dev/snd/by-path/yaddayadda");It should be: i =
snd_card_index("/dev/snd/by-path/yaddayadda");
Yes, of course.
Quoted 4 lines
Quoted 2 lines
snd_hw_open(&hw, snprint("hw:%i", i));You mean probably
snd_pcm_open()here.
Yes, you are right.
Quoted 7 lines
Quoted 4 lines
snd_ctl_open(&ctl, snprint("hw:%i", i));
</snip>Which your patch that costs three open()s.
It's similar to your patch. Two open calls.
snd_pcm_open()does not use ctl device if a direct card index is specified.
Hmm? The first thing snd_pcm_hw_open() does is calling snd_ctl_hw_open(). So with your code, the name will bre resolved and the ctl device opened and closed for that. And then shortly after the device will be reopened right-away and then kept open. In my code after the resolving I'd just keep the device open.
Your code requires three open()s for this, mine required two.
Quoted 5 lines
Quoted 1 line
And hardcodes "hw".
It's not relevant. Your code also hardcodes "hw" (and application should decide if hw: is a proper interface not alsa-lib - any defined device which accepts the card argument will work).
The example code I gave doesn't hardcode it. You can specify any device as long as the stream info knows the card parameter properly.
Quoted 8 lines
Quoted 1 line
I really would like to know why my patch was so bad?
I do not think that an addition of extra argument to
open()calls is good in this case. The card identification foropen()calls is string anyway, because you may use syntax like 'hw:FirstHDACard' - see 'cat/proc/asound/cards' for string identification. All other extensions should be in the configuration area (in .conf files or configuration parsing code).
Hmm? The whole point of my patch was to make ALSA devices a bit more like other devices, i.e. with persistancy of device symlinks and stuff. Also, AFAICS the snd_pcm_hw_open() call (and friends) are internal anyway?
Anyway, given that your code has the same effect as mine, it's probably not worth dicussing this any further...
Lennart
Signature · 3 lines
Lennart Poettering Red Hat, Inc. lennart [at] poettering [dot] net http://0pointer.net/lennart/ GnuPG 0x1A015CC4
Quoted 7 lines · Lennart Poettering
Hmm? The first thing
snd_pcm_hw_open()does is callingsnd_ctl_hw_open(). So with your code, the name will bre resolved and the ctl device opened and closed for that. And then shortly after the device will be reopened right-away and then kept open. In my code after the resolving I'd just keep the device open.Your code requires three open()s for this, mine required two.
I see your point now - I forgot that control API is used to prefer subdevices. But it would be better to add some cache for ctl opens in alsa-lib rather than abusing other levels of API with additional information.
Thanks,
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
Quoted 25 lines · Jaroslav Kysela
Quoted 22 lines · Lennart Poettering
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/xxxxand so on.With this patch this line:
aplay -f CD -D hw:/dev/snd/controlC0 <
/dev/urandombecomes equivalent to this line:
aplay -f CD -D hw:0 <
/dev/urandomA more useful example is this:
aplay -f CD -D hw:/dev/snd/by-path/pci-0000:00:1a.7-usb-0:2:1.2
Quoted 7 lines
Quoted 5 lines
(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?
Quoted 3 lines
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 applications.
Lennart
Signature · 3 lines
Lennart Poettering Red Hat, Inc. lennart [at] poettering [dot] net http://0pointer.net/lennart/ GnuPG 0x1A015CC4