aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-05-25 21:04:00 -0700
committerChris Robinson <[email protected]>2013-05-25 21:04:00 -0700
commit6571d805400f018b51835a8e37752409af9b1c4d (patch)
tree83cbbb263ca40d19fe25252c9d62400fc61d90c9
parent2da6caeaa61338ccbea9a7cbc022be932bb4e0e1 (diff)
Use a Delete method for deletable objects
-rw-r--r--Alc/effects/chorus.c11
-rw-r--r--Alc/effects/dedicated.c11
-rw-r--r--Alc/effects/distortion.c11
-rw-r--r--Alc/effects/echo.c11
-rw-r--r--Alc/effects/equalizer.c11
-rw-r--r--Alc/effects/flanger.c11
-rw-r--r--Alc/effects/modulator.c11
-rw-r--r--Alc/effects/null.c16
-rw-r--r--Alc/effects/reverb.c11
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h15
-rw-r--r--OpenAL32/Include/alMain.h5
11 files changed, 28 insertions, 96 deletions
diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c
index c74bf0b5..22241af5 100644
--- a/Alc/effects/chorus.c
+++ b/Alc/effects/chorus.c
@@ -243,9 +243,9 @@ static ALvoid ALchorusState_Process(ALchorusState *state, ALuint SamplesToDo, co
ProcessSinusoid(state, SamplesToDo, SamplesIn, SamplesOut);
}
-static ALeffectStateFactory *ALchorusState_getCreator(void)
+static void ALchorusState_Delete(ALchorusState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &ChorusFactory);
+ free(state);
}
DEFINE_ALEFFECTSTATE_VTABLE(ALchorusState);
@@ -267,13 +267,6 @@ static ALeffectState *ALchorusStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-static ALvoid ALchorusStateFactory_destroy(ALeffectState *effect)
-{
- ALchorusState *state = STATIC_UPCAST(ALchorusState, ALeffectState, effect);
- ALchorusState_Destruct(state);
- free(state);
-}
-
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALchorusStateFactory);
diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c
index 6b3ce1ae..184fe292 100644
--- a/Alc/effects/dedicated.c
+++ b/Alc/effects/dedicated.c
@@ -85,9 +85,9 @@ static ALvoid ALdedicatedState_Process(ALdedicatedState *state, ALuint SamplesTo
}
}
-static ALeffectStateFactory *ALdedicatedState_getCreator(void)
+static void ALdedicatedState_Delete(ALdedicatedState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &DedicatedFactory);
+ free(state);
}
DEFINE_ALEFFECTSTATE_VTABLE(ALdedicatedState);
@@ -108,13 +108,6 @@ ALeffectState *ALdedicatedStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-static ALvoid ALdedicatedStateFactory_destroy(ALeffectState *effect)
-{
- ALdedicatedState *state = STATIC_UPCAST(ALdedicatedState, ALeffectState, effect);
- ALdedicatedState_Destruct(state);
- free(state);
-}
-
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALdedicatedStateFactory);
diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c
index e92fb9a8..cc6669af 100644
--- a/Alc/effects/distortion.c
+++ b/Alc/effects/distortion.c
@@ -234,9 +234,9 @@ static ALvoid ALdistortionState_Process(ALdistortionState *state, ALuint Samples
}
}
-static ALeffectStateFactory *ALdistortionState_getCreator(void)
+static void ALdistortionState_Delete(ALdistortionState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &DistortionFactory);
+ free(state);
}
DEFINE_ALEFFECTSTATE_VTABLE(ALdistortionState);
@@ -263,13 +263,6 @@ static ALeffectState *ALdistortionStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-static ALvoid ALdistortionStateFactory_destroy(ALeffectState *effect)
-{
- ALdistortionState *state = STATIC_UPCAST(ALdistortionState, ALeffectState, effect);
- ALdistortionState_Destruct(state);
- free(state);
-}
-
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALdistortionStateFactory);
diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c
index 8f679c41..533461ac 100644
--- a/Alc/effects/echo.c
+++ b/Alc/effects/echo.c
@@ -175,9 +175,9 @@ static ALvoid ALechoState_Process(ALechoState *state, ALuint SamplesToDo, const
state->Offset = offset;
}
-static ALeffectStateFactory *ALechoState_getCreator(void)
+static void ALechoState_Delete(ALechoState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &EchoFactory);
+ free(state);
}
DEFINE_ALEFFECTSTATE_VTABLE(ALechoState);
@@ -205,13 +205,6 @@ ALeffectState *ALechoStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-static ALvoid ALechoStateFactory_destroy(ALeffectState *effect)
-{
- ALechoState *state = STATIC_UPCAST(ALechoState, ALeffectState, effect);
- ALechoState_Destruct(state);
- free(state);
-}
-
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALechoStateFactory);
diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c
index adcd40f4..3d5f35d5 100644
--- a/Alc/effects/equalizer.c
+++ b/Alc/effects/equalizer.c
@@ -270,9 +270,9 @@ static ALvoid ALequalizerState_Process(ALequalizerState *state, ALuint SamplesTo
}
}
-static ALeffectStateFactory *ALequalizerState_getCreator(void)
+static void ALequalizerState_Delete(ALequalizerState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &EqualizerFactory);
+ free(state);
}
DEFINE_ALEFFECTSTATE_VTABLE(ALequalizerState);
@@ -305,13 +305,6 @@ ALeffectState *ALequalizerStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-static ALvoid ALequalizerStateFactory_destroy(ALeffectState *effect)
-{
- ALequalizerState *state = STATIC_UPCAST(ALequalizerState, ALeffectState, effect);
- ALequalizerState_Destruct(state);
- free(state);
-}
-
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALequalizerStateFactory);
diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c
index de98a06d..12e16de2 100644
--- a/Alc/effects/flanger.c
+++ b/Alc/effects/flanger.c
@@ -243,9 +243,9 @@ static ALvoid ALflangerState_Process(ALflangerState *state, ALuint SamplesToDo,
ProcessSinusoid(state, SamplesToDo, SamplesIn, SamplesOut);
}
-static ALeffectStateFactory *ALflangerState_getCreator(void)
+static void ALflangerState_Delete(ALflangerState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &FlangerFactory);
+ free(state);
}
DEFINE_ALEFFECTSTATE_VTABLE(ALflangerState);
@@ -267,13 +267,6 @@ ALeffectState *ALflangerStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-static ALvoid ALflangerStateFactory_destroy(ALeffectState *effect)
-{
- ALflangerState *state = STATIC_UPCAST(ALflangerState, ALeffectState, effect);
- ALflangerState_Destruct(state);
- free(state);
-}
-
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALflangerStateFactory);
diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c
index e48a6d94..3f9ff8a5 100644
--- a/Alc/effects/modulator.c
+++ b/Alc/effects/modulator.c
@@ -197,9 +197,9 @@ static ALvoid ALmodulatorState_Process(ALmodulatorState *state, ALuint SamplesTo
}
}
-static ALeffectStateFactory *ALmodulatorState_getCreator(void)
+static void ALmodulatorState_Delete(ALmodulatorState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &ModulatorFactory);
+ free(state);
}
DEFINE_ALEFFECTSTATE_VTABLE(ALmodulatorState);
@@ -222,13 +222,6 @@ static ALeffectState *ALmodulatorStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-static ALvoid ALmodulatorStateFactory_destroy(ALeffectState *effect)
-{
- ALmodulatorState *state = STATIC_UPCAST(ALmodulatorState, ALeffectState, effect);
- ALmodulatorState_Destruct(state);
- free(state);
-}
-
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALmodulatorStateFactory);
diff --git a/Alc/effects/null.c b/Alc/effects/null.c
index 76d650da..3d617b64 100644
--- a/Alc/effects/null.c
+++ b/Alc/effects/null.c
@@ -60,12 +60,10 @@ static ALvoid ALnullState_Process(ALnullState *state, ALuint samplesToDo, const
(void)samplesOut;
}
-/* This returns the ALeffectStateFactory that creates these ALeffectState
- * object types.
- */
-static ALeffectStateFactory *ALnullState_getCreator(void)
+/* This frees the memory used by the object, after it has been destructed. */
+static void ALnullState_Delete(ALnullState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &NullFactory);
+ free(state);
}
/* Define the forwards and the ALeffectState vtable for this type. */
@@ -85,14 +83,6 @@ ALeffectState *ALnullStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-/* Destroys (destructs and frees) the ALeffectState. */
-static ALvoid ALnullStateFactory_destroy(ALeffectState *effect)
-{
- ALnullState *state = STATIC_UPCAST(ALnullState, ALeffectState, effect);
- ALnullState_Destruct(state);
- free(state);
-}
-
/* Define the ALeffectStateFactory vtable for this type. */
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALnullStateFactory);
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index b634dd1c..2421225d 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -1174,9 +1174,9 @@ static ALvoid ALreverbState_Destruct(ALreverbState *State)
State->SampleBuffer = NULL;
}
-static ALeffectStateFactory *ALreverbState_getCreator(void)
+static void ALreverbState_Delete(ALreverbState *state)
{
- return STATIC_CAST(ALeffectStateFactory, &ReverbFactory);
+ free(state);
}
DEFINE_ALEFFECTSTATE_VTABLE(ALreverbState);
@@ -1274,13 +1274,6 @@ static ALeffectState *ALreverbStateFactory_create(void)
return STATIC_CAST(ALeffectState, state);
}
-static ALvoid ALreverbStateFactory_destroy(ALeffectState *effect)
-{
- ALreverbState *state = STATIC_UPCAST(ALreverbState, ALeffectState, effect);
- ALreverbState_Destruct(state);
- free(state);
-}
-
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALreverbStateFactory);
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index ff88fe7b..d7062ff7 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -18,7 +18,8 @@ struct ALeffectStateVtable {
ALboolean (*const DeviceUpdate)(ALeffectState *state, ALCdevice *device);
ALvoid (*const Update)(ALeffectState *state, ALCdevice *device, const ALeffectslot *slot);
ALvoid (*const Process)(ALeffectState *state, ALuint samplesToDo, const ALfloat *restrict samplesIn, ALfloat (*restrict samplesOut)[BUFFERSIZE]);
- ALeffectStateFactory *(*const getCreator)(void);
+
+ void (*const Delete)(ALeffectState *state);
};
struct ALeffectState {
@@ -29,7 +30,6 @@ struct ALeffectState {
#define ALeffectState_DeviceUpdate(a,b) ((a)->vtbl->DeviceUpdate((a),(b)))
#define ALeffectState_Update(a,b,c) ((a)->vtbl->Update((a),(b),(c)))
#define ALeffectState_Process(a,b,c,d) ((a)->vtbl->Process((a),(b),(c),(d)))
-#define ALeffectState_getCreator(a) ((a)->vtbl->getCreator())
#define DEFINE_ALEFFECTSTATE_VTABLE(T) \
static ALvoid T##_ALeffectState_Destruct(ALeffectState *state) \
@@ -40,21 +40,20 @@ static ALvoid T##_ALeffectState_Update(ALeffectState *state, ALCdevice *device,
{ T##_Update(STATIC_UPCAST(T, ALeffectState, state), device, slot); } \
static ALvoid T##_ALeffectState_Process(ALeffectState *state, ALuint samplesToDo, const ALfloat *restrict samplesIn, ALfloat (*restrict samplesOut)[BUFFERSIZE]) \
{ T##_Process(STATIC_UPCAST(T, ALeffectState, state), samplesToDo, samplesIn, samplesOut); } \
-static ALeffectStateFactory* T##_ALeffectState_getCreator(void) \
-{ return T##_getCreator(); } \
+static ALvoid T##_ALeffectState_Delete(ALeffectState *state) \
+{ T##_Delete(STATIC_UPCAST(T, ALeffectState, state)); } \
\
static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \
T##_ALeffectState_Destruct, \
T##_ALeffectState_DeviceUpdate, \
T##_ALeffectState_Update, \
T##_ALeffectState_Process, \
- T##_ALeffectState_getCreator, \
+ T##_ALeffectState_Delete, \
}
struct ALeffectStateFactoryVtable {
ALeffectState *(*const create)(void);
- ALvoid (*const destroy)(ALeffectState *state);
};
struct ALeffectStateFactory {
@@ -62,17 +61,13 @@ struct ALeffectStateFactory {
};
#define ALeffectStateFactory_create(p) ((p)->vtbl->create())
-#define ALeffectStateFactory_destroy(p,a) ((p)->vtbl->destroy((a)))
#define DEFINE_ALEFFECTSTATEFACTORY_VTABLE(T) \
static ALeffectState* T##_ALeffectStateFactory_create(void) \
{ return T##_create(); } \
-static ALvoid T##_ALeffectStateFactory_destroy(ALeffectState *state) \
-{ T##_destroy(state); } \
\
static const struct ALeffectStateFactoryVtable T##_ALeffectStateFactory_vtable = { \
T##_ALeffectStateFactory_create, \
- T##_ALeffectStateFactory_destroy \
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index ca0df2ad..a7c79b2a 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -70,7 +70,10 @@ static const union {
#define SET_VTABLE1(T1, obj) ((obj)->vtbl = &(T1##_vtable))
#define SET_VTABLE2(T1, T2, obj) SET_VTABLE1(T1##_##T2, STATIC_CAST(T2, (obj)))
-#define DELETE_OBJ(obj) ((obj)->vtbl->getCreator()->vtbl->destroy((obj)))
+#define DELETE_OBJ(obj) do { \
+ (obj)->vtbl->Destruct((obj)); \
+ (obj)->vtbl->Delete((obj)); \
+} while(0)
#ifdef _WIN32