diff options
author | Chris Robinson <[email protected]> | 2017-06-29 10:39:27 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-06-29 10:39:27 -0700 |
commit | 058d57ef0352ee0f46fc5e0ebe76479660bfc44e (patch) | |
tree | fbae1802299c979047e4fcf2ef2ccc3790e7b1f5 /router/alc.c | |
parent | e8ce8924d179d515fe1439163b7ea73e895f408c (diff) |
Protect device enumeration in the router with a mutex
Diffstat (limited to 'router/alc.c')
-rw-r--r-- | router/alc.c | 12 |
1 files changed, 12 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); |