From 8eaa9bb4691dbd479236771064b958bedcdab145 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 29 Aug 2011 19:44:40 -0700 Subject: Manually lock the map while iterating through its contents --- Alc/ALc.c | 7 +++++++ Alc/ALu.c | 2 ++ 2 files changed, 9 insertions(+) (limited to 'Alc') diff --git a/Alc/ALc.c b/Alc/ALc.c index 892ccc41..02200e2b 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -434,6 +434,7 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) break; case DLL_THREAD_DETACH: + ReadLock(&TlsDestructor.lock); for(i = 0;i < TlsDestructor.size;i++) { void *ptr = pthread_getspecific(TlsDestructor.array[i].key); @@ -441,6 +442,7 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) if(ptr && callback) callback(ptr); } + ReadUnlock(&TlsDestructor.lock); break; case DLL_PROCESS_DETACH: @@ -1237,12 +1239,14 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) ALsizei pos; context->UpdateSources = AL_FALSE; + ReadLock(&context->EffectSlotMap.lock); 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); UnlockDevice(device); ALCdevice_StopPlayback(device); device->Flags &= ~DEVICE_RUNNING; @@ -1251,7 +1255,9 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) slot->NeedsUpdate = AL_FALSE; ALEffect_Update(slot->EffectState, context, slot); } + ReadUnlock(&context->EffectSlotMap.lock); + ReadLock(&context->SourceMap.lock); for(pos = 0;pos < context->SourceMap.size;pos++) { ALsource *source = context->SourceMap.array[pos].value; @@ -1268,6 +1274,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) source->NeedsUpdate = AL_FALSE; ALsource_Update(source, context); } + ReadUnlock(&context->SourceMap.lock); context = context->next; } diff --git a/Alc/ALu.c b/Alc/ALu.c index b11a1c3a..7300a81e 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -1123,6 +1123,7 @@ ALvoid aluHandleDisconnect(ALCdevice *device) ALsource *source; ALsizei pos; + ReadLock(&Context->SourceMap.lock); for(pos = 0;pos < Context->SourceMap.size;pos++) { source = Context->SourceMap.array[pos].value; @@ -1134,6 +1135,7 @@ ALvoid aluHandleDisconnect(ALCdevice *device) source->position_fraction = 0; } } + ReadUnlock(&Context->SourceMap.lock); Context = Context->next; } -- cgit v1.2.3