aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alAuxEffectSlot.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-27 19:01:25 -0800
committerChris Robinson <[email protected]>2018-01-27 19:04:32 -0800
commite8c268ef09d53461386fa7e81bd853cd1007d6c2 (patch)
tree9c17f4bac398ca3de8c74661bf28a9b5fc046933 /OpenAL32/alAuxEffectSlot.c
parent6a839600b96b73104f8b93a4fa4a1a8da67cae5c (diff)
Store effects in an array of lists
Diffstat (limited to 'OpenAL32/alAuxEffectSlot.c')
-rw-r--r--OpenAL32/alAuxEffectSlot.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 3fbf4b6e..30ca097f 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -61,6 +61,20 @@ static inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id)
return VECTOR_ELEM(context->EffectSlotList, id);
}
+static inline ALeffect *LookupEffect(ALCdevice *device, ALuint id)
+{
+ EffectSubList *sublist;
+ ALuint lidx = (id-1) >> 6;
+ ALsizei slidx = (id-1) & 0x3f;
+
+ if(UNLIKELY(lidx >= VECTOR_SIZE(device->EffectList)))
+ return NULL;
+ sublist = &VECTOR_ELEM(device->EffectList, lidx);
+ if(UNLIKELY(sublist->FreeMask & (U64(1)<<slidx)))
+ return NULL;
+ return sublist->Effects + slidx;
+}
+
#define DO_UPDATEPROPS() do { \
if(!ATOMIC_LOAD(&context->DeferUpdates, almemory_order_acquire)) \
@@ -261,15 +275,15 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
case AL_EFFECTSLOT_EFFECT:
device = context->Device;
- LockEffectsRead(device);
+ almtx_lock(&device->EffectLock);
effect = (value ? LookupEffect(device, value) : NULL);
if(!(value == 0 || effect != NULL))
{
- UnlockEffectsRead(device);
+ almtx_unlock(&device->EffectLock);
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Invalid effect ID %u", value);
}
err = InitializeEffect(context, slot, effect);
- UnlockEffectsRead(device);
+ almtx_unlock(&device->EffectLock);
if(err != AL_NO_ERROR)
SETERR_GOTO(context, err, done, "Effect initialization failed");