[alsa-devel] Getting a full device list (was: alsa-lib functions reporting conflicting information with two sound cards)
Nicholas Smethurst
nick.smethurst at gmail.com
Fri May 11 12:28:43 CEST 2007
Takashi wrote:
> At Thu, 19 Apr 2007 20:08:21 +0200,
> Nicholas Smethurst wrote:
>> However, I note that snd_device_name_hint() does not return hw, plughw,
>> plug, dmix, etc. Are these obtained elsewhere? I would like to build a
>> complete list of all available devices in order to allow the user to
>> select them from a dropdown list in a GUI.
>
> They are not shown unless you give the device description explicitly
> or set a global flag. See the description of snd_device_name_hint()
> function.
Well I tried to understand how to do the two things you mention, but am
still stuck..
In namehint.c, I note that the snd_device_name_hint() function has the
following code:
if (strcmp(iface, "card") == 0)
list.iface = SND_CTL_ELEM_IFACE_CARD;
else if (strcmp(iface, "pcm") == 0)
list.iface = SND_CTL_ELEM_IFACE_PCM;
else if (strcmp(iface, "rawmidi") == 0)
list.iface = SND_CTL_ELEM_IFACE_RAWMIDI;
else if (strcmp(iface, "timer") == 0)
list.iface = SND_CTL_ELEM_IFACE_TIMER;
else if (strcmp(iface, "seq") == 0)
list.iface = SND_CTL_ELEM_IFACE_SEQUENCER;
else if (strcmp(iface, "hwdep") == 0)
list.iface = SND_CTL_ELEM_IFACE_HWDEP;
else
return -EINVAL;
which thus gives possible interface strings of "card", "pcm", "rawmidi",
"timer", "seq", and "hwdep". I concluded from this that the only way to
get the default devices is to set the global variable.
I thus tried doing the following in a small test app:
snd_config_t * conf;
int show_all;
snd_config_update();
if (snd_config_search(snd_config, "defaults.namehint.showall",
&conf) >= 0) {
show_all = snd_config_get_bool(conf);
if (show_all < 1) {
snd_config_set_integer(conf, 1);
}
} else { // Create node.
...
}
but this doesn't work.. I am apparently doing something wrong since the
global configuration is not changed with my code.
Is it possible to change global variables from a user application? Or is
it currently necessary to manually edit the alsa.conf file (as root) in
order to modify "defaults.namehint.showall" to allow applications to see
all devices?
I wish to obtain a full list of available devices in a user application
without running as root and without insisting that the user manually
edits configuration files that he doesn't understand.
Is this possible? If not, can we work towards implementing such
functionality?
Nicholas
More information about the Alsa-devel
mailing list