aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-10 09:12:02 -0700
committerChris Robinson <[email protected]>2011-09-10 09:12:02 -0700
commitf21b1eefdae35eb3e0078e8783cb043b5543491a (patch)
tree9d55f2870f8dd136f3ffa315bb985673dcb77bfd /Alc
parent6cd55a0a1064c59df6ef014b7628035d8cace7b7 (diff)
Lock the lists while probing devices
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 03082f1f..0d8d39ea 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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 : "");