diff options
author | Chris Robinson <[email protected]> | 2009-08-27 20:13:35 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-08-27 20:13:35 -0700 |
commit | 1816c8bd37a9ff95827d95338963a9a14603543e (patch) | |
tree | 9ba1506739afcf8a16ebac1792b9089fe5a4fd44 /Alc/ALc.c | |
parent | c27948a7ee9613e174015daeac1c927a38a09ed9 (diff) |
Make a copy of the default device name for the app
The pointer to it could otherwise change if the device list is rebuilt, which
would be bad if the app has it
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 45 |
1 files changed, 26 insertions, 19 deletions
@@ -268,8 +268,6 @@ static void ProbeDeviceList() for(i = 0;BackendList[i].Probe;i++) BackendList[i].Probe(DEVICE_PROBE); - - alcDefaultDeviceSpecifier = alcDeviceList; } static void ProbeAllDeviceList() @@ -281,8 +279,6 @@ static void ProbeAllDeviceList() for(i = 0;BackendList[i].Probe;i++) BackendList[i].Probe(ALL_DEVICE_PROBE); - - alcDefaultAllDeviceSpecifier = alcAllDeviceList; } static void ProbeCaptureDeviceList() @@ -294,8 +290,6 @@ static void ProbeCaptureDeviceList() for(i = 0;BackendList[i].Probe;i++) BackendList[i].Probe(CAPTURE_DEVICE_PROBE); - - alcCaptureDefaultDeviceSpecifier = alcCaptureDeviceList; } static void InitAL(void) @@ -360,11 +354,6 @@ static void InitAL(void) BackendList[i].Probe(CAPTURE_DEVICE_PROBE); } - /* Default is always the first in the list */ - alcDefaultDeviceSpecifier = alcDeviceList; - alcDefaultAllDeviceSpecifier = alcAllDeviceList; - alcCaptureDefaultDeviceSpecifier = alcCaptureDeviceList; - str = GetConfigValue(NULL, "stereodup", "false"); DuplicateStereo = (strcasecmp(str, "true") == 0 || strcasecmp(str, "yes") == 0 || @@ -803,10 +792,6 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param) value = alcErrOutOfMemory; break; - case ALC_DEFAULT_DEVICE_SPECIFIER: - value = alcDefaultDeviceSpecifier; - break; - case ALC_DEVICE_SPECIFIER: if(IsDevice(pDevice)) value = pDevice->szDeviceName; @@ -822,10 +807,6 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param) value = alcAllDeviceList; break; - case ALC_DEFAULT_ALL_DEVICES_SPECIFIER: - value = alcDefaultAllDeviceSpecifier; - break; - case ALC_CAPTURE_DEVICE_SPECIFIER: if(IsDevice(pDevice)) value = pDevice->szDeviceName; @@ -836,7 +817,30 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param) } break; + /* Default devices are always first in the list */ + case ALC_DEFAULT_DEVICE_SPECIFIER: + free(alcDefaultDeviceSpecifier); + alcDefaultDeviceSpecifier = strdup(alcDeviceList ? alcDeviceList : ""); + if(!alcDefaultDeviceSpecifier) + SetALCError(ALC_OUT_OF_MEMORY); + value = alcDefaultDeviceSpecifier; + break; + + case ALC_DEFAULT_ALL_DEVICES_SPECIFIER: + free(alcDefaultAllDeviceSpecifier); + alcDefaultAllDeviceSpecifier = strdup(alcAllDeviceList ? + alcAllDeviceList : ""); + if(!alcDefaultAllDeviceSpecifier) + SetALCError(ALC_OUT_OF_MEMORY); + value = alcDefaultAllDeviceSpecifier; + break; + case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER: + free(alcCaptureDefaultDeviceSpecifier); + alcCaptureDefaultDeviceSpecifier = strdup(alcCaptureDeviceList ? + alcCaptureDeviceList : ""); + if(!alcCaptureDefaultDeviceSpecifier) + SetALCError(ALC_OUT_OF_MEMORY); value = alcCaptureDefaultDeviceSpecifier; break; @@ -1584,8 +1588,11 @@ ALCvoid ReleaseALC(ALCvoid) free(alcCaptureDeviceList); alcCaptureDeviceList = NULL; alcCaptureDeviceListSize = 0; + free(alcDefaultDeviceSpecifier); alcDefaultDeviceSpecifier = NULL; + free(alcDefaultAllDeviceSpecifier); alcDefaultAllDeviceSpecifier = NULL; + free(alcCaptureDefaultDeviceSpecifier); alcCaptureDefaultDeviceSpecifier = NULL; #ifdef _DEBUG |