All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lennart Poettering <mznyfn@0pointer.de>
To: alsa-devel@alsa-project.org
Subject: Re: [PATCH] control, hw, rawmidi: accept control	device node as card identifier when opening
Date: Tue, 12 May 2009 15:24:47 +0200	[thread overview]
Message-ID: <20090512132447.GF29607@tango.0pointer.de> (raw)
In-Reply-To: <alpine.LNX.2.00.0905121433510.25064@eeebox2.perex-int.cz>

On Tue, 12.05.09 14:42, Jaroslav Kysela (perex@perex.cz) wrote:

> 
> On Tue, 12 May 2009, Lennart Poettering wrote:
> 
> > 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.

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

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

  reply	other threads:[~2009-05-12 13:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-11 22:41 [PATCH] control, hw, rawmidi: accept control device node as card identifier when opening Lennart Poettering
2009-05-12  6:09 ` Jaroslav Kysela
2009-05-12 11:40   ` Jaroslav Kysela
2009-05-12 12:32     ` Lennart Poettering
2009-05-12 12:42       ` Jaroslav Kysela
2009-05-12 13:24         ` Lennart Poettering [this message]
2009-05-12 14:40           ` Jaroslav Kysela
2009-05-12 16:04             ` Lennart Poettering
2009-05-12 16:54               ` Jaroslav Kysela
2009-05-12 12:29   ` Lennart Poettering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090512132447.GF29607@tango.0pointer.de \
    --to=mznyfn@0pointer.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.