diff options
Diffstat (limited to 'Alc/dsound.c')
-rw-r--r-- | Alc/dsound.c | 38 |
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; |