Move some inline functions into a header instead of copying them

Unfortunately does not include the Lookup* functions, which need the full type
declaration to offset the pointer.
This commit is contained in:
Chris Robinson
2018-01-27 21:16:24 -08:00
parent e12059a311
commit f16ece6048
5 changed files with 36 additions and 35 deletions
+13 -4
View File
@@ -723,10 +723,19 @@ inline ALint GetChannelIdxByName(const RealMixParams *real, enum Channel chan)
{ return GetChannelIndex(real->ChannelName, chan); }
inline void LockBufferList(ALCdevice *device)
{ almtx_lock(&device->BufferLock); }
inline void UnlockBufferList(ALCdevice *device)
{ almtx_unlock(&device->BufferLock); }
inline void LockBufferList(ALCdevice *device) { almtx_lock(&device->BufferLock); }
inline void UnlockBufferList(ALCdevice *device) { almtx_unlock(&device->BufferLock); }
inline void LockEffectList(ALCdevice *device) { almtx_lock(&device->EffectLock); }
inline void UnlockEffectList(ALCdevice *device) { almtx_unlock(&device->EffectLock); }
inline void LockFilterList(ALCdevice *device) { almtx_lock(&device->FilterLock); }
inline void UnlockFilterList(ALCdevice *device) { almtx_unlock(&device->FilterLock); }
inline void LockEffectSlotList(ALCcontext *context)
{ almtx_lock(&context->EffectSlotLock); }
inline void UnlockEffectSlotList(ALCcontext *context)
{ almtx_unlock(&context->EffectSlotLock); }
vector_al_string SearchDataFiles(const char *match, const char *subdir);
+6 -8
View File
@@ -36,6 +36,9 @@
#include "almalloc.h"
extern inline void LockEffectSlotList(ALCcontext *context);
extern inline void UnlockEffectSlotList(ALCcontext *context);
static UIntMap EffectStateFactoryMap;
static inline ALeffectStateFactory *getFactoryByType(ALenum type)
{
@@ -48,11 +51,6 @@ static inline ALeffectStateFactory *getFactoryByType(ALenum type)
static void ALeffectState_IncRef(ALeffectState *state);
static inline void LockEffectSlotList(ALCcontext *context)
{ almtx_lock(&context->EffectSlotLock); }
static inline void UnlockEffectSlotList(ALCcontext *context)
{ almtx_unlock(&context->EffectSlotLock); }
static inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id)
{
id--;
@@ -275,15 +273,15 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
case AL_EFFECTSLOT_EFFECT:
device = context->Device;
almtx_lock(&device->EffectLock);
LockEffectList(device);
effect = (value ? LookupEffect(device, value) : NULL);
if(!(value == 0 || effect != NULL))
{
almtx_unlock(&device->EffectLock);
UnlockEffectList(device);
SETERR_GOTO(context, AL_INVALID_VALUE, done, "Invalid effect ID %u", value);
}
err = InitializeEffect(context, slot, effect);
almtx_unlock(&device->EffectLock);
UnlockEffectList(device);
if(err != AL_NO_ERROR)
SETERR_GOTO(context, err, done, "Effect initialization failed");
+4 -7
View File
@@ -32,6 +32,10 @@
#include "alError.h"
extern inline void LockEffectList(ALCdevice *device);
extern inline void UnlockEffectList(ALCdevice *device);
extern inline ALboolean IsReverbEffect(ALenum type);
const struct EffectList EffectList[EFFECTLIST_SIZE] = {
{ "eaxreverb", EAXREVERB_EFFECT, AL_EFFECT_EAXREVERB },
{ "reverb", REVERB_EFFECT, AL_EFFECT_REVERB },
@@ -48,17 +52,10 @@ const struct EffectList EffectList[EFFECTLIST_SIZE] = {
ALboolean DisabledEffects[MAX_EFFECTS];
extern inline ALboolean IsReverbEffect(ALenum type);
static ALeffect *AllocEffect(ALCcontext *context);
static void FreeEffect(ALCdevice *device, ALeffect *effect);
static void InitEffectParams(ALeffect *effect, ALenum type);
static inline void LockEffectList(ALCdevice *device)
{ almtx_lock(&device->EffectLock); }
static inline void UnlockEffectList(ALCdevice *device)
{ almtx_unlock(&device->EffectLock); }
static inline ALeffect *LookupEffect(ALCdevice *device, ALuint id)
{
EffectSubList *sublist;
+2 -5
View File
@@ -29,6 +29,8 @@
#include "alError.h"
extern inline void LockFilterList(ALCdevice *device);
extern inline void UnlockFilterList(ALCdevice *device);
extern inline void ALfilterState_clear(ALfilterState *filter);
extern inline void ALfilterState_copyParams(ALfilterState *restrict dst, const ALfilterState *restrict src);
extern inline void ALfilterState_processPassthru(ALfilterState *filter, const ALfloat *restrict src, ALsizei numsamples);
@@ -39,11 +41,6 @@ static ALfilter *AllocFilter(ALCcontext *context);
static void FreeFilter(ALCdevice *device, ALfilter *filter);
static void InitFilterParams(ALfilter *filter, ALenum type);
static inline void LockFilterList(ALCdevice *device)
{ almtx_lock(&device->FilterLock); }
static inline void UnlockFilterList(ALCdevice *device)
{ almtx_unlock(&device->FilterLock); }
static inline ALfilter *LookupFilter(ALCdevice *device, ALuint id)
{
FilterSubList *sublist;
+11 -11
View File
@@ -908,10 +908,10 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
return AL_TRUE;
case AL_DIRECT_FILTER:
almtx_lock(&device->FilterLock);
LockFilterList(device);
if(!(*values == 0 || (filter=LookupFilter(device, *values)) != NULL))
{
almtx_unlock(&device->FilterLock);
UnlockFilterList(device);
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid filter ID %u",
*values);
}
@@ -932,7 +932,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
Source->Direct.GainLF = filter->GainLF;
Source->Direct.LFReference = filter->LFReference;
}
almtx_unlock(&device->FilterLock);
UnlockFilterList(device);
DO_UPDATEPROPS();
return AL_TRUE;
@@ -994,23 +994,23 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
case AL_AUXILIARY_SEND_FILTER:
almtx_lock(&Context->EffectSlotLock);
LockEffectSlotList(Context);
if(!(values[0] == 0 || (slot=LookupEffectSlot(Context, values[0])) != NULL))
{
almtx_unlock(&Context->EffectSlotLock);
UnlockEffectSlotList(Context);
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid effect ID %u",
values[0]);
}
if(!((ALuint)values[1] < (ALuint)device->NumAuxSends))
{
almtx_unlock(&Context->EffectSlotLock);
UnlockEffectSlotList(Context);
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid send %u", values[1]);
}
almtx_lock(&device->FilterLock);
LockFilterList(device);
if(!(values[2] == 0 || (filter=LookupFilter(device, values[2])) != NULL))
{
almtx_unlock(&device->FilterLock);
almtx_unlock(&Context->EffectSlotLock);
UnlockFilterList(device);
UnlockEffectSlotList(Context);
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid filter ID %u",
values[2]);
}
@@ -1032,7 +1032,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
Source->Send[values[1]].GainLF = filter->GainLF;
Source->Send[values[1]].LFReference = filter->LFReference;
}
almtx_unlock(&device->FilterLock);
UnlockFilterList(device);
if(slot != Source->Send[values[1]].Slot && IsPlayingOrPaused(Source))
{
@@ -1059,7 +1059,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
Source->Send[values[1]].Slot = slot;
DO_UPDATEPROPS();
}
almtx_unlock(&Context->EffectSlotLock);
UnlockEffectSlotList(Context);
return AL_TRUE;