diff options
author | Chris Robinson <[email protected]> | 2013-05-20 01:32:02 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-05-20 01:32:02 -0700 |
commit | 4c436b106d1a2b57e28fcaff0d5ec4a7abc6badc (patch) | |
tree | c1aff676a030f3581a28bfcb65a286c9910aaaa5 /Alc/alcModulator.c | |
parent | 1c523df16044730986ec745170d724fa82015ea0 (diff) |
Use some macros to help with deriving types
Diffstat (limited to 'Alc/alcModulator.c')
-rw-r--r-- | Alc/alcModulator.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c index f1f8dadd..d33811ba 100644 --- a/Alc/alcModulator.c +++ b/Alc/alcModulator.c @@ -31,8 +31,7 @@ typedef struct ALmodulatorState { - // Must be first in all effects! - ALeffectState state; + DERIVE_FROM_TYPE(ALeffectState); enum { SINUSOID, @@ -116,7 +115,7 @@ DECL_TEMPLATE(Square) static ALvoid ModulatorDestroy(ALeffectState *effect) { - ALmodulatorState *state = (ALmodulatorState*)effect; + ALmodulatorState *state = GET_PARENT_TYPE(ALmodulatorState, ALeffectState, effect); free(state); } @@ -129,7 +128,7 @@ static ALboolean ModulatorDeviceUpdate(ALeffectState *effect, ALCdevice *Device) static ALvoid ModulatorUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot) { - ALmodulatorState *state = (ALmodulatorState*)effect; + ALmodulatorState *state = GET_PARENT_TYPE(ALmodulatorState, ALeffectState, effect); ALfloat gain, cw, a = 0.0f; ALuint index; @@ -162,7 +161,7 @@ static ALvoid ModulatorUpdate(ALeffectState *effect, ALCdevice *Device, const AL static ALvoid ModulatorProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE]) { - ALmodulatorState *state = (ALmodulatorState*)effect; + ALmodulatorState *state = GET_PARENT_TYPE(ALmodulatorState, ALeffectState, effect); switch(state->Waveform) { @@ -188,10 +187,10 @@ ALeffectState *ModulatorCreate(void) if(!state) return NULL; - state->state.Destroy = ModulatorDestroy; - state->state.DeviceUpdate = ModulatorDeviceUpdate; - state->state.Update = ModulatorUpdate; - state->state.Process = ModulatorProcess; + GET_DERIVED_TYPE(ALeffectState, state)->Destroy = ModulatorDestroy; + GET_DERIVED_TYPE(ALeffectState, state)->DeviceUpdate = ModulatorDeviceUpdate; + GET_DERIVED_TYPE(ALeffectState, state)->Update = ModulatorUpdate; + GET_DERIVED_TYPE(ALeffectState, state)->Process = ModulatorProcess; state->index = 0; state->step = 1; @@ -199,7 +198,7 @@ ALeffectState *ModulatorCreate(void) state->iirFilter.coeff = 0.0f; state->iirFilter.history[0] = 0.0f; - return &state->state; + return GET_DERIVED_TYPE(ALeffectState, state); } void mod_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) |