aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-06-09 23:11:34 -0700
committerChris Robinson <[email protected]>2010-06-09 23:11:34 -0700
commitcff805e0a37d6b1866f00863ea968ad2d5ad6d45 (patch)
tree2113b5bb221b62e1543e6838612a473e073f6a06 /Alc
parent25a941666ad8691dfc0f389baf642fa2690ba334 (diff)
Prevent multiple DirectSound devices from getting the same name, too
Diffstat (limited to 'Alc')
-rw-r--r--Alc/dsound.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/Alc/dsound.c b/Alc/dsound.c
index e4f11f75..7fe6825c 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -110,25 +110,39 @@ LOAD_FUNC(DirectSoundEnumerateA);
static BOOL CALLBACK DSoundEnumDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data)
{
+ char str[1024];
+ void *temp;
+ int count;
+ ALuint i;
+
(void)data;
(void)drvname;
- if(guid)
- {
- char str[1024];
- void *temp;
-
- temp = realloc(DeviceList, sizeof(DevMap) * (NumDevices+1));
- if(temp)
- {
- DeviceList = temp;
+ if(!guid)
+ return TRUE;
+ count = 0;
+ do {
+ if(count == 0)
snprintf(str, sizeof(str), "%s via DirectSound", desc);
+ else
+ snprintf(str, sizeof(str), "%s #%d via DirectSound", desc, count+1);
+ count++;
- DeviceList[NumDevices].name = strdup(str);
- DeviceList[NumDevices].guid = *guid;
- NumDevices++;
+ for(i = 0;i < NumDevices;i++)
+ {
+ if(strcmp(str, DeviceList[i].name) == 0)
+ break;
}
+ } while(i != NumDevices);
+
+ temp = realloc(DeviceList, sizeof(DevMap) * (NumDevices+1));
+ if(temp)
+ {
+ DeviceList = temp;
+ DeviceList[NumDevices].name = strdup(str);
+ DeviceList[NumDevices].guid = *guid;
+ NumDevices++;
}
return TRUE;