aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alEffect.h154
-rw-r--r--OpenAL32/alEffect.c90
2 files changed, 55 insertions, 189 deletions
diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h
index a3d40b82..cea785dc 100644
--- a/OpenAL32/Include/alEffect.h
+++ b/OpenAL32/Include/alEffect.h
@@ -7,6 +7,8 @@
extern "C" {
#endif
+typedef struct ALeffect ALeffect;
+
enum {
EAXREVERB = 0,
REVERB,
@@ -25,7 +27,39 @@ extern ALboolean DisabledEffects[MAX_EFFECTS];
extern ALfloat ReverbBoost;
extern ALboolean EmulateEAXReverb;
-typedef struct ALeffect
+struct ALeffectVtable {
+ void (*const SetParami)(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
+ void (*const SetParamiv)(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
+ void (*const SetParamf)(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
+ void (*const SetParamfv)(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
+
+ void (*const GetParami)(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
+ void (*const GetParamiv)(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
+ void (*const GetParamf)(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
+ void (*const GetParamfv)(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
+};
+
+#define DEFINE_ALEFFECT_VTABLE(T) \
+const struct ALeffectVtable T##_vtable = { \
+ T##_SetParami, T##_SetParamiv, \
+ T##_SetParamf, T##_SetParamfv, \
+ T##_GetParami, T##_GetParamiv, \
+ T##_GetParamf, T##_GetParamfv, \
+}
+
+extern const struct ALeffectVtable ALeaxreverb_vtable;
+extern const struct ALeffectVtable ALreverb_vtable;
+extern const struct ALeffectVtable ALchorus_vtable;
+extern const struct ALeffectVtable ALdistortion_vtable;
+extern const struct ALeffectVtable ALecho_vtable;
+extern const struct ALeffectVtable ALequalizer_vtable;
+extern const struct ALeffectVtable ALflanger_vtable;
+extern const struct ALeffectVtable ALmodulator_vtable;
+extern const struct ALeffectVtable ALnull_vtable;
+extern const struct ALeffectVtable ALdedicated_vtable;
+
+
+struct ALeffect
{
// Effect type (AL_EFFECT_NULL, ...)
ALenum type;
@@ -119,123 +153,25 @@ typedef struct ALeffect
ALfloat EQBandwidth;
} Distortion;
- void (*SetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
- void (*SetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
- void (*SetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
- void (*SetParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-
- void (*GetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
- void (*GetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
- void (*GetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
- void (*GetParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
+ const struct ALeffectVtable *vtbl;
/* Self ID */
ALuint id;
-} ALeffect;
+};
-#define ALeffect_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v)))
-#define ALeffect_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v)))
-#define ALeffect_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v)))
-#define ALeffect_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v)))
+#define ALeffect_SetParami(x, c, p, v) ((x)->vtbl->SetParami((x),(c),(p),(v)))
+#define ALeffect_SetParamiv(x, c, p, v) ((x)->vtbl->SetParamiv((x),(c),(p),(v)))
+#define ALeffect_SetParamf(x, c, p, v) ((x)->vtbl->SetParamf((x),(c),(p),(v)))
+#define ALeffect_SetParamfv(x, c, p, v) ((x)->vtbl->SetParamfv((x),(c),(p),(v)))
-#define ALeffect_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v)))
-#define ALeffect_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v)))
-#define ALeffect_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v)))
-#define ALeffect_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v)))
+#define ALeffect_GetParami(x, c, p, v) ((x)->vtbl->GetParami((x),(c),(p),(v)))
+#define ALeffect_GetParamiv(x, c, p, v) ((x)->vtbl->GetParamiv((x),(c),(p),(v)))
+#define ALeffect_GetParamf(x, c, p, v) ((x)->vtbl->GetParamf((x),(c),(p),(v)))
+#define ALeffect_GetParamfv(x, c, p, v) ((x)->vtbl->GetParamfv((x),(c),(p),(v)))
static __inline ALboolean IsReverbEffect(ALenum type)
{ return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
-void eaxreverb_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void eaxreverb_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void eaxreverb_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void eaxreverb_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void eaxreverb_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void eaxreverb_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void eaxreverb_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void eaxreverb_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void reverb_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void reverb_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void reverb_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void reverb_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void reverb_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void reverb_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void reverb_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void reverb_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void chorus_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void chorus_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void chorus_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void chorus_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void chorus_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void chorus_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void chorus_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void chorus_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void distortion_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void distortion_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void distortion_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void distortion_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void distortion_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void distortion_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void distortion_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void distortion_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void echo_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void echo_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void echo_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void echo_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void echo_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void echo_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void echo_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void echo_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void equalizer_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void equalizer_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void equalizer_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void equalizer_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void equalizer_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void equalizer_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void equalizer_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void equalizer_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void flanger_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void flanger_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void flanger_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void flanger_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void flanger_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void flanger_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void flanger_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void flanger_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void mod_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void mod_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void mod_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void mod_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void mod_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void mod_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void mod_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void mod_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void ded_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void ded_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void ded_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void ded_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void ded_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void ded_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void ded_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void ded_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
-void null_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
-void null_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
-void null_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
-void null_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
-void null_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
-void null_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
-void null_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
-void null_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
-
ALenum InitEffect(ALeffect *effect);
ALvoid ReleaseALEffects(ALCdevice *device);
diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c
index 23176beb..dded17b1 100644
--- a/OpenAL32/alEffect.c
+++ b/OpenAL32/alEffect.c
@@ -395,14 +395,7 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE;
effect->Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
effect->Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT;
- effect->SetParami = eaxreverb_SetParami;
- effect->SetParamiv = eaxreverb_SetParamiv;
- effect->SetParamf = eaxreverb_SetParamf;
- effect->SetParamfv = eaxreverb_SetParamfv;
- effect->GetParami = eaxreverb_GetParami;
- effect->GetParamiv = eaxreverb_GetParamiv;
- effect->GetParamf = eaxreverb_GetParamf;
- effect->GetParamfv = eaxreverb_GetParamfv;
+ effect->vtbl = &ALeaxreverb_vtable;
break;
case AL_EFFECT_REVERB:
effect->Reverb.Density = AL_REVERB_DEFAULT_DENSITY;
@@ -418,14 +411,7 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
effect->Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
effect->Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT;
- effect->SetParami = reverb_SetParami;
- effect->SetParamiv = reverb_SetParamiv;
- effect->SetParamf = reverb_SetParamf;
- effect->SetParamfv = reverb_SetParamfv;
- effect->GetParami = reverb_GetParami;
- effect->GetParamiv = reverb_GetParamiv;
- effect->GetParamf = reverb_GetParamf;
- effect->GetParamfv = reverb_GetParamfv;
+ effect->vtbl = &ALreverb_vtable;
break;
case AL_EFFECT_CHORUS:
effect->Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM;
@@ -434,14 +420,7 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH;
effect->Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK;
effect->Chorus.Delay = AL_CHORUS_DEFAULT_DELAY;
- effect->SetParami = chorus_SetParami;
- effect->SetParamiv = chorus_SetParamiv;
- effect->SetParamf = chorus_SetParamf;
- effect->SetParamfv = chorus_SetParamfv;
- effect->GetParami = chorus_GetParami;
- effect->GetParamiv = chorus_GetParamiv;
- effect->GetParamf = chorus_GetParamf;
- effect->GetParamfv = chorus_GetParamfv;
+ effect->vtbl = &ALchorus_vtable;
break;
case AL_EFFECT_DISTORTION:
effect->Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE;
@@ -449,14 +428,7 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF;
effect->Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER;
effect->Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH;
- effect->SetParami = distortion_SetParami;
- effect->SetParamiv = distortion_SetParamiv;
- effect->SetParamf = distortion_SetParamf;
- effect->SetParamfv = distortion_SetParamfv;
- effect->GetParami = distortion_GetParami;
- effect->GetParamiv = distortion_GetParamiv;
- effect->GetParamf = distortion_GetParamf;
- effect->GetParamfv = distortion_GetParamfv;
+ effect->vtbl = &ALdistortion_vtable;
break;
case AL_EFFECT_ECHO:
effect->Echo.Delay = AL_ECHO_DEFAULT_DELAY;
@@ -464,14 +436,7 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Echo.Damping = AL_ECHO_DEFAULT_DAMPING;
effect->Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK;
effect->Echo.Spread = AL_ECHO_DEFAULT_SPREAD;
- effect->SetParami = echo_SetParami;
- effect->SetParamiv = echo_SetParamiv;
- effect->SetParamf = echo_SetParamf;
- effect->SetParamfv = echo_SetParamfv;
- effect->GetParami = echo_GetParami;
- effect->GetParamiv = echo_GetParamiv;
- effect->GetParamf = echo_GetParamf;
- effect->GetParamfv = echo_GetParamfv;
+ effect->vtbl = &ALecho_vtable;
break;
case AL_EFFECT_EQUALIZER:
effect->Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF;
@@ -484,14 +449,7 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH;
effect->Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF;
effect->Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN;
- effect->SetParami = equalizer_SetParami;
- effect->SetParamiv = equalizer_SetParamiv;
- effect->SetParamf = equalizer_SetParamf;
- effect->SetParamfv = equalizer_SetParamfv;
- effect->GetParami = equalizer_GetParami;
- effect->GetParamiv = equalizer_GetParamiv;
- effect->GetParamf = equalizer_GetParamf;
- effect->GetParamfv = equalizer_GetParamfv;
+ effect->vtbl = &ALequalizer_vtable;
break;
case AL_EFFECT_FLANGER:
effect->Flanger.Waveform = AL_FLANGER_DEFAULT_WAVEFORM;
@@ -500,49 +458,21 @@ static void InitEffectParams(ALeffect *effect, ALenum type)
effect->Flanger.Depth = AL_FLANGER_DEFAULT_DEPTH;
effect->Flanger.Feedback = AL_FLANGER_DEFAULT_FEEDBACK;
effect->Flanger.Delay = AL_FLANGER_DEFAULT_DELAY;
- effect->SetParami = flanger_SetParami;
- effect->SetParamiv = flanger_SetParamiv;
- effect->SetParamf = flanger_SetParamf;
- effect->SetParamfv = flanger_SetParamfv;
- effect->GetParami = flanger_GetParami;
- effect->GetParamiv = flanger_GetParamiv;
- effect->GetParamf = flanger_GetParamf;
- effect->GetParamfv = flanger_GetParamfv;
+ effect->vtbl = &ALflanger_vtable;
break;
case AL_EFFECT_RING_MODULATOR:
effect->Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
effect->Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
effect->Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
- effect->SetParami = mod_SetParami;
- effect->SetParamiv = mod_SetParamiv;
- effect->SetParamf = mod_SetParamf;
- effect->SetParamfv = mod_SetParamfv;
- effect->GetParami = mod_GetParami;
- effect->GetParamiv = mod_GetParamiv;
- effect->GetParamf = mod_GetParamf;
- effect->GetParamfv = mod_GetParamfv;
+ effect->vtbl = &ALmodulator_vtable;
break;
case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT:
case AL_EFFECT_DEDICATED_DIALOGUE:
effect->Dedicated.Gain = 1.0f;
- effect->SetParami = ded_SetParami;
- effect->SetParamiv = ded_SetParamiv;
- effect->SetParamf = ded_SetParamf;
- effect->SetParamfv = ded_SetParamfv;
- effect->GetParami = ded_GetParami;
- effect->GetParamiv = ded_GetParamiv;
- effect->GetParamf = ded_GetParamf;
- effect->GetParamfv = ded_GetParamfv;
+ effect->vtbl = &ALdedicated_vtable;
break;
default:
- effect->SetParami = null_SetParami;
- effect->SetParamiv = null_SetParamiv;
- effect->SetParamf = null_SetParamf;
- effect->SetParamfv = null_SetParamfv;
- effect->GetParami = null_GetParami;
- effect->GetParamiv = null_GetParamiv;
- effect->GetParamf = null_GetParamf;
- effect->GetParamfv = null_GetParamfv;
+ effect->vtbl = &ALnull_vtable;
break;
}
effect->type = type;