aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-29 19:44:40 -0700
committerChris Robinson <[email protected]>2011-08-29 20:05:50 -0700
commit8eaa9bb4691dbd479236771064b958bedcdab145 (patch)
tree514f8630df3deab4e23301eb7dea46b11e4858ba /Alc
parentb283dd3682e5c56483e69c4b65e889563e95d8c0 (diff)
Manually lock the map while iterating through its contents
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c7
-rw-r--r--Alc/ALu.c2
2 files changed, 9 insertions, 0 deletions
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;
}