namehint: Evaluate more possibilities for hw devices
authorJaroslav Kysela <perex@perex.cz>
Fri, 20 Aug 2010 08:31:17 +0000 (10:31 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 20 Aug 2010 08:33:32 +0000 (10:33 +0200)
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 <perex@perex.cz>

src/control/namehint.c

index 1819292..e06d240 100644 (file)
@@ -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)