aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects/modulator.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-08-25 03:42:43 -0700
committerChris Robinson <[email protected]>2016-08-25 03:49:57 -0700
commit0fbf34fb4592aa29fcbf4e725719cb253e7d3a78 (patch)
treeb378b50a61dd604bb7d2baadb127834c4c55e678 /Alc/effects/modulator.c
parentd8e9b3c621762e3d9e2b81034e19aa0d671247ae (diff)
Add a ref count to ALeffectState
This is mostly just reorganizing the effects to call the Construct method which initializes the ref count.
Diffstat (limited to 'Alc/effects/modulator.c')
-rw-r--r--Alc/effects/modulator.c37
1 files changed, 24 insertions, 13 deletions
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<<WAVEFORM_FRACBITS)
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
@@ -82,6 +91,20 @@ DECL_TEMPLATE(Square)
#undef DECL_TEMPLATE
+static void ALmodulatorState_Construct(ALmodulatorState *state)
+{
+ ALuint i;
+
+ ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
+ SET_VTABLE2(ALmodulatorState, ALeffectState, state);
+
+ state->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);
}