From 0fbf34fb4592aa29fcbf4e725719cb253e7d3a78 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 25 Aug 2016 03:42:43 -0700 Subject: Add a ref count to ALeffectState This is mostly just reorganizing the effects to call the Construct method which initializes the ref count. --- Alc/effects/modulator.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'Alc/effects/modulator.c') diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c index 7e3e89b2..08f3d5eb 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -43,6 +43,15 @@ typedef struct ALmodulatorState { ALfilterState Filter[MAX_EFFECT_CHANNELS]; } ALmodulatorState; +static ALvoid ALmodulatorState_Destruct(ALmodulatorState *state); +static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *state, ALCdevice *device); +static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props); +static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels); +DECLARE_DEFAULT_ALLOCATORS(ALmodulatorState) + +DEFINE_ALEFFECTSTATE_VTABLE(ALmodulatorState); + + #define WAVEFORM_FRACBITS 24 #define WAVEFORM_FRACONE (1<index = 0; + state->step = 1; + + for(i = 0;i < MAX_EFFECT_CHANNELS;i++) + ALfilterState_clear(&state->Filter[i]); +} + static ALvoid ALmodulatorState_Destruct(ALmodulatorState *state) { ALeffectState_Destruct(STATIC_CAST(ALeffectState,state)); @@ -175,10 +198,6 @@ static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesTo state->index = index; } -DECLARE_DEFAULT_ALLOCATORS(ALmodulatorState) - -DEFINE_ALEFFECTSTATE_VTABLE(ALmodulatorState); - typedef struct ALmodulatorStateFactory { DERIVE_FROM_TYPE(ALeffectStateFactory); @@ -187,17 +206,9 @@ typedef struct ALmodulatorStateFactory { static ALeffectState *ALmodulatorStateFactory_create(ALmodulatorStateFactory *UNUSED(factory)) { ALmodulatorState *state; - ALuint i; - state = ALmodulatorState_New(sizeof(*state)); + NEW_OBJ0(state, ALmodulatorState)(); if(!state) return NULL; - SET_VTABLE2(ALmodulatorState, ALeffectState, state); - - state->index = 0; - state->step = 1; - - for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ALfilterState_clear(&state->Filter[i]); return STATIC_CAST(ALeffectState, state); } -- cgit v1.2.3