aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alcModulator.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-05-21 12:47:18 -0700
committerChris Robinson <[email protected]>2013-05-21 12:47:18 -0700
commita5d94f5d09be24bf34cbf8433a288cfd9ca396fb (patch)
tree456165199302b1b30bc68aadd4913f5d4ecf1572 /Alc/alcModulator.c
parentaf1936be5dd4724367bfb7a90965f8769aa4f705 (diff)
Use factories to create and destroy effect states
Diffstat (limited to 'Alc/alcModulator.c')
-rw-r--r--Alc/alcModulator.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c
index bb90d646..25b5bcc4 100644
--- a/Alc/alcModulator.c
+++ b/Alc/alcModulator.c
@@ -30,6 +30,13 @@
#include "alu.h"
+typedef struct ALmodulatorStateFactory {
+ DERIVE_FROM_TYPE(ALeffectStateFactory);
+} ALmodulatorStateFactory;
+
+static ALmodulatorStateFactory ModulatorFactory;
+
+
typedef struct ALmodulatorState {
DERIVE_FROM_TYPE(ALeffectState);
@@ -130,7 +137,7 @@ DECL_TEMPLATE(Square)
static ALvoid ALmodulatorState_Destroy(ALmodulatorState *state)
{
- free(state);
+ (void)state;
}
static ALboolean ALmodulatorState_DeviceUpdate(ALmodulatorState *state, ALCdevice *Device)
@@ -190,9 +197,15 @@ static ALvoid ALmodulatorState_Process(ALmodulatorState *state, ALuint SamplesTo
}
}
+static ALeffectStateFactory *ALmodulatorState_getCreator(void)
+{
+ return STATIC_CAST(ALeffectStateFactory, &ModulatorFactory);
+}
+
DEFINE_ALEFFECTSTATE_VTABLE(ALmodulatorState);
-ALeffectState *ModulatorCreate(void)
+
+static ALeffectState *ALmodulatorStateFactory_create(void)
{
ALmodulatorState *state;
@@ -209,6 +222,29 @@ ALeffectState *ModulatorCreate(void)
return STATIC_CAST(ALeffectState, state);
}
+static ALvoid ALmodulatorStateFactory_destroy(ALeffectState *effect)
+{
+ ALmodulatorState *state = STATIC_UPCAST(ALmodulatorState, ALeffectState, effect);
+ ALmodulatorState_Destroy(state);
+ free(state);
+}
+
+DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALmodulatorStateFactory);
+
+
+static void init_modulator_factory(void)
+{
+ SET_VTABLE2(ALmodulatorStateFactory, ALeffectStateFactory, &ModulatorFactory);
+}
+
+ALeffectStateFactory *ALmodulatorStateFactory_getFactory(void)
+{
+ static pthread_once_t once = PTHREAD_ONCE_INIT;
+ pthread_once(&once, init_modulator_factory);
+ return STATIC_CAST(ALeffectStateFactory, &ModulatorFactory);
+}
+
+
void mod_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val)
{
switch(param)