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

Lennart Poettering mznyfn at 0pointer.de
Tue May 12 18:04:37 CEST 2009


On Tue, 12.05.09 16:40, Jaroslav Kysela (perex at perex.cz) wrote:

> > 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. 

> > 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.

> 
> > snd_hw_open(&hw, snprint("hw:%i", i));
> 
> You mean probably snd_pcm_open() here.

Yes, you are right.

> > 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. 

> > 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.

> > 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).

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

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


More information about the Alsa-devel mailing list