aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alcEcho.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-05-20 01:32:02 -0700
committerChris Robinson <[email protected]>2013-05-20 01:32:02 -0700
commit4c436b106d1a2b57e28fcaff0d5ec4a7abc6badc (patch)
treec1aff676a030f3581a28bfcb65a286c9910aaaa5 /Alc/alcEcho.c
parent1c523df16044730986ec745170d724fa82015ea0 (diff)
Use some macros to help with deriving types
Diffstat (limited to 'Alc/alcEcho.c')
-rw-r--r--Alc/alcEcho.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c
index 55a5b599..1d06e68a 100644
--- a/Alc/alcEcho.c
+++ b/Alc/alcEcho.c
@@ -31,8 +31,7 @@
typedef struct ALechoState {
- // Must be first in all effects!
- ALeffectState state;
+ DERIVE_FROM_TYPE(ALeffectState);
ALfloat *SampleBuffer;
ALuint BufferLength;
@@ -54,7 +53,7 @@ typedef struct ALechoState {
static ALvoid EchoDestroy(ALeffectState *effect)
{
- ALechoState *state = (ALechoState*)effect;
+ ALechoState *state = GET_PARENT_TYPE(ALechoState, ALeffectState, effect);
if(state)
{
free(state->SampleBuffer);
@@ -65,7 +64,7 @@ static ALvoid EchoDestroy(ALeffectState *effect)
static ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
{
- ALechoState *state = (ALechoState*)effect;
+ ALechoState *state = GET_PARENT_TYPE(ALechoState, ALeffectState, effect);
ALuint maxlen, i;
// Use the next power of 2 for the buffer length, so the tap offsets can be
@@ -92,7 +91,7 @@ static ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
static ALvoid EchoUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot)
{
- ALechoState *state = (ALechoState*)effect;
+ ALechoState *state = GET_PARENT_TYPE(ALechoState, ALeffectState, effect);
ALuint frequency = Device->Frequency;
ALfloat lrpan, cw, g, gain;
ALfloat dirGain;
@@ -128,7 +127,7 @@ static ALvoid EchoUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffec
static ALvoid EchoProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE])
{
- ALechoState *state = (ALechoState*)effect;
+ ALechoState *state = GET_PARENT_TYPE(ALechoState, ALeffectState, effect);
const ALuint mask = state->BufferLength-1;
const ALuint tap1 = state->Tap[0].delay;
const ALuint tap2 = state->Tap[1].delay;
@@ -164,10 +163,10 @@ ALeffectState *EchoCreate(void)
if(!state)
return NULL;
- state->state.Destroy = EchoDestroy;
- state->state.DeviceUpdate = EchoDeviceUpdate;
- state->state.Update = EchoUpdate;
- state->state.Process = EchoProcess;
+ GET_DERIVED_TYPE(ALeffectState, state)->Destroy = EchoDestroy;
+ GET_DERIVED_TYPE(ALeffectState, state)->DeviceUpdate = EchoDeviceUpdate;
+ GET_DERIVED_TYPE(ALeffectState, state)->Update = EchoUpdate;
+ GET_DERIVED_TYPE(ALeffectState, state)->Process = EchoProcess;
state->BufferLength = 0;
state->SampleBuffer = NULL;
@@ -180,7 +179,7 @@ ALeffectState *EchoCreate(void)
state->iirFilter.history[0] = 0.0f;
state->iirFilter.history[1] = 0.0f;
- return &state->state;
+ return GET_DERIVED_TYPE(ALeffectState, state);
}
void echo_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val)