From 85a8f965e56dadf6928ca66503391029d7965928 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 11 Jan 2018 09:34:01 -0800 Subject: Clean up the EffectList members and make the list size known --- Alc/ALc.c | 2 +- OpenAL32/Include/alEffect.h | 26 +++++++++++++------------- OpenAL32/alEffect.c | 31 +++++++++++++++---------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index 3b175b66..00d75f8c 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -1133,7 +1133,7 @@ static void alc_initconfig(void) continue; len = (next ? ((size_t)(next-str)) : strlen(str)); - for(n = 0;EffectList[n].name;n++) + for(n = 0;n < EFFECTLIST_SIZE;n++) { if(len == strlen(EffectList[n].name) && strncmp(EffectList[n].name, str, len) == 0) diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h index 394500e0..dbbd8966 100644 --- a/OpenAL32/Include/alEffect.h +++ b/OpenAL32/Include/alEffect.h @@ -10,16 +10,16 @@ extern "C" { struct ALeffect; enum { - AL__EAXREVERB = 0, - AL__REVERB, - AL__CHORUS, - AL__COMPRESSOR, - AL__DISTORTION, - AL__ECHO, - AL__EQUALIZER, - AL__FLANGER, - AL__MODULATOR, - AL__DEDICATED, + EAXREVERB_EFFECT = 0, + REVERB_EFFECT, + CHORUS_EFFECT, + COMPRESSOR_EFFECT, + DISTORTION_EFFECT, + ECHO_EFFECT, + EQUALIZER_EFFECT, + FLANGER_EFFECT, + MODULATOR_EFFECT, + DEDICATED_EFFECT, MAX_EFFECTS }; @@ -28,12 +28,12 @@ extern ALboolean DisabledEffects[MAX_EFFECTS]; extern ALfloat ReverbBoost; struct EffectList { - const char *name; + const char name[16]; int type; - const char *ename; ALenum val; }; -extern const struct EffectList EffectList[]; +#define EFFECTLIST_SIZE 11 +extern const struct EffectList EffectList[EFFECTLIST_SIZE]; struct ALeffectVtable { diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index 6fa748b3..48268247 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -32,19 +32,18 @@ #include "alError.h" -const struct EffectList EffectList[] = { - { "eaxreverb", AL__EAXREVERB, "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB }, - { "reverb", AL__REVERB, "AL_EFFECT_REVERB", AL_EFFECT_REVERB }, - { "chorus", AL__CHORUS, "AL_EFFECT_CHORUS", AL_EFFECT_CHORUS }, - { "compressor", AL__COMPRESSOR, "AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR }, - { "distortion", AL__DISTORTION, "AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION }, - { "echo", AL__ECHO, "AL_EFFECT_ECHO", AL_EFFECT_ECHO }, - { "equalizer", AL__EQUALIZER, "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER }, - { "flanger", AL__FLANGER, "AL_EFFECT_FLANGER", AL_EFFECT_FLANGER }, - { "modulator", AL__MODULATOR, "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR }, - { "dedicated", AL__DEDICATED, "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT", AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT }, - { "dedicated", AL__DEDICATED, "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE }, - { NULL, 0, NULL, (ALenum)0 } +const struct EffectList EffectList[EFFECTLIST_SIZE] = { + { "eaxreverb", EAXREVERB_EFFECT, AL_EFFECT_EAXREVERB }, + { "reverb", REVERB_EFFECT, AL_EFFECT_REVERB }, + { "chorus", CHORUS_EFFECT, AL_EFFECT_CHORUS }, + { "compressor", COMPRESSOR_EFFECT, AL_EFFECT_COMPRESSOR }, + { "distortion", DISTORTION_EFFECT, AL_EFFECT_DISTORTION }, + { "echo", ECHO_EFFECT, AL_EFFECT_ECHO }, + { "equalizer", EQUALIZER_EFFECT, AL_EFFECT_EQUALIZER }, + { "flanger", FLANGER_EFFECT, AL_EFFECT_FLANGER }, + { "modulator", MODULATOR_EFFECT, AL_EFFECT_RING_MODULATOR }, + { "dedicated", DEDICATED_EFFECT, AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT }, + { "dedicated", DEDICATED_EFFECT, AL_EFFECT_DEDICATED_DIALOGUE }, }; ALboolean DisabledEffects[MAX_EFFECTS]; @@ -175,7 +174,7 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value) { ALboolean isOk = (value == AL_EFFECT_NULL); ALint i; - for(i = 0;!isOk && EffectList[i].val;i++) + for(i = 0;!isOk && i < EFFECTLIST_SIZE;i++) { if(value == EffectList[i].val && !DisabledEffects[EffectList[i].type]) @@ -682,9 +681,9 @@ ALvoid LoadReverbPreset(const char *name, ALeffect *effect) return; } - if(!DisabledEffects[AL__EAXREVERB]) + if(!DisabledEffects[EAXREVERB_EFFECT]) InitEffectParams(effect, AL_EFFECT_EAXREVERB); - else if(!DisabledEffects[AL__REVERB]) + else if(!DisabledEffects[REVERB_EFFECT]) InitEffectParams(effect, AL_EFFECT_REVERB); else InitEffectParams(effect, AL_EFFECT_NULL); -- cgit v1.2.3