diff options
author | Chris Robinson <[email protected]> | 2018-11-19 22:34:26 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-19 22:34:26 -0800 |
commit | 8472a9d916eae13771455c2b527c1148aa71d8fb (patch) | |
tree | d86470a5e2882ce73a86a892eac7082bd2b97566 /OpenAL32/Include | |
parent | 6ac84c7a5f6d267522bdc872802c8940dcd2adec (diff) |
Use proper inheritence for the effect state objects
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r-- | OpenAL32/Include/alAuxEffectSlot.h | 59 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 3 |
2 files changed, 17 insertions, 45 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index d3d4e704..ca2cb663 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -8,58 +8,31 @@ #include "atomic.h" -struct ALeffectStateVtable; struct ALeffectslot; -typedef struct ALeffectState { - RefCount Ref; - const struct ALeffectStateVtable *vtbl; - ALfloat (*OutBuffer)[BUFFERSIZE]; - ALsizei OutChannels; -} ALeffectState; +struct EffectState { + RefCount mRef{1u}; -void ALeffectState_Construct(ALeffectState *state); -void ALeffectState_Destruct(ALeffectState *state); + ALfloat (*mOutBuffer)[BUFFERSIZE]{nullptr}; + ALsizei mOutChannels{0}; -struct ALeffectStateVtable { - void (*const Destruct)(ALeffectState *state); - ALboolean (*const deviceUpdate)(ALeffectState *state, ALCdevice *device); - void (*const update)(ALeffectState *state, const ALCcontext *context, const struct ALeffectslot *slot, const union ALeffectProps *props); - void (*const process)(ALeffectState *state, ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels); + virtual ~EffectState() = default; - void (*const Delete)(void *ptr); -}; + virtual ALboolean deviceUpdate(ALCdevice *device) = 0; + virtual void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) = 0; + virtual void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) = 0; -/* Small hack to use a pointer-to-array types as a normal argument type. - * Shouldn't be used directly. - */ -typedef ALfloat ALfloatBUFFERSIZE[BUFFERSIZE]; - -#define DEFINE_ALEFFECTSTATE_VTABLE(T) \ -DECLARE_THUNK(T, ALeffectState, void, Destruct) \ -DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \ -DECLARE_THUNK3(T, ALeffectState, void, update, const ALCcontext*, const ALeffectslot*, const ALeffectProps*) \ -DECLARE_THUNK4(T, ALeffectState, void, process, ALsizei, const ALfloatBUFFERSIZE*RESTRICT, ALfloatBUFFERSIZE*RESTRICT, ALsizei) \ -static void T##_ALeffectState_Delete(void *ptr) \ -{ return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \ - \ -static const struct ALeffectStateVtable T##_ALeffectState_vtable = { \ - T##_ALeffectState_Destruct, \ - \ - T##_ALeffectState_deviceUpdate, \ - T##_ALeffectState_update, \ - T##_ALeffectState_process, \ - \ - T##_ALeffectState_Delete, \ -} + void IncRef() noexcept; + void DecRef() noexcept; +}; struct EffectStateFactory { virtual ~EffectStateFactory() { } - virtual ALeffectState *create() = 0; + virtual EffectState *create() = 0; }; @@ -79,7 +52,7 @@ struct ALeffectslotProps { ALenum Type; ALeffectProps Props; - ALeffectState *State; + EffectState *State; ATOMIC(struct ALeffectslotProps*) next; }; @@ -93,7 +66,7 @@ struct ALeffectslot { ALenum Type{AL_EFFECT_NULL}; ALeffectProps Props{}; - ALeffectState *State{nullptr}; + EffectState *State{nullptr}; } Effect; ATOMIC(ALenum) PropsClean{AL_TRUE}; @@ -108,7 +81,7 @@ struct ALeffectslot { ALenum EffectType{AL_EFFECT_NULL}; ALeffectProps EffectProps{}; - ALeffectState *EffectState{nullptr}; + EffectState *EffectState{nullptr}; ALfloat RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */ ALfloat DecayTime{0.0f}; @@ -167,6 +140,4 @@ EffectStateFactory *DedicatedStateFactory_getFactory(void); ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect); -void ALeffectState_DecRef(ALeffectState *state); - #endif diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 64297592..8f08d94a 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -206,6 +206,7 @@ struct ALCbackend; struct ALbuffer; struct ALeffect; struct ALfilter; +struct EffectState; #define DEFAULT_OUTPUT_RATE (44100) @@ -755,7 +756,7 @@ typedef struct AsyncEvent { ALuint param; ALchar msg[1008]; } user; - struct ALeffectState *EffectState; + EffectState *mEffectState; } u; } AsyncEvent; #define ASYNC_EVENT(t) { t, { 0 } } |