From 0865db564fa86df6c02ab10ec62cfbbe98f8c917 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 18 Aug 2012 15:58:04 -0700 Subject: 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. --- OpenAL32/Include/alMain.h | 15 +++++++++------ OpenAL32/alAuxEffectSlot.c | 10 +++++----- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index d12fe3f8..8ff792d0 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -446,6 +446,9 @@ typedef struct { ALCenum (*CaptureSamples)(ALCdevice*, void*, ALCuint); ALCuint (*AvailableSamples)(ALCdevice*); + void (*Lock)(ALCdevice*); + void (*Unlock)(ALCdevice*); + ALint64 (*GetLatency)(ALCdevice*); } BackendFuncs; @@ -632,6 +635,8 @@ struct ALCdevice_struct #define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a))) #define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c))) #define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a))) +#define ALCdevice_Lock(a) ((a)->Funcs->Lock((a))) +#define ALCdevice_Unlock(a) ((a)->Funcs->Unlock((a))) #define ALCdevice_GetLatency(a) ((a)->Funcs->GetLatency((a))) // Frequency was requested by the app or config file @@ -703,15 +708,13 @@ void ALCcontext_DecRef(ALCcontext *context); void AppendAllDevicesList(const ALCchar *name); void AppendCaptureDeviceList(const ALCchar *name); -static __inline void LockDevice(ALCdevice *device) -{ EnterCriticalSection(&device->Mutex); } -static __inline void UnlockDevice(ALCdevice *device) -{ LeaveCriticalSection(&device->Mutex); } +void ALCdevice_LockDefault(ALCdevice *device); +void ALCdevice_UnlockDefault(ALCdevice *device); static __inline void LockContext(ALCcontext *context) -{ LockDevice(context->Device); } +{ ALCdevice_Lock(context->Device); } static __inline void UnlockContext(ALCcontext *context) -{ UnlockDevice(context->Device); } +{ ALCdevice_Unlock(context->Device); } void *al_malloc(size_t alignment, size_t size); diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 1823ed07..ab884cf7 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -487,7 +487,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e ALeffectState *State = NULL; ALenum err = AL_NO_ERROR; - LockDevice(Device); + ALCdevice_Lock(Device); if(newtype == AL_EFFECT_NULL && EffectSlot->effect.type != AL_EFFECT_NULL) { State = NoneCreate(); @@ -522,7 +522,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e if(err != AL_NO_ERROR) { - UnlockDevice(Device); + ALCdevice_Unlock(Device); return err; } @@ -534,7 +534,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e if(ALeffectState_DeviceUpdate(State, Device) == AL_FALSE) { RestoreFPUMode(oldMode); - UnlockDevice(Device); + ALCdevice_Unlock(Device); ALeffectState_Destroy(State); return AL_OUT_OF_MEMORY; } @@ -549,7 +549,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e * be called. */ EffectSlot->NeedsUpdate = AL_FALSE; ALeffectState_Update(EffectSlot->EffectState, Device, EffectSlot); - UnlockDevice(Device); + ALCdevice_Unlock(Device); RestoreFPUMode(oldMode); @@ -562,7 +562,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect)); else memcpy(&EffectSlot->effect, effect, sizeof(*effect)); - UnlockDevice(Device); + ALCdevice_Unlock(Device); EffectSlot->NeedsUpdate = AL_TRUE; } -- cgit v1.2.3