summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-07-13 01:21:30 -0700
committerChris Robinson <[email protected]>2011-07-13 01:21:30 -0700
commit2bb3d31d5c266c572863824e7c2aea8a240cfcba (patch)
treeeadb7cda6edbc8a0aef0bc38c4f82685c44c8275 /Alc
parent2a7bf1234bac0ed3f27df9d004be47b7c8a190cb (diff)
Avoid holding the global list lock while calling some capture methods
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 7aebea52..099dd1bc 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1670,7 +1670,9 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
UnlockLists();
+ LockDevice(pDevice);
ALCdevice_CloseCapture(pDevice);
+ UnlockDevice(pDevice);
free(pDevice->szDeviceName);
pDevice->szDeviceName = NULL;
@@ -1686,30 +1688,48 @@ ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device)
{
LockLists();
if(!IsDevice(device) || !device->IsCaptureDevice)
+ {
alcSetError(device, ALC_INVALID_DEVICE);
- else if(device->Connected)
- ALCdevice_StartCapture(device);
+ UnlockLists();
+ return;
+ }
+ LockDevice(device);
UnlockLists();
+ if(device->Connected)
+ ALCdevice_StartCapture(device);
+ UnlockDevice(device);
}
ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device)
{
LockLists();
if(!IsDevice(device) || !device->IsCaptureDevice)
+ {
alcSetError(device, ALC_INVALID_DEVICE);
- else
- ALCdevice_StopCapture(device);
+ UnlockLists();
+ return;
+ }
+ LockDevice(device);
UnlockLists();
+ if(device->Connected)
+ ALCdevice_StopCapture(device);
+ UnlockDevice(device);
}
ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
{
LockLists();
if(!IsDevice(device) || !device->IsCaptureDevice)
+ {
alcSetError(device, ALC_INVALID_DEVICE);
- else
- ALCdevice_CaptureSamples(device, buffer, samples);
+ UnlockLists();
+ return;
+ }
+ LockDevice(device);
UnlockLists();
+ if(device->Connected)
+ ALCdevice_CaptureSamples(device, buffer, samples);
+ UnlockDevice(device);
}
/*
@@ -1931,7 +1951,9 @@ ALC_API ALCvoid ALC_APIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsi
switch(param)
{
case ALC_CAPTURE_SAMPLES:
+ LockDevice(device);
*data = ALCdevice_AvailableSamples(device);
+ UnlockDevice(device);
break;
case ALC_CONNECTED: