From da4f5c6f96b04094bf37e5c7ac393a7bfbfbb681 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 28 Nov 2010 19:52:17 -0800 Subject: Uninline some functions Also add -Winline to the compiler command line to watch for future inline problems --- Alc/ALc.c | 20 ++++++++ Alc/ALu.c | 106 +++++++++++++++++++++++++++++++++++++++ Alc/panning.c | 14 ++++++ CMakeLists.txt | 2 +- OpenAL32/Include/alMain.h | 21 +------- OpenAL32/Include/alu.h | 123 ++-------------------------------------------- 6 files changed, 145 insertions(+), 141 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index d2bdf144..2463ab12 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -757,6 +757,26 @@ void RemoveUIntMapKey(UIntMap *map, ALuint key) } } +ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key) +{ + if(map->size > 0) + { + ALsizei low = 0; + ALsizei high = map->size - 1; + while(low < high) + { + ALsizei mid = low + (high-low)/2; + if(map->array[mid].key < key) + low = mid + 1; + else + high = mid; + } + if(map->array[low].key == key) + return map->array[low].value; + } + return NULL; +} + /* IsDevice diff --git a/Alc/ALu.c b/Alc/ALu.c index 83571f50..03e1f6ca 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -37,6 +37,112 @@ #include "bs2b.h" +ALuint aluBytesFromFormat(ALenum format) +{ + switch(format) + { + case AL_FORMAT_MONO8: + case AL_FORMAT_STEREO8: + case AL_FORMAT_QUAD8_LOKI: + case AL_FORMAT_QUAD8: + case AL_FORMAT_REAR8: + case AL_FORMAT_51CHN8: + case AL_FORMAT_61CHN8: + case AL_FORMAT_71CHN8: + return 1; + + case AL_FORMAT_MONO16: + case AL_FORMAT_STEREO16: + case AL_FORMAT_QUAD16_LOKI: + case AL_FORMAT_QUAD16: + case AL_FORMAT_REAR16: + case AL_FORMAT_51CHN16: + case AL_FORMAT_61CHN16: + case AL_FORMAT_71CHN16: + return 2; + + case AL_FORMAT_MONO_FLOAT32: + case AL_FORMAT_STEREO_FLOAT32: + case AL_FORMAT_QUAD32: + case AL_FORMAT_REAR32: + case AL_FORMAT_51CHN32: + case AL_FORMAT_61CHN32: + case AL_FORMAT_71CHN32: + return 4; + + case AL_FORMAT_MONO_DOUBLE_EXT: + case AL_FORMAT_STEREO_DOUBLE_EXT: + return 8; + + case AL_FORMAT_MONO_MULAW: + case AL_FORMAT_STEREO_MULAW: + case AL_FORMAT_QUAD_MULAW: + case AL_FORMAT_REAR_MULAW: + case AL_FORMAT_51CHN_MULAW: + case AL_FORMAT_61CHN_MULAW: + case AL_FORMAT_71CHN_MULAW: + return 1; + + default: + return 0; + } +} +ALuint aluChannelsFromFormat(ALenum format) +{ + switch(format) + { + case AL_FORMAT_MONO8: + case AL_FORMAT_MONO16: + case AL_FORMAT_MONO_FLOAT32: + case AL_FORMAT_MONO_DOUBLE_EXT: + case AL_FORMAT_MONO_MULAW: + return 1; + + case AL_FORMAT_STEREO8: + case AL_FORMAT_STEREO16: + case AL_FORMAT_STEREO_FLOAT32: + case AL_FORMAT_STEREO_DOUBLE_EXT: + case AL_FORMAT_STEREO_MULAW: + return 2; + + case AL_FORMAT_QUAD8_LOKI: + case AL_FORMAT_QUAD16_LOKI: + case AL_FORMAT_QUAD8: + case AL_FORMAT_QUAD16: + case AL_FORMAT_QUAD32: + case AL_FORMAT_QUAD_MULAW: + return 4; + + case AL_FORMAT_REAR8: + case AL_FORMAT_REAR16: + case AL_FORMAT_REAR32: + case AL_FORMAT_REAR_MULAW: + return 2; + + case AL_FORMAT_51CHN8: + case AL_FORMAT_51CHN16: + case AL_FORMAT_51CHN32: + case AL_FORMAT_51CHN_MULAW: + return 6; + + case AL_FORMAT_61CHN8: + case AL_FORMAT_61CHN16: + case AL_FORMAT_61CHN32: + case AL_FORMAT_61CHN_MULAW: + return 7; + + case AL_FORMAT_71CHN8: + case AL_FORMAT_71CHN16: + case AL_FORMAT_71CHN32: + case AL_FORMAT_71CHN_MULAW: + return 8; + + default: + return 0; + } +} + + static __inline ALvoid aluCrossproduct(const ALfloat *inVector1, const ALfloat *inVector2, ALfloat *outVector) { outVector[0] = inVector1[1]*inVector2[2] - inVector1[2]*inVector2[1]; diff --git a/Alc/panning.c b/Alc/panning.c index 5c0f68fd..43c55cad 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -146,6 +146,20 @@ static ALfloat aluLUTpos2Angle(ALint pos) return aluAtan((ALfloat)(pos - 3 * QUADRANT_NUM) / (ALfloat)(4 * QUADRANT_NUM - pos)) - M_PI_2; } +ALint aluCart2LUTpos(ALfloat re, ALfloat im) +{ + ALint pos = 0; + ALfloat denom = aluFabs(re) + aluFabs(im); + if(denom > 0.0f) + pos = (ALint)(QUADRANT_NUM*aluFabs(im) / denom + 0.5); + + if(re < 0.0) + pos = 2 * QUADRANT_NUM - pos; + if(im < 0.0) + pos = LUT_NUM - pos; + return pos%LUT_NUM; +} + ALvoid aluInitPanning(ALCdevice *Device) { ALfloat SpeakerAngle[OUTPUTCHANNELS]; diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fe2f912..0842aae7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ IF(MSVC) LINK_DIRECTORIES("${DXSDK_DIR}/Lib") ENDIF() ELSE() - ADD_DEFINITIONS(-Wall) + ADD_DEFINITIONS(-Winline -Wall) CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA) IF(HAVE_W_EXTRA) ADD_DEFINITIONS(-Wextra) diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 41189010..1bfcc0f1 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -324,26 +324,7 @@ void InitUIntMap(UIntMap *map); void ResetUIntMap(UIntMap *map); ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); void RemoveUIntMapKey(UIntMap *map, ALuint key); - -static __inline ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key) -{ - if(map->size > 0) - { - ALsizei low = 0; - ALsizei high = map->size - 1; - while(low < high) - { - ALsizei mid = low + (high-low)/2; - if(map->array[mid].key < key) - low = mid + 1; - else - high = mid; - } - if(map->array[low].key == key) - return map->array[low].value; - } - return NULL; -} +ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key); struct ALCdevice_struct diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 698fccfd..d3d29994 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -95,131 +95,13 @@ typedef enum { #endif -/* NOTE: The AL_FORMAT_REAR* enums aren't handled here because they're - * converted to AL_FORMAT_QUAD* when loaded */ -static __inline ALuint aluBytesFromFormat(ALenum format) -{ - switch(format) - { - case AL_FORMAT_MONO8: - case AL_FORMAT_STEREO8: - case AL_FORMAT_QUAD8_LOKI: - case AL_FORMAT_QUAD8: - case AL_FORMAT_REAR8: - case AL_FORMAT_51CHN8: - case AL_FORMAT_61CHN8: - case AL_FORMAT_71CHN8: - return 1; - - case AL_FORMAT_MONO16: - case AL_FORMAT_STEREO16: - case AL_FORMAT_QUAD16_LOKI: - case AL_FORMAT_QUAD16: - case AL_FORMAT_REAR16: - case AL_FORMAT_51CHN16: - case AL_FORMAT_61CHN16: - case AL_FORMAT_71CHN16: - return 2; - - case AL_FORMAT_MONO_FLOAT32: - case AL_FORMAT_STEREO_FLOAT32: - case AL_FORMAT_QUAD32: - case AL_FORMAT_REAR32: - case AL_FORMAT_51CHN32: - case AL_FORMAT_61CHN32: - case AL_FORMAT_71CHN32: - return 4; - - case AL_FORMAT_MONO_DOUBLE_EXT: - case AL_FORMAT_STEREO_DOUBLE_EXT: - return 8; - - case AL_FORMAT_MONO_MULAW: - case AL_FORMAT_STEREO_MULAW: - case AL_FORMAT_QUAD_MULAW: - case AL_FORMAT_REAR_MULAW: - case AL_FORMAT_51CHN_MULAW: - case AL_FORMAT_61CHN_MULAW: - case AL_FORMAT_71CHN_MULAW: - return 1; - - default: - return 0; - } -} -static __inline ALuint aluChannelsFromFormat(ALenum format) -{ - switch(format) - { - case AL_FORMAT_MONO8: - case AL_FORMAT_MONO16: - case AL_FORMAT_MONO_FLOAT32: - case AL_FORMAT_MONO_DOUBLE_EXT: - case AL_FORMAT_MONO_MULAW: - return 1; - - case AL_FORMAT_STEREO8: - case AL_FORMAT_STEREO16: - case AL_FORMAT_STEREO_FLOAT32: - case AL_FORMAT_STEREO_DOUBLE_EXT: - case AL_FORMAT_STEREO_MULAW: - return 2; - - case AL_FORMAT_QUAD8_LOKI: - case AL_FORMAT_QUAD16_LOKI: - case AL_FORMAT_QUAD8: - case AL_FORMAT_QUAD16: - case AL_FORMAT_QUAD32: - case AL_FORMAT_QUAD_MULAW: - return 4; - - case AL_FORMAT_REAR8: - case AL_FORMAT_REAR16: - case AL_FORMAT_REAR32: - case AL_FORMAT_REAR_MULAW: - return 2; - - case AL_FORMAT_51CHN8: - case AL_FORMAT_51CHN16: - case AL_FORMAT_51CHN32: - case AL_FORMAT_51CHN_MULAW: - return 6; - - case AL_FORMAT_61CHN8: - case AL_FORMAT_61CHN16: - case AL_FORMAT_61CHN32: - case AL_FORMAT_61CHN_MULAW: - return 7; - - case AL_FORMAT_71CHN8: - case AL_FORMAT_71CHN16: - case AL_FORMAT_71CHN32: - case AL_FORMAT_71CHN_MULAW: - return 8; - - default: - return 0; - } -} +ALuint aluBytesFromFormat(ALenum format); +ALuint aluChannelsFromFormat(ALenum format); static __inline ALuint aluFrameSizeFromFormat(ALenum format) { return aluBytesFromFormat(format) * aluChannelsFromFormat(format); } -static __inline ALint aluCart2LUTpos(ALfloat re, ALfloat im) -{ - ALint pos = 0; - ALfloat denom = aluFabs(re) + aluFabs(im); - if(denom > 0.0f) - pos = (ALint)(QUADRANT_NUM*aluFabs(im) / denom + 0.5); - - if(re < 0.0) - pos = 2 * QUADRANT_NUM - pos; - if(im < 0.0) - pos = LUT_NUM - pos; - return pos%LUT_NUM; -} - static __inline ALdouble lerp(ALdouble val1, ALdouble val2, ALdouble mu) { val1 += (val2-val1) * mu; @@ -239,6 +121,7 @@ static __inline ALdouble cubic(ALdouble val0, ALdouble val1, ALdouble val2, ALdo struct ALsource; ALvoid aluInitPanning(ALCdevice *Device); +ALint aluCart2LUTpos(ALfloat re, ALfloat im); ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext); ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext); -- cgit v1.2.3