diff options
author | Chris Robinson <[email protected]> | 2018-11-19 06:43:37 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-19 06:43:37 -0800 |
commit | c5c537cc5f5cb466cdf6679c9af9768301e32cc3 (patch) | |
tree | 6e9252e69132430c35e853132df5e42f5c1fae4d /OpenAL32 | |
parent | f0cc34a60e65b7120a8d2d2bd5f76aebb3352685 (diff) |
Use proper inheritence for EffectStateFactory
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alAuxEffectSlot.h | 25 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.cpp | 8 |
2 files changed, 6 insertions, 27 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index 815ae77e..d3d4e704 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -7,9 +7,6 @@ #include "almalloc.h" #include "atomic.h" -#ifdef __cplusplus -extern "C" { -#endif struct ALeffectStateVtable; struct ALeffectslot; @@ -59,23 +56,11 @@ static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \ } -struct EffectStateFactoryVtable; - -typedef struct EffectStateFactory { - const struct EffectStateFactoryVtable *vtab; -} EffectStateFactory; +struct EffectStateFactory { + virtual ~EffectStateFactory() { } -struct EffectStateFactoryVtable { - ALeffectState *(*const create)(EffectStateFactory *factory); + virtual ALeffectState *create() = 0; }; -#define EffectStateFactory_create(x) ((x)->vtab->create((x))) - -#define DEFINE_EFFECTSTATEFACTORY_VTABLE(T) \ -DECLARE_THUNK(T, EffectStateFactory, ALeffectState*, create) \ - \ -static const struct EffectStateFactoryVtable T##_EffectStateFactory_vtable = { \ - T##_EffectStateFactory_create, \ -} #define MAX_EFFECT_CHANNELS (4) @@ -184,8 +169,4 @@ ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect void ALeffectState_DecRef(ALeffectState *state); -#ifdef __cplusplus -} -#endif - #endif diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp index ff0f7eaa..4e25d3ee 100644 --- a/OpenAL32/alAuxEffectSlot.cpp +++ b/OpenAL32/alAuxEffectSlot.cpp @@ -487,15 +487,13 @@ ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect if(newtype != EffectSlot->Effect.Type) { - EffectStateFactory *factory; - - factory = getFactoryByType(newtype); + EffectStateFactory *factory = getFactoryByType(newtype); if(!factory) { ERR("Failed to find factory for effect type 0x%04x\n", newtype); return AL_INVALID_ENUM; } - State = EffectStateFactory_create(factory); + State = factory->create(); if(!State) return AL_OUT_OF_MEMORY; START_MIXER_MODE(); @@ -663,7 +661,7 @@ static void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcon ALenum InitEffectSlot(ALeffectslot *slot) { EffectStateFactory *factory{getFactoryByType(slot->Effect.Type)}; - slot->Effect.State = EffectStateFactory_create(factory); + slot->Effect.State = factory->create(); if(!slot->Effect.State) return AL_OUT_OF_MEMORY; ALeffectState_IncRef(slot->Effect.State); |