aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-28 00:10:12 -0800
committerChris Robinson <[email protected]>2018-01-28 00:10:12 -0800
commitdcc5a10c7b8bbe6be82c992b6540fd1ad745b7a7 (patch)
treed5f931b713bbd7c1031aebcbe0e01ca202bdcc71
parent0051ebace0c419d873c1ebbe615c483c0124e70e (diff)
Use a fixed array for the effect state factory list
-rw-r--r--Alc/ALc.c4
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h3
-rw-r--r--OpenAL32/alAuxEffectSlot.c52
3 files changed, 24 insertions, 35 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 7ec5ec8d..ea387c6d 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1127,8 +1127,6 @@ static void alc_initconfig(void)
} while(next++);
}
- InitEffectFactoryMap();
-
InitEffect(&DefaultEffect);
str = getenv("ALSOFT_DEFAULT_REVERB");
if((str && str[0]) || ConfigValueStr(NULL, NULL, "default-reverb", &str))
@@ -1229,8 +1227,6 @@ static void alc_cleanup(void)
} while((dev=dev->next) != NULL);
ERR("%u device%s not closed\n", num, (num>1)?"s":"");
}
-
- DeinitEffectFactoryMap();
}
static void alc_deinit_safe(void)
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index e4e954a0..aa3a0118 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -171,9 +171,6 @@ ALeffectStateFactory *ALdedicatedStateFactory_getFactory(void);
ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect);
-void InitEffectFactoryMap(void);
-void DeinitEffectFactoryMap(void);
-
void ALeffectState_DecRef(ALeffectState *state);
#ifdef __cplusplus
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index f5362e94..cd028bb0 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -39,12 +39,32 @@
extern inline void LockEffectSlotList(ALCcontext *context);
extern inline void UnlockEffectSlotList(ALCcontext *context);
-static UIntMap EffectStateFactoryMap;
+static const struct {
+ ALenum Type;
+ ALeffectStateFactory* (*GetFactory)(void);
+} FactoryList[] = {
+ { AL_EFFECT_NULL, ALnullStateFactory_getFactory },
+ { AL_EFFECT_EAXREVERB, ALreverbStateFactory_getFactory },
+ { AL_EFFECT_REVERB, ALreverbStateFactory_getFactory },
+ { AL_EFFECT_CHORUS, ALchorusStateFactory_getFactory },
+ { AL_EFFECT_COMPRESSOR, ALcompressorStateFactory_getFactory },
+ { AL_EFFECT_DISTORTION, ALdistortionStateFactory_getFactory },
+ { AL_EFFECT_ECHO, ALechoStateFactory_getFactory },
+ { AL_EFFECT_EQUALIZER, ALequalizerStateFactory_getFactory },
+ { AL_EFFECT_FLANGER, ALflangerStateFactory_getFactory },
+ { AL_EFFECT_RING_MODULATOR, ALmodulatorStateFactory_getFactory },
+ { AL_EFFECT_DEDICATED_DIALOGUE, ALdedicatedStateFactory_getFactory },
+ { AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, ALdedicatedStateFactory_getFactory }
+};
+
static inline ALeffectStateFactory *getFactoryByType(ALenum type)
{
- ALeffectStateFactory* (*getFactory)(void) = LookupUIntMapKey(&EffectStateFactoryMap, type);
- if(getFactory != NULL)
- return getFactory();
+ size_t i;
+ for(i = 0;i < COUNTOF(FactoryList);i++)
+ {
+ if(FactoryList[i].Type == type)
+ return FactoryList[i].GetFactory();
+ }
return NULL;
}
@@ -517,30 +537,6 @@ done:
}
-void InitEffectFactoryMap(void)
-{
- InitUIntMap(&EffectStateFactoryMap, INT_MAX);
-
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_NULL, ALnullStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_EAXREVERB, ALreverbStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_REVERB, ALreverbStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_CHORUS, ALchorusStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_COMPRESSOR, ALcompressorStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_DISTORTION, ALdistortionStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_ECHO, ALechoStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_EQUALIZER, ALequalizerStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_FLANGER, ALflangerStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_RING_MODULATOR, ALmodulatorStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_DEDICATED_DIALOGUE, ALdedicatedStateFactory_getFactory);
- InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, ALdedicatedStateFactory_getFactory);
-}
-
-void DeinitEffectFactoryMap(void)
-{
- ResetUIntMap(&EffectStateFactoryMap);
-}
-
-
ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect)
{
ALCdevice *Device = Context->Device;