aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-07-03 22:14:15 -0700
committerChris Robinson <[email protected]>2017-07-03 22:14:15 -0700
commit72ce0d1e9cb5474361fb7d2b2d87172bc89ffdc5 (patch)
tree48f9c5468b244db3c69b4291f4195d70df192eb0
parent3cd4cfe73d48afc31ac8a376ff12eb9476dd3c09 (diff)
Open a device only when a driver index is found
-rw-r--r--router/alc.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/router/alc.c b/router/alc.c
index a8b9c2b2..fd9ae81b 100644
--- a/router/alc.c
+++ b/router/alc.c
@@ -345,8 +345,8 @@ void ReleaseALC(void)
ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
{
- ALCdevice *device;
- ALint idx = 0;
+ ALCdevice *device = NULL;
+ ALint idx;
/* Prior to the enumeration extension, apps would hardcode these names as a
* quality hint for the wrapper driver. Ignore them since there's no sane
@@ -368,14 +368,14 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
if(!AllDevicesList.Names)
(void)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
idx = GetDriverIndexForName(&AllDevicesList, devicename);
- if(idx < 0)
- {
- ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_VALUE);
- almtx_unlock(&EnumerationLock);
- return NULL;
- }
}
almtx_unlock(&EnumerationLock);
+ if(idx < 0)
+ {
+ ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_VALUE);
+ return NULL;
+ }
+ device = DriverList[idx].alcOpenDevice(devicename);
}
else
{
@@ -386,12 +386,12 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
DriverList[i].alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
{
idx = i;
+ device = DriverList[idx].alcOpenDevice(NULL);
break;
}
}
}
- device = DriverList[idx].alcOpenDevice(devicename);
if(device)
{
if(InsertPtrIntMapEntry(&DeviceIfaceMap, device, idx) != ALC_NO_ERROR)
@@ -799,8 +799,8 @@ ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsi
ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize)
{
- ALCdevice *device;
- ALint idx = 0;
+ ALCdevice *device = NULL;
+ ALint idx;
if(devicename && devicename[0] == '\0')
devicename = NULL;
@@ -810,13 +810,15 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename,
if(!CaptureDevicesList.Names)
(void)alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
idx = GetDriverIndexForName(&CaptureDevicesList, devicename);
+ almtx_unlock(&EnumerationLock);
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
+ );
}
else
{
@@ -827,12 +829,14 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename,
DriverList[i].alcIsExtensionPresent(NULL, "ALC_EXT_CAPTURE"))
{
idx = i;
+ device = DriverList[idx].alcCaptureOpenDevice(
+ NULL, frequency, format, buffersize
+ );
break;
}
}
}
- device = DriverList[idx].alcCaptureOpenDevice(devicename, frequency, format, buffersize);
if(device)
{
if(InsertPtrIntMapEntry(&DeviceIfaceMap, device, idx) != ALC_NO_ERROR)