diff options
author | Chris Robinson <[email protected]> | 2018-01-27 17:24:18 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-27 19:04:32 -0800 |
commit | 6a839600b96b73104f8b93a4fa4a1a8da67cae5c (patch) | |
tree | 5b5203ce907411f32999e2e3ee3e3cd2a39dda25 /OpenAL32/alSource.c | |
parent | 4d1795e90b83f040aa59cf69616a4ff2b32bf71a (diff) |
Use a vector to store the effect slot pointers
And make the ID a simple index into it (1-base, to avoid ID 0).
Diffstat (limited to 'OpenAL32/alSource.c')
-rw-r--r-- | OpenAL32/alSource.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 05d9a456..58026aeb 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -84,6 +84,14 @@ static inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id) return sublist->Buffers + slidx; } +static inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) +{ + id--; + if(UNLIKELY(id >= VECTOR_SIZE(context->EffectSlotList))) + return NULL; + return VECTOR_ELEM(context->EffectSlotList, id); +} + typedef enum SourceProp { srcPitch = AL_PITCH, @@ -972,23 +980,23 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p case AL_AUXILIARY_SEND_FILTER: - LockEffectSlotsRead(Context); + almtx_lock(&Context->EffectSlotLock); if(!(values[0] == 0 || (slot=LookupEffectSlot(Context, values[0])) != NULL)) { - UnlockEffectSlotsRead(Context); + almtx_unlock(&Context->EffectSlotLock); SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid effect ID %u", values[0]); } if(!((ALuint)values[1] < (ALuint)device->NumAuxSends)) { - UnlockEffectSlotsRead(Context); + almtx_unlock(&Context->EffectSlotLock); SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid send %u", values[1]); } LockFiltersRead(device); if(!(values[2] == 0 || (filter=LookupFilter(device, values[2])) != NULL)) { UnlockFiltersRead(device); - UnlockEffectSlotsRead(Context); + almtx_unlock(&Context->EffectSlotLock); SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid filter ID %u", values[2]); } @@ -1037,7 +1045,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p Source->Send[values[1]].Slot = slot; DO_UPDATEPROPS(); } - UnlockEffectSlotsRead(Context); + almtx_unlock(&Context->EffectSlotLock); return AL_TRUE; |