aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-08-18 15:58:04 -0700
committerChris Robinson <[email protected]>2012-08-18 15:58:04 -0700
commit0865db564fa86df6c02ab10ec62cfbbe98f8c917 (patch)
treec3ea9c6c1dc274776fd29c409e2231fa949e9742 /Alc/ALc.c
parent2b020040b41a8a8a19869263ad2816daad2e1361 (diff)
Move the device lock into the backend function table
For backend-specific implementations: this should hold the audio mixer loop for playback devices, and provide recursive mutex behavior.
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index f72122f3..9b04de13 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -43,7 +43,7 @@
/************************************************
* Backends
************************************************/
-#define EmptyFuncs { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
+#define EmptyFuncs { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
static struct BackendInfo BackendList[] = {
#ifdef HAVE_PULSEAUDIO
{ "pulse", alc_pulse_init, alc_pulse_deinit, alc_pulse_probe, EmptyFuncs },
@@ -1259,6 +1259,15 @@ static ALCboolean IsValidALCChannels(ALCenum channels)
* Miscellaneous ALC helpers
************************************************/
+void ALCdevice_LockDefault(ALCdevice *device)
+{
+ EnterCriticalSection(&device->Mutex);
+}
+void ALCdevice_UnlockDefault(ALCdevice *device)
+{
+ LeaveCriticalSection(&device->Mutex);
+}
+
/* SetDefaultWFXChannelOrder
*
* Sets the default channel order used by WaveFormatEx.
@@ -1609,7 +1618,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->Flags |= DEVICE_WIDE_STEREO;
oldMode = SetMixerFPUMode();
- LockDevice(device);
+ ALCdevice_Lock(device);
context = device->ContextList;
while(context)
{
@@ -1624,7 +1633,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if(ALeffectState_DeviceUpdate(slot->EffectState, device) == AL_FALSE)
{
UnlockUIntMapRead(&context->EffectSlotMap);
- UnlockDevice(device);
+ ALCdevice_Unlock(device);
RestoreFPUMode(oldMode);
return ALC_INVALID_DEVICE;
}
@@ -1660,14 +1669,14 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if(ALeffectState_DeviceUpdate(slot->EffectState, device) == AL_FALSE)
{
- UnlockDevice(device);
+ ALCdevice_Unlock(device);
RestoreFPUMode(oldMode);
return ALC_INVALID_DEVICE;
}
slot->NeedsUpdate = AL_FALSE;
ALeffectState_Update(slot->EffectState, device, slot);
}
- UnlockDevice(device);
+ ALCdevice_Unlock(device);
RestoreFPUMode(oldMode);
if(ALCdevice_StartPlayback(device) == ALC_FALSE)
@@ -1876,7 +1885,7 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device)
if(CompExchangePtr((XchgPtr*)&GlobalContext, context, NULL))
ALCcontext_DecRef(context);
- LockDevice(device);
+ ALCdevice_Lock(device);
tmp_ctx = &device->ContextList;
while(*tmp_ctx)
{
@@ -1884,7 +1893,7 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device)
break;
tmp_ctx = &(*tmp_ctx)->next;
}
- UnlockDevice(device);
+ ALCdevice_Unlock(device);
ALCcontext_DecRef(context);
}