Prevent multiple DirectSound devices from getting the same name, too

This commit is contained in:
Chris Robinson 2010-06-09 23:11:34 -07:00
parent 25a941666a
commit cff805e0a3

View File

@ -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;