From cff805e0a37d6b1866f00863ea968ad2d5ad6d45 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 9 Jun 2010 23:11:34 -0700 Subject: Prevent multiple DirectSound devices from getting the same name, too --- Alc/dsound.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'Alc') 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; -- cgit v1.2.3