From e4a2b69b37dcefcf2939bc020421daa467a64f43 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 29 Aug 2011 20:21:28 -0700 Subject: [PATCH] Make specific functions to lock/unlock UIntMap access --- Alc/ALc.c | 14 +++++++------- Alc/ALu.c | 4 ++-- OpenAL32/Include/alMain.h | 8 ++++++++ OpenAL32/alState.c | 8 ++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index 02200e2b..ff5f3c78 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -434,7 +434,7 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) break; case DLL_THREAD_DETACH: - ReadLock(&TlsDestructor.lock); + LockUIntMapRead(&TlsDestructor); for(i = 0;i < TlsDestructor.size;i++) { void *ptr = pthread_getspecific(TlsDestructor.array[i].key); @@ -442,7 +442,7 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) if(ptr && callback) callback(ptr); } - ReadUnlock(&TlsDestructor.lock); + UnlockUIntMapRead(&TlsDestructor); break; case DLL_PROCESS_DETACH: @@ -1239,14 +1239,14 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) ALsizei pos; context->UpdateSources = AL_FALSE; - ReadLock(&context->EffectSlotMap.lock); + LockUIntMapRead(&context->EffectSlotMap); for(pos = 0;pos < context->EffectSlotMap.size;pos++) { ALeffectslot *slot = context->EffectSlotMap.array[pos].value; if(ALEffect_DeviceUpdate(slot->EffectState, device) == AL_FALSE) { - ReadUnlock(&context->EffectSlotMap.lock); + UnlockUIntMapRead(&context->EffectSlotMap); UnlockDevice(device); ALCdevice_StopPlayback(device); device->Flags &= ~DEVICE_RUNNING; @@ -1255,9 +1255,9 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) slot->NeedsUpdate = AL_FALSE; ALEffect_Update(slot->EffectState, context, slot); } - ReadUnlock(&context->EffectSlotMap.lock); + UnlockUIntMapRead(&context->EffectSlotMap); - ReadLock(&context->SourceMap.lock); + LockUIntMapRead(&context->SourceMap); for(pos = 0;pos < context->SourceMap.size;pos++) { ALsource *source = context->SourceMap.array[pos].value; @@ -1274,7 +1274,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) source->NeedsUpdate = AL_FALSE; ALsource_Update(source, context); } - ReadUnlock(&context->SourceMap.lock); + UnlockUIntMapRead(&context->SourceMap); context = context->next; } diff --git a/Alc/ALu.c b/Alc/ALu.c index 7300a81e..8c0901a1 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -1123,7 +1123,7 @@ ALvoid aluHandleDisconnect(ALCdevice *device) ALsource *source; ALsizei pos; - ReadLock(&Context->SourceMap.lock); + LockUIntMapRead(&Context->SourceMap); for(pos = 0;pos < Context->SourceMap.size;pos++) { source = Context->SourceMap.array[pos].value; @@ -1135,7 +1135,7 @@ ALvoid aluHandleDisconnect(ALCdevice *device) source->position_fraction = 0; } } - ReadUnlock(&Context->SourceMap.lock); + UnlockUIntMapRead(&Context->SourceMap); Context = Context->next; } diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index fd645218..9a7c1cc4 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -322,6 +322,14 @@ ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); void RemoveUIntMapKey(UIntMap *map, ALuint key); ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key); +static __inline void LockUIntMapRead(UIntMap *map) +{ ReadLock(&map->lock); } +static __inline void UnlockUIntMapRead(UIntMap *map) +{ ReadUnlock(&map->lock); } +static __inline void LockUIntMapWrite(UIntMap *map) +{ WriteLock(&map->lock); } +static __inline void UnlockUIntMapWrite(UIntMap *map) +{ WriteUnlock(&map->lock); } #include "alListener.h" #include "alu.h" diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index 424a73f6..76628038 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -610,14 +610,14 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) src++; } - ReadLock(&Context->EffectSlotMap.lock); + LockUIntMapRead(&Context->EffectSlotMap); for(e = 0;e < Context->EffectSlotMap.size;e++) { ALEffectSlot = Context->EffectSlotMap.array[e].value; if(Exchange_ALenum(&ALEffectSlot->NeedsUpdate, AL_FALSE)) ALEffect_Update(ALEffectSlot->EffectState, Context, ALEffectSlot); } - ReadUnlock(&Context->EffectSlotMap.lock); + UnlockUIntMapRead(&Context->EffectSlotMap); UnlockContext(Context); } @@ -636,7 +636,7 @@ AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void) ALsizei pos; LockContext(Context); - ReadLock(&Context->SourceMap.lock); + LockUIntMapRead(&Context->SourceMap); for(pos = 0;pos < Context->SourceMap.size;pos++) { ALsource *Source = Context->SourceMap.array[pos].value; @@ -649,7 +649,7 @@ AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void) if(new_state) SetSourceState(Source, Context, new_state); } - ReadUnlock(&Context->SourceMap.lock); + UnlockUIntMapRead(&Context->SourceMap); UnlockContext(Context); } -- 2.11.4.GIT