From: Jaroslav Kysela Date: Fri, 20 Aug 2010 08:31:17 +0000 (+0200) Subject: namehint: Evaluate more possibilities for hw devices X-Git-Tag: v1.0.24~27 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=97d25c0766405453d3c298bd51dd4916121a4f6a;p=alsa-lib.git namehint: Evaluate more possibilities for hw devices This tries to fix the issue when logical device indexes does not match the hardware device indexes (like hdmi -> 0:3, 1:7, 2:8, 3:9). Signed-off-by: Jaroslav Kysela --- diff --git a/src/control/namehint.c b/src/control/namehint.c index 18192921..e06d2407 100644 --- a/src/control/namehint.c +++ b/src/control/namehint.c @@ -414,6 +414,7 @@ static int add_card(struct hint_list *list, int card) const char *str; char ctl_name[16]; snd_ctl_card_info_t *info; + int device, max_device = 0; snd_ctl_card_info_alloca(&info); list->info = info; @@ -431,18 +432,25 @@ static int add_card(struct hint_list *list, int card) n = snd_config_iterator_entry(i); if (snd_config_get_id(n, &str) < 0) continue; + if (next_devices[list->iface] != NULL) { list->card = card; - list->device = -1; - err = next_devices[list->iface](list->ctl, &list->device); - if (list->device < 0) + device = max_device = -1; + err = next_devices[list->iface](list->ctl, &device); + if (device < 0) err = -EINVAL; + while (err >= 0 && device >= 0) { + err = next_devices[list->iface](list->ctl, &device); + if (device > max_device) + max_device = device; + ok++; + } ok = 0; - while (err >= 0 && list->device >= 0) { + for (device = 0; err >= 0 && device < max_device; device++) { + list->device = device; err = try_config(list, list->siface, str); if (err < 0) break; - err = next_devices[list->iface](list->ctl, &list->device); ok++; } if (ok)