diff options
author | Chris Robinson <[email protected]> | 2011-09-10 09:12:02 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-09-10 09:12:02 -0700 |
commit | f21b1eefdae35eb3e0078e8783cb043b5543491a (patch) | |
tree | 9d55f2870f8dd136f3ffa315bb985673dcb77bfd | |
parent | 6cd55a0a1064c59df6ef014b7628035d8cace7b7 (diff) |
Lock the lists while probing devices
-rw-r--r-- | Alc/ALc.c | 39 |
1 files changed, 21 insertions, 18 deletions
@@ -701,17 +701,31 @@ static void alc_initconfig(void) } +static void LockLists(void) +{ + EnterCriticalSection(&ListLock); +} + +static void UnlockLists(void) +{ + LeaveCriticalSection(&ListLock); +} + + static void ProbeList(ALCchar **list, size_t *listsize, enum DevProbe type) { + DO_INITCONFIG(); + + LockLists(); free(*list); *list = NULL; *listsize = 0; - DO_INITCONFIG(); if(type == CAPTURE_DEVICE_PROBE) CaptureBackend.Probe(type); else PlaybackBackend.Probe(type); + UnlockLists(); } static void ProbeDeviceList(void) @@ -1001,17 +1015,6 @@ static ALCboolean IsValidALCChannels(ALCenum channels) return ALC_FALSE; } - -static void LockLists(void) -{ - EnterCriticalSection(&ListLock); -} - -static void UnlockLists(void) -{ - LeaveCriticalSection(&ListLock); -} - /* IsDevice * * Check if the device pointer is valid (caller is responsible for holding the @@ -1884,11 +1887,11 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *pDevice,ALCenum para /* Default devices are always first in the list */ case ALC_DEFAULT_DEVICE_SPECIFIER: - pDevice = VerifyDevice(pDevice); - if(!alcDeviceList) ProbeDeviceList(); + pDevice = VerifyDevice(pDevice); + free(alcDefaultDeviceSpecifier); alcDefaultDeviceSpecifier = strdup(alcDeviceList ? alcDeviceList : ""); if(!alcDefaultDeviceSpecifier) @@ -1899,11 +1902,11 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *pDevice,ALCenum para break; case ALC_DEFAULT_ALL_DEVICES_SPECIFIER: - pDevice = VerifyDevice(pDevice); - if(!alcAllDeviceList) ProbeAllDeviceList(); + pDevice = VerifyDevice(pDevice); + free(alcDefaultAllDeviceSpecifier); alcDefaultAllDeviceSpecifier = strdup(alcAllDeviceList ? alcAllDeviceList : ""); @@ -1915,11 +1918,11 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *pDevice,ALCenum para break; case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER: - pDevice = VerifyDevice(pDevice); - if(!alcCaptureDeviceList) ProbeCaptureDeviceList(); + pDevice = VerifyDevice(pDevice); + free(alcCaptureDefaultDeviceSpecifier); alcCaptureDefaultDeviceSpecifier = strdup(alcCaptureDeviceList ? alcCaptureDeviceList : ""); |