Use C99 inline in more places

This commit is contained in:
Chris Robinson
2013-11-04 13:44:46 -08:00
parent 551f893ae9
commit d3c70e63b4
11 changed files with 79 additions and 35 deletions
+4
View File
@@ -1274,6 +1274,7 @@ const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans)
return "(unknown channels)";
}
extern inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans, enum DevFmtType type);
ALuint BytesFromDevFmt(enum DevFmtType type)
{
switch(type)
@@ -1415,6 +1416,9 @@ void ALCdevice_Unlock(ALCdevice *device)
V0(device->Backend,unlock)();
}
extern inline void LockContext(ALCcontext *context);
extern inline void UnlockContext(ALCcontext *context);
/* SetDefaultWFXChannelOrder
*
+22
View File
@@ -48,6 +48,28 @@ ALfloat ConeScale = 1.0f;
/* Localized Z scalar for mono sources */
ALfloat ZScale = 1.0f;
extern inline ALfloat minf(ALfloat a, ALfloat b);
extern inline ALfloat maxf(ALfloat a, ALfloat b);
extern inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max);
extern inline ALuint minu(ALuint a, ALuint b);
extern inline ALuint maxu(ALuint a, ALuint b);
extern inline ALuint clampu(ALuint val, ALuint min, ALuint max);
extern inline ALint mini(ALint a, ALint b);
extern inline ALint maxi(ALint a, ALint b);
extern inline ALint clampi(ALint val, ALint min, ALint max);
extern inline ALint64 mini64(ALint64 a, ALint64 b);
extern inline ALint64 maxi64(ALint64 a, ALint64 b);
extern inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max);
extern inline ALuint64 minu64(ALuint64 a, ALuint64 b);
extern inline ALuint64 maxu64(ALuint64 a, ALuint64 b);
extern inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max);
extern inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu);
extern inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu);
static ResamplerFunc SelectResampler(enum Resampler Resampler, ALuint increment)
{
+4
View File
@@ -86,6 +86,10 @@ extern inline void UnlockUIntMapRead(UIntMap *map);
extern inline void LockUIntMapWrite(UIntMap *map);
extern inline void UnlockUIntMapWrite(UIntMap *map);
extern inline ALuint NextPowerOf2(ALuint value);
extern inline ALint fastf2i(ALfloat f);
extern inline ALuint fastf2u(ALfloat f);
ALuint CPUCapFlags = 0;
+2
View File
@@ -31,6 +31,8 @@
#include "AL/alc.h"
#include "alu.h"
extern inline void SetGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels]);
static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MaxChannels],
enum Channel Speaker2Chan[MaxChannels], ALint chans)
{
+17 -17
View File
@@ -145,8 +145,8 @@ struct Hrtf;
#define MIN_OUTPUT_RATE (8000)
// Find the next power-of-2 for non-power-of-2 numbers.
static inline ALuint NextPowerOf2(ALuint value)
/* Find the next power-of-2 for non-power-of-2 numbers. */
inline ALuint NextPowerOf2(ALuint value)
{
if(value > 0)
{
@@ -162,7 +162,7 @@ static inline ALuint NextPowerOf2(ALuint value)
/* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
* mode. */
static inline ALint fastf2i(ALfloat f)
inline ALint fastf2i(ALfloat f)
{
#ifdef HAVE_LRINTF
return lrintf(f);
@@ -178,7 +178,7 @@ static inline ALint fastf2i(ALfloat f)
/* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
* mode. */
static inline ALuint fastf2u(ALfloat f)
inline ALuint fastf2u(ALfloat f)
{ return fastf2i(f); }
@@ -304,7 +304,7 @@ enum DevFmtChannels {
ALuint BytesFromDevFmt(enum DevFmtType type);
ALuint ChannelsFromDevFmt(enum DevFmtChannels chans);
static inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans, enum DevFmtType type)
inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans, enum DevFmtType type)
{
return ChannelsFromDevFmt(chans) * BytesFromDevFmt(type);
}
@@ -432,18 +432,18 @@ struct ALCdevice_struct
#define MIXER_THREAD_NAME "alsoft-mixer"
static inline struct ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
inline struct ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
{ return (struct ALbuffer*)LookupUIntMapKey(&device->BufferMap, id); }
static inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id)
inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id)
{ return (struct ALeffect*)LookupUIntMapKey(&device->EffectMap, id); }
static inline struct ALfilter *LookupFilter(ALCdevice *device, ALuint id)
inline struct ALfilter *LookupFilter(ALCdevice *device, ALuint id)
{ return (struct ALfilter*)LookupUIntMapKey(&device->FilterMap, id); }
static inline struct ALbuffer *RemoveBuffer(ALCdevice *device, ALuint id)
inline struct ALbuffer *RemoveBuffer(ALCdevice *device, ALuint id)
{ return (struct ALbuffer*)RemoveUIntMapKey(&device->BufferMap, id); }
static inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id)
inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id)
{ return (struct ALeffect*)RemoveUIntMapKey(&device->EffectMap, id); }
static inline struct ALfilter *RemoveFilter(ALCdevice *device, ALuint id)
inline struct ALfilter *RemoveFilter(ALCdevice *device, ALuint id)
{ return (struct ALfilter*)RemoveUIntMapKey(&device->FilterMap, id); }
@@ -482,14 +482,14 @@ struct ALCcontext_struct
ALCcontext *volatile next;
};
static inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
inline struct ALsource *LookupSource(ALCcontext *context, ALuint id)
{ return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); }
static inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id)
inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id)
{ return (struct ALeffectslot*)LookupUIntMapKey(&context->EffectSlotMap, id); }
static inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id)
{ return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); }
static inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id)
inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id)
{ return (struct ALeffectslot*)RemoveUIntMapKey(&context->EffectSlotMap, id); }
@@ -509,10 +509,10 @@ void ALCdevice_Lock(ALCdevice *device);
void ALCdevice_Unlock(ALCdevice *device);
ALint64 ALCdevice_GetLatency(ALCdevice *device);
static inline void LockContext(ALCcontext *context)
inline void LockContext(ALCcontext *context)
{ ALCdevice_Lock(context->Device); }
static inline void UnlockContext(ALCcontext *context)
inline void UnlockContext(ALCcontext *context)
{ ALCdevice_Unlock(context->Device); }
+18 -18
View File
@@ -57,47 +57,47 @@ typedef ALvoid (*WetMixerFunc)(const struct SendParams *params,
#define FRACTIONMASK (FRACTIONONE-1)
static inline ALfloat minf(ALfloat a, ALfloat b)
inline ALfloat minf(ALfloat a, ALfloat b)
{ return ((a > b) ? b : a); }
static inline ALfloat maxf(ALfloat a, ALfloat b)
inline ALfloat maxf(ALfloat a, ALfloat b)
{ return ((a > b) ? a : b); }
static inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max)
inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max)
{ return minf(max, maxf(min, val)); }
static inline ALuint minu(ALuint a, ALuint b)
inline ALuint minu(ALuint a, ALuint b)
{ return ((a > b) ? b : a); }
static inline ALuint maxu(ALuint a, ALuint b)
inline ALuint maxu(ALuint a, ALuint b)
{ return ((a > b) ? a : b); }
static inline ALuint clampu(ALuint val, ALuint min, ALuint max)
inline ALuint clampu(ALuint val, ALuint min, ALuint max)
{ return minu(max, maxu(min, val)); }
static inline ALint mini(ALint a, ALint b)
inline ALint mini(ALint a, ALint b)
{ return ((a > b) ? b : a); }
static inline ALint maxi(ALint a, ALint b)
inline ALint maxi(ALint a, ALint b)
{ return ((a > b) ? a : b); }
static inline ALint clampi(ALint val, ALint min, ALint max)
inline ALint clampi(ALint val, ALint min, ALint max)
{ return mini(max, maxi(min, val)); }
static inline ALint64 mini64(ALint64 a, ALint64 b)
inline ALint64 mini64(ALint64 a, ALint64 b)
{ return ((a > b) ? b : a); }
static inline ALint64 maxi64(ALint64 a, ALint64 b)
inline ALint64 maxi64(ALint64 a, ALint64 b)
{ return ((a > b) ? a : b); }
static inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max)
inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max)
{ return mini64(max, maxi64(min, val)); }
static inline ALuint64 minu64(ALuint64 a, ALuint64 b)
inline ALuint64 minu64(ALuint64 a, ALuint64 b)
{ return ((a > b) ? b : a); }
static inline ALuint64 maxu64(ALuint64 a, ALuint64 b)
inline ALuint64 maxu64(ALuint64 a, ALuint64 b)
{ return ((a > b) ? a : b); }
static inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max)
inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max)
{ return minu64(max, maxu64(min, val)); }
static inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu)
inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu)
{
return val1 + (val2-val1)*mu;
}
static inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu)
inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu)
{
ALfloat mu2 = mu*mu;
ALfloat a0 = -0.5f*val0 + 1.5f*val1 + -1.5f*val2 + 0.5f*val3;
@@ -124,7 +124,7 @@ void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, A
*
* Helper to set the appropriate channels to the specified gain.
*/
static inline void SetGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels])
inline void SetGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels])
{
ComputeAngleGains(device, 0.0f, F_PI, ingain, gains);
}
+3
View File
@@ -32,6 +32,9 @@
#include "alSource.h"
extern inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id);
extern inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id);
static ALenum AddEffectSlotArray(ALCcontext *Context, ALsizei count, const ALuint *slots);
static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *slot);
+2
View File
@@ -32,6 +32,8 @@
#include "alThunk.h"
extern inline struct ALbuffer *LookupBuffer(ALCdevice *device, ALuint id);
extern inline struct ALbuffer *RemoveBuffer(ALCdevice *device, ALuint id);
extern inline ALuint FrameSizeFromUserFmt(enum UserFmtChannels chans, enum UserFmtType type);
extern inline ALuint FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type);
+2
View File
@@ -34,6 +34,8 @@
ALboolean DisabledEffects[MAX_EFFECTS];
extern inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id);
extern inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id);
extern inline ALboolean IsReverbEffect(ALenum type);
static void InitEffectParams(ALeffect *effect, ALenum type);
+2
View File
@@ -29,6 +29,8 @@
#include "alError.h"
extern inline struct ALfilter *LookupFilter(ALCdevice *device, ALuint id);
extern inline struct ALfilter *RemoveFilter(ALCdevice *device, ALuint id);
extern inline ALfloat ALfilterState_processSingle(ALfilterState *filter, ALfloat sample);
extern inline ALfloat ALfilterState_processSingleC(const ALfilterState *filter, ALfloat sample);
+3
View File
@@ -47,6 +47,9 @@ const ALsizei ResamplerPrePadding[ResamplerMax] = {
};
extern inline struct ALsource *LookupSource(ALCcontext *context, ALuint id);
extern inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id);
static ALvoid InitSourceParams(ALsource *Source);
static ALint64 GetSourceOffset(const ALsource *Source);
static ALdouble GetSourceSecOffset(const ALsource *Source);