aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-29 02:47:54 -0700
committerChris Robinson <[email protected]>2016-05-29 02:47:54 -0700
commit4802465f1a6365051604f38dae9c20c93c0f0a7b (patch)
tree826777dc9aac2c56bd53fa000e9387ceecc7717f
parent8aa4a74a7b213f2a8a3e0126a248357e587d34a8 (diff)
Hold the effectslot map lock while handling it
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h13
-rw-r--r--OpenAL32/alAuxEffectSlot.c24
-rw-r--r--OpenAL32/alSource.c3
3 files changed, 38 insertions, 2 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index a9b50387..8d2fc3d7 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -133,10 +133,19 @@ typedef struct ALeffectslot {
ATOMIC(struct ALeffectslot*) next;
} ALeffectslot;
+inline void LockEffectSlotsRead(ALCcontext *context)
+{ LockUIntMapRead(&context->EffectSlotMap); }
+inline void UnlockEffectSlotsRead(ALCcontext *context)
+{ UnlockUIntMapRead(&context->EffectSlotMap); }
+inline void LockEffectSlotsWrite(ALCcontext *context)
+{ LockUIntMapWrite(&context->EffectSlotMap); }
+inline void UnlockEffectSlotsWrite(ALCcontext *context)
+{ UnlockUIntMapWrite(&context->EffectSlotMap); }
+
inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id)
-{ return (struct ALeffectslot*)LookupUIntMapKey(&context->EffectSlotMap, id); }
+{ return (struct ALeffectslot*)LookupUIntMapKeyNoLock(&context->EffectSlotMap, id); }
inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id)
-{ return (struct ALeffectslot*)RemoveUIntMapKey(&context->EffectSlotMap, id); }
+{ return (struct ALeffectslot*)RemoveUIntMapKeyNoLock(&context->EffectSlotMap, id); }
ALenum InitEffectSlot(ALeffectslot *slot);
void DeinitEffectSlot(ALeffectslot *slot);
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 8da7aeb2..b0fd3385 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -35,6 +35,10 @@
#include "almalloc.h"
+extern inline void LockEffectSlotsRead(ALCcontext *context);
+extern inline void UnlockEffectSlotsRead(ALCcontext *context);
+extern inline void LockEffectSlotsWrite(ALCcontext *context);
+extern inline void UnlockEffectSlotsWrite(ALCcontext *context);
extern inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id);
extern inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id);
@@ -113,6 +117,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *
context = GetContextRef();
if(!context) return;
+ LockEffectSlotsWrite(context);
if(!(n >= 0))
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
for(i = 0;i < n;i++)
@@ -138,6 +143,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *
}
done:
+ UnlockEffectSlotsWrite(context);
ALCcontext_DecRef(context);
}
@@ -149,7 +155,9 @@ AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot)
context = GetContextRef();
if(!context) return AL_FALSE;
+ LockEffectSlotsRead(context);
ret = (LookupEffectSlot(context, effectslot) ? AL_TRUE : AL_FALSE);
+ UnlockEffectSlotsRead(context);
ALCcontext_DecRef(context);
@@ -168,6 +176,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
if(!context) return;
WriteLock(&context->PropLock);
+ LockEffectSlotsRead(context);
if((slot=LookupEffectSlot(context, effectslot)) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param)
@@ -203,6 +212,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
}
done:
+ UnlockEffectSlotsRead(context);
WriteUnlock(&context->PropLock);
ALCcontext_DecRef(context);
}
@@ -222,6 +232,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum para
context = GetContextRef();
if(!context) return;
+ LockEffectSlotsRead(context);
if(LookupEffectSlot(context, effectslot) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param)
@@ -231,6 +242,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum para
}
done:
+ UnlockEffectSlotsRead(context);
ALCcontext_DecRef(context);
}
@@ -243,6 +255,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param
if(!context) return;
WriteLock(&context->PropLock);
+ LockEffectSlotsRead(context);
if((slot=LookupEffectSlot(context, effectslot)) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param)
@@ -259,6 +272,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param
UpdateEffectSlotProps(slot);
done:
+ UnlockEffectSlotsRead(context);
WriteUnlock(&context->PropLock);
ALCcontext_DecRef(context);
}
@@ -277,6 +291,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum para
context = GetContextRef();
if(!context) return;
+ LockEffectSlotsRead(context);
if(LookupEffectSlot(context, effectslot) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param)
@@ -286,6 +301,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum para
}
done:
+ UnlockEffectSlotsRead(context);
ALCcontext_DecRef(context);
}
@@ -297,6 +313,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum pa
context = GetContextRef();
if(!context) return;
+ LockEffectSlotsRead(context);
if((slot=LookupEffectSlot(context, effectslot)) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param)
@@ -310,6 +327,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum pa
}
done:
+ UnlockEffectSlotsRead(context);
ALCcontext_DecRef(context);
}
@@ -328,6 +346,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum p
context = GetContextRef();
if(!context) return;
+ LockEffectSlotsRead(context);
if(LookupEffectSlot(context, effectslot) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param)
@@ -337,6 +356,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum p
}
done:
+ UnlockEffectSlotsRead(context);
ALCcontext_DecRef(context);
}
@@ -348,6 +368,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum pa
context = GetContextRef();
if(!context) return;
+ LockEffectSlotsRead(context);
if((slot=LookupEffectSlot(context, effectslot)) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param)
@@ -361,6 +382,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum pa
}
done:
+ UnlockEffectSlotsRead(context);
ALCcontext_DecRef(context);
}
@@ -378,6 +400,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum p
context = GetContextRef();
if(!context) return;
+ LockEffectSlotsRead(context);
if(LookupEffectSlot(context, effectslot) == NULL)
SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
switch(param)
@@ -387,6 +410,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum p
}
done:
+ UnlockEffectSlotsRead(context);
ALCcontext_DecRef(context);
}
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index a15b169f..c1824d5b 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -796,12 +796,14 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
case AL_AUXILIARY_SEND_FILTER:
+ LockEffectSlotsRead(Context);
LockFiltersRead(device);
if(!((ALuint)values[1] < device->NumAuxSends &&
(values[0] == 0 || (slot=LookupEffectSlot(Context, values[0])) != NULL) &&
(values[2] == 0 || (filter=LookupFilter(device, values[2])) != NULL)))
{
UnlockFiltersRead(device);
+ UnlockEffectSlotsRead(Context);
SET_ERROR_AND_RETURN_VALUE(Context, AL_INVALID_VALUE, AL_FALSE);
}
@@ -846,6 +848,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
Source->Send[values[1]].Slot = slot;
DO_UPDATEPROPS();
}
+ UnlockEffectSlotsRead(Context);
return AL_TRUE;