diff options
author | Chris Robinson <[email protected]> | 2013-05-21 12:47:18 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-05-21 12:47:18 -0700 |
commit | a5d94f5d09be24bf34cbf8433a288cfd9ca396fb (patch) | |
tree | 456165199302b1b30bc68aadd4913f5d4ecf1572 /Alc/alcDedicated.c | |
parent | af1936be5dd4724367bfb7a90965f8769aa4f705 (diff) |
Use factories to create and destroy effect states
Diffstat (limited to 'Alc/alcDedicated.c')
-rw-r--r-- | Alc/alcDedicated.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/Alc/alcDedicated.c b/Alc/alcDedicated.c index 7d32c153..fbe2a5f1 100644 --- a/Alc/alcDedicated.c +++ b/Alc/alcDedicated.c @@ -29,6 +29,13 @@ #include "alu.h" +typedef struct ALdedicatedStateFactory { + DERIVE_FROM_TYPE(ALeffectStateFactory); +} ALdedicatedStateFactory; + +static ALdedicatedStateFactory DedicatedFactory; + + typedef struct ALdedicatedState { DERIVE_FROM_TYPE(ALeffectState); @@ -38,7 +45,7 @@ typedef struct ALdedicatedState { static ALvoid ALdedicatedState_Destroy(ALdedicatedState *state) { - free(state); + (void)state; } static ALboolean ALdedicatedState_DeviceUpdate(ALdedicatedState *state, ALCdevice *Device) @@ -78,9 +85,15 @@ static ALvoid ALdedicatedState_Process(ALdedicatedState *state, ALuint SamplesTo } } +static ALeffectStateFactory *ALdedicatedState_getCreator(void) +{ + return STATIC_CAST(ALeffectStateFactory, &DedicatedFactory); +} + DEFINE_ALEFFECTSTATE_VTABLE(ALdedicatedState); -ALeffectState *DedicatedCreate(void) + +ALeffectState *ALdedicatedStateFactory_create(void) { ALdedicatedState *state; ALsizei s; @@ -95,6 +108,29 @@ ALeffectState *DedicatedCreate(void) return STATIC_CAST(ALeffectState, state); } +static ALvoid ALdedicatedStateFactory_destroy(ALeffectState *effect) +{ + ALdedicatedState *state = STATIC_UPCAST(ALdedicatedState, ALeffectState, effect); + ALdedicatedState_Destroy(state); + free(state); +} + +DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALdedicatedStateFactory); + + +static void init_dedicated_factory(void) +{ + SET_VTABLE2(ALdedicatedStateFactory, ALeffectStateFactory, &DedicatedFactory); +} + +ALeffectStateFactory *ALdedicatedStateFactory_getFactory(void) +{ + static pthread_once_t once = PTHREAD_ONCE_INIT; + pthread_once(&once, init_dedicated_factory); + return STATIC_CAST(ALeffectStateFactory, &DedicatedFactory); +} + + void ded_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } void ded_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) |