diff options
author | Chris Robinson <[email protected]> | 2012-02-20 22:03:08 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-02-20 22:03:08 -0800 |
commit | 14912229b1e433842077ac0fd483f0bebb9aafbd (patch) | |
tree | 8234f7148d6e128df17ad02973b81480977d0e73 | |
parent | 2b64df05e63eb21dc2ecfa3aa32fd54e5413a13e (diff) |
Avoid default names for winmm and dsound
-rw-r--r-- | Alc/backends/dsound.c | 24 | ||||
-rw-r--r-- | Alc/backends/winmm.c | 56 |
2 files changed, 29 insertions, 51 deletions
diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index e2375137..851dd9e2 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -86,7 +86,6 @@ typedef struct { GUID guid; } DevMap; -static const ALCchar dsDevice[] = "DirectSound Default"; static DevMap *PlaybackDeviceList; static ALuint NumPlaybackDevices; static DevMap *CaptureDeviceList; @@ -312,18 +311,21 @@ static ALCenum DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName) LPGUID guid = NULL; HRESULT hr; - if(!deviceName) - deviceName = dsDevice; - else if(strcmp(deviceName, dsDevice) != 0) + if(!PlaybackDeviceList) { - ALuint i; + hr = DirectSoundEnumerateA(DSoundEnumPlaybackDevices, NULL); + if(FAILED(hr)) + ERR("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr); + } - if(!PlaybackDeviceList) - { - hr = DirectSoundEnumerateA(DSoundEnumPlaybackDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr); - } + if(!deviceName && NumPlaybackDevices > 0) + { + deviceName = PlaybackDeviceList[0].name; + guid = &PlaybackDeviceList[0].guid; + } + else + { + ALuint i; for(i = 0;i < NumPlaybackDevices;i++) { diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index 994c073c..9f2c6316 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -56,8 +56,6 @@ typedef struct { } WinMMData; -static const ALCchar woDefault[] = "WaveOut Default"; - static ALCchar **PlaybackDeviceList; static ALuint NumPlaybackDevices; static ALCchar **CaptureDeviceList; @@ -286,26 +284,21 @@ static ALCenum WinMMOpenPlayback(ALCdevice *pDevice, const ALCchar *deviceName) MMRESULT res; ALuint i = 0; + if(!PlaybackDeviceList) + ProbePlaybackDevices(); + // Find the Device ID matching the deviceName if valid - if(!deviceName || strcmp(deviceName, woDefault) == 0) - lDeviceID = WAVE_MAPPER; - else + for(i = 0;i < NumPlaybackDevices;i++) { - if(!PlaybackDeviceList) - ProbePlaybackDevices(); - - for(i = 0;i < NumPlaybackDevices;i++) + if(PlaybackDeviceList[i] && + (!deviceName || strcmp(deviceName, PlaybackDeviceList[i]) == 0)) { - if(PlaybackDeviceList[i] && - strcmp(deviceName, PlaybackDeviceList[i]) == 0) - { - lDeviceID = i; - break; - } + lDeviceID = i; + break; } - if(i == NumPlaybackDevices) - return ALC_INVALID_VALUE; } + if(i == NumPlaybackDevices) + return ALC_INVALID_VALUE; pData = calloc(1, sizeof(*pData)); if(!pData) @@ -371,8 +364,7 @@ retry_open: pData->Frequency = pDevice->Frequency; - pDevice->szDeviceName = strdup((lDeviceID==WAVE_MAPPER) ? woDefault : - PlaybackDeviceList[lDeviceID]); + pDevice->szDeviceName = strdup(PlaybackDeviceList[lDeviceID]); return ALC_NO_ERROR; failure: @@ -487,27 +479,13 @@ static ALCenum WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName) ProbeCaptureDevices(); // Find the Device ID matching the deviceName if valid - if(deviceName) - { - for(i = 0;i < NumCaptureDevices;i++) - { - if(CaptureDeviceList[i] && - strcmp(deviceName, CaptureDeviceList[i]) == 0) - { - lDeviceID = i; - break; - } - } - } - else + for(i = 0;i < NumCaptureDevices;i++) { - for(i = 0;i < NumCaptureDevices;i++) + if(CaptureDeviceList[i] && + (!deviceName || strcmp(deviceName, CaptureDeviceList[i]) == 0)) { - if(CaptureDeviceList[i]) - { - lDeviceID = i; - break; - } + lDeviceID = i; + break; } } if(i == NumCaptureDevices) @@ -754,8 +732,6 @@ void alcWinMMProbe(enum DevProbe type) { case ALL_DEVICE_PROBE: ProbePlaybackDevices(); - if(NumPlaybackDevices > 0) - AppendAllDeviceList(woDefault); for(i = 0;i < NumPlaybackDevices;i++) { if(PlaybackDeviceList[i]) |