aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-06-30 07:44:56 -0700
committerChris Robinson <[email protected]>2015-06-30 07:44:56 -0700
commitd90dfc8d1f4f9ae374230cab837400a64503c2c1 (patch)
treef270b2f1f36a9d8e82ae6ec80c2f4f4d9f80cc7b
parentc24f4f230fda217641cc9484c03b0a2053185228 (diff)
Check for duplicate device names in the mmdevapi backend
-rw-r--r--Alc/backends/mmdevapi.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 3a4bde5c..e688052d 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -176,14 +176,40 @@ static void get_device_formfactor(IMMDevice *device, EndpointFormFactor *formfac
static void add_device(IMMDevice *device, LPCWSTR devid, vector_DevMap *list)
{
+ int count = 0;
+ al_string tmpname;
DevMap entry;
+ AL_STRING_INIT(tmpname);
AL_STRING_INIT(entry.name);
+
entry.devid = strdupW(devid);
- get_device_name(device, &entry.name);
+ get_device_name(device, &tmpname);
+
+ while(1)
+ {
+ const DevMap *iter;
+
+ al_string_copy(&entry.name, tmpname);
+ if(count != 0)
+ {
+ char str[64];
+ snprintf(str, sizeof(str), " #%d", count+1);
+ al_string_append_cstr(&entry.name, str);
+ }
+
+#define MATCH_ENTRY(i) (al_string_cmp(entry.name, (i)->name) == 0)
+ VECTOR_FIND_IF(iter, const DevMap, *list, MATCH_ENTRY);
+ if(iter == VECTOR_ITER_END(*list))
+ break;
+#undef MATCH_ENTRY
+ count++;
+ }
TRACE("Got device \"%s\", \"%ls\"\n", al_string_get_cstr(entry.name), entry.devid);
VECTOR_PUSH_BACK(*list, entry);
+
+ AL_STRING_DEINIT(tmpname);
}
static LPWSTR get_device_id(IMMDevice *device)