aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--router/alc.c12
-rw-r--r--router/router.c4
-rw-r--r--router/router.h3
3 files changed, 19 insertions, 0 deletions
diff --git a/router/alc.c b/router/alc.c
index 17ba7013..0fb9cf4e 100644
--- a/router/alc.c
+++ b/router/alc.c
@@ -345,6 +345,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
devicename = NULL;
if(devicename)
{
+ almtx_lock(&EnumerationLock);
if(!DevicesList.Names)
(void)alcGetString(NULL, ALC_DEVICE_SPECIFIER);
idx = GetDriverIndexForName(&DevicesList, devicename);
@@ -356,9 +357,11 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
if(idx < 0)
{
ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_VALUE);
+ almtx_unlock(&EnumerationLock);
return NULL;
}
}
+ almtx_unlock(&EnumerationLock);
}
device = DriverList[idx].alcOpenDevice(devicename);
@@ -624,6 +627,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
return alcExtensionList;
case ALC_DEVICE_SPECIFIER:
+ almtx_lock(&EnumerationLock);
ClearDeviceList(&DevicesList);
for(i = 0;i < DriverListSize;i++)
{
@@ -634,9 +638,11 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
DriverList[i].alcGetString(NULL, ALC_DEVICE_SPECIFIER), i
);
}
+ almtx_unlock(&EnumerationLock);
return DevicesList.Names;
case ALC_ALL_DEVICES_SPECIFIER:
+ almtx_lock(&EnumerationLock);
ClearDeviceList(&AllDevicesList);
for(i = 0;i < DriverListSize;i++)
{
@@ -653,9 +659,11 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
DriverList[i].alcGetString(NULL, ALC_DEVICE_SPECIFIER), i
);
}
+ almtx_unlock(&EnumerationLock);
return AllDevicesList.Names;
case ALC_CAPTURE_DEVICE_SPECIFIER:
+ almtx_lock(&EnumerationLock);
ClearDeviceList(&CaptureDevicesList);
for(i = 0;i < DriverListSize;i++)
{
@@ -665,6 +673,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para
DriverList[i].alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER), i
);
}
+ almtx_unlock(&EnumerationLock);
return CaptureDevicesList.Names;
case ALC_DEFAULT_DEVICE_SPECIFIER:
@@ -745,14 +754,17 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename,
devicename = NULL;
if(devicename)
{
+ almtx_lock(&EnumerationLock);
if(!CaptureDevicesList.Names)
(void)alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
idx = GetDriverIndexForName(&CaptureDevicesList, devicename);
if(idx < 0)
{
ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_VALUE);
+ almtx_unlock(&EnumerationLock);
return NULL;
}
+ almtx_unlock(&EnumerationLock);
}
device = DriverList[idx].alcCaptureOpenDevice(devicename, frequency, format, buffersize);
diff --git a/router/router.c b/router/router.c
index 86189b78..4dfae314 100644
--- a/router/router.c
+++ b/router/router.c
@@ -15,6 +15,8 @@ DriverIface *DriverList = NULL;
int DriverListSize = 0;
static int DriverListSizeMax = 0;
+almtx_t EnumerationLock;
+
static void LoadDriverList(void);
@@ -26,6 +28,7 @@ BOOL APIENTRY DllMain(HINSTANCE UNUSED(module), DWORD reason, void* UNUSED(reser
{
case DLL_PROCESS_ATTACH:
LoadDriverList();
+ almtx_init(&EnumerationLock, almtx_recursive);
break;
case DLL_THREAD_ATTACH:
@@ -34,6 +37,7 @@ BOOL APIENTRY DllMain(HINSTANCE UNUSED(module), DWORD reason, void* UNUSED(reser
case DLL_PROCESS_DETACH:
ReleaseALC();
+ almtx_destroy(&EnumerationLock);
for(i = 0;i < DriverListSize;i++)
{
if(DriverList[i].Module)
diff --git a/router/router.h b/router/router.h
index 30401f88..78f7b6c0 100644
--- a/router/router.h
+++ b/router/router.h
@@ -9,6 +9,7 @@
#include "AL/al.h"
#include "atomic.h"
#include "rwlock.h"
+#include "threads.h"
#ifndef UNUSED
@@ -150,6 +151,8 @@ ALint RemovePtrIntMapKey(PtrIntMap *map, ALvoid *key);
ALint LookupPtrIntMapKey(PtrIntMap *map, ALvoid *key);
+extern almtx_t EnumerationLock;
+
void ReleaseALC(void);
#endif /* ROUTER_ROUTER_H */