aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alcReverb.c
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/alcReverb.c')
-rw-r--r--Alc/alcReverb.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c
index ab52ae77..ac9af905 100644
--- a/Alc/alcReverb.c
+++ b/Alc/alcReverb.c
@@ -40,8 +40,7 @@ typedef struct DelayLine
} DelayLine;
typedef struct ALverbState {
- // Must be first in all effects!
- ALeffectState state;
+ DERIVE_FROM_TYPE(ALeffectState);
// All delay lines are allocated as a single buffer to reduce memory
// fragmentation and management code.
@@ -557,7 +556,7 @@ static __inline ALvoid EAXVerbPass(ALverbState *State, ALfloat in, ALfloat *REST
// buffer.
static ALvoid VerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE])
{
- ALverbState *State = (ALverbState*)effect;
+ ALverbState *State = GET_PARENT_TYPE(ALverbState, ALeffectState, effect);
ALfloat (*RESTRICT out)[4] = State->ReverbSamples;
ALuint index, c;
@@ -580,7 +579,7 @@ static ALvoid VerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALflo
// buffer.
static ALvoid EAXVerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE])
{
- ALverbState *State = (ALverbState*)effect;
+ ALverbState *State = GET_PARENT_TYPE(ALverbState, ALeffectState, effect);
ALfloat (*RESTRICT early)[4] = State->EarlySamples;
ALfloat (*RESTRICT late)[4] = State->ReverbSamples;
ALuint index, c;
@@ -727,7 +726,7 @@ static ALboolean AllocLines(ALuint frequency, ALverbState *State)
// format) have been changed.
static ALboolean ReverbDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
{
- ALverbState *State = (ALverbState*)effect;
+ ALverbState *State = GET_PARENT_TYPE(ALverbState, ALeffectState, effect);
ALuint frequency = Device->Frequency, index;
// Allocate the delay lines.
@@ -1079,19 +1078,19 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
// effect is loaded into a slot.
static ALvoid ReverbUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot)
{
- ALverbState *State = (ALverbState*)effect;
+ ALverbState *State = GET_PARENT_TYPE(ALverbState, ALeffectState, effect);
ALuint frequency = Device->Frequency;
ALboolean isEAX = AL_FALSE;
ALfloat cw, x, y, hfRatio;
if(Slot->effect.type == AL_EFFECT_EAXREVERB && !EmulateEAXReverb)
{
- State->state.Process = EAXVerbProcess;
+ GET_DERIVED_TYPE(ALeffectState, State)->Process = EAXVerbProcess;
isEAX = AL_TRUE;
}
else if(Slot->effect.type == AL_EFFECT_REVERB || EmulateEAXReverb)
{
- State->state.Process = VerbProcess;
+ GET_DERIVED_TYPE(ALeffectState, State)->Process = VerbProcess;
isEAX = AL_FALSE;
}
@@ -1174,7 +1173,7 @@ static ALvoid ReverbUpdate(ALeffectState *effect, ALCdevice *Device, const ALeff
// slot has a different (or no) effect loaded over the reverb effect.
static ALvoid ReverbDestroy(ALeffectState *effect)
{
- ALverbState *State = (ALverbState*)effect;
+ ALverbState *State = GET_PARENT_TYPE(ALverbState, ALeffectState, effect);
if(State)
{
free(State->SampleBuffer);
@@ -1194,10 +1193,10 @@ ALeffectState *ReverbCreate(void)
if(!State)
return NULL;
- State->state.Destroy = ReverbDestroy;
- State->state.DeviceUpdate = ReverbDeviceUpdate;
- State->state.Update = ReverbUpdate;
- State->state.Process = VerbProcess;
+ GET_DERIVED_TYPE(ALeffectState, State)->Destroy = ReverbDestroy;
+ GET_DERIVED_TYPE(ALeffectState, State)->DeviceUpdate = ReverbDeviceUpdate;
+ GET_DERIVED_TYPE(ALeffectState, State)->Update = ReverbUpdate;
+ GET_DERIVED_TYPE(ALeffectState, State)->Process = VerbProcess;
State->TotalSamples = 0;
State->SampleBuffer = NULL;
@@ -1279,7 +1278,7 @@ ALeffectState *ReverbCreate(void)
State->Gain = State->Late.PanGain;
- return &State->state;
+ return GET_DERIVED_TYPE(ALeffectState, State);
}
void eaxreverb_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val)