<div dir="ltr"><div class="gmail_default" style="font-size:small">Devices with the same device description cannot be distinguished.<br>Add card number to the description of second and subsequent instances<br>of devices with the same description.  This mimics Windows behavior.<br><br>Signed-off-by: Doug Kingston <<a href="mailto:dpk@google.com">dpk@google.com</a>><br>---<br> dlls/winealsa.drv/mmdevdrv.c | 43 ++++++++++++++++++++++++++++++++++++<br> 1 file changed, 43 insertions(+)<br><br>diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c<br>index 318350471db..a26d09a0bd7 100644<br>--- a/dlls/winealsa.drv/mmdevdrv.c<br>+++ b/dlls/winealsa.drv/mmdevdrv.c<br>@@ -22,6 +22,8 @@<br> #include "config.h"<br><br> #include <stdarg.h><br>+#define _GNU_SOURCE<br>+#include <stdio.h><br> #include <math.h><br><br> #include "windef.h"<br>@@ -521,6 +523,36 @@ static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR ***id<br>     }<br> }<br><br>+struct card_type {<br>+    struct list entry;<br>+    int first_card_number;<br>+    char string[1];<br>+};<br>+<br>+static struct list card_types = LIST_INIT(card_types);<br>+<br>+static BOOL need_card_number(int card, const char *string)<br>+{<br>+    struct card_type *cptr;<br>+<br>+    LIST_FOR_EACH_ENTRY(cptr, &card_types, struct card_type, entry)<br>+    {<br>+        if(!strcmp(string, cptr->string))<br>+            return card != cptr->first_card_number;<br>+    }<br>+<br>+    /* this is the first instance of string */<br>+    cptr = HeapAlloc(GetProcessHeap(), 0, sizeof(struct card_type) + strlen(string));<br>+    if(!cptr)<br>+        /* Default to displaying card number if we can't track cards */<br>+        return TRUE;<br>+<br>+    cptr->first_card_number = card;<br>+    strcpy(cptr->string, string);<br>+    list_add_head(&card_types, &cptr->entry);<br>+    return FALSE;<br>+}<br>+<br> static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR ***ids, GUID **guids,<br>         UINT *num)<br> {<br>@@ -564,6 +596,17 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR ***ids, GUID **guids,<br>                     cardpath, err, snd_strerror(err));<br>             alsa_get_card_devices(flow, stream, ids, guids, num, ctl, card, nameW);<br>         }else{<br>+            if(need_card_number(card, cardname)){<br>+                char *cardnameN;<br>+                /*<br>+                 * For identical instances, second and subsequent instances get<br>+                 * instance number prefix to distinguish them (like Windows).<br>+                 */<br>+                if(asprintf(&cardnameN, "%u-%s", card, cardname) > 0){<br>+                    free(cardname);<br>+                    cardname = cardnameN;<br>+                }<br>+            }<br>             len = MultiByteToWideChar(CP_UNIXCP, 0, cardname, -1, NULL, 0);<br>             cardnameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));<br><br>--<br>2.24.3 (Apple Git-128)<br></div><div class="gmail_default" style="font-size:small"><br></div></div>