From a6bd53c4e1de084d93541f23d391154d7949b678 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 24 Aug 2020 20:34:50 -0700 Subject: Store a reference to the effect buffer as an active property --- al/auxeffectslot.cpp | 8 +++++--- al/auxeffectslot.h | 2 ++ al/event.cpp | 5 +++++ al/event.h | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) (limited to 'al') diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 88512bef..790db24f 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -702,6 +702,8 @@ ALeffectslot::~ALeffectslot() if(Params.mEffectState) Params.mEffectState->release(); + if(Params.mEffectBuffer) + Params.mEffectBuffer->release(); } ALenum ALeffectslot::init() @@ -764,6 +766,7 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context) while(props) { props->State = nullptr; + props->Buffer = nullptr; props = props->next.load(std::memory_order_relaxed); } @@ -792,10 +795,8 @@ void ALeffectslot::updateProps(ALCcontext *context) props->Type = Effect.Type; props->Props = Effect.Props; - /* Swap out any stale effect state object there may be in the container, to - * delete it. - */ props->State = Effect.State; + props->Buffer = Effect.Buffer; /* Set the new container for updating internal parameters. */ props = Params.Update.exchange(props, std::memory_order_acq_rel); @@ -805,6 +806,7 @@ void ALeffectslot::updateProps(ALCcontext *context) * freelist. */ props->State = nullptr; + props->Buffer = nullptr; AtomicReplaceHead(context->mFreeEffectslotProps, props); } } diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index de640b58..79373f45 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -32,6 +32,7 @@ struct ALeffectslotProps { EffectProps Props; al::intrusive_ptr State; + al::intrusive_ptr Buffer; std::atomic next; @@ -67,6 +68,7 @@ struct ALeffectslot { ALenum EffectType{AL_EFFECT_NULL}; EffectProps mEffectProps{}; EffectState *mEffectState{nullptr}; + EffectBufferBase *mEffectBuffer{nullptr}; float RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */ float DecayTime{0.0f}; diff --git a/al/event.cpp b/al/event.cpp index cd8ea7c2..6c004ef3 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -60,6 +60,11 @@ static int EventThread(ALCcontext *context) evt.u.mEffectState->release(); continue; } + if(evt.EnumType == EventType_ReleaseEffectBuffer) + { + evt.u.mEffectBuffer->release(); + continue; + } ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_acquire)}; if(!context->mEventCb) continue; diff --git a/al/event.h b/al/event.h index 44d9306f..4717865b 100644 --- a/al/event.h +++ b/al/event.h @@ -6,6 +6,7 @@ #include "almalloc.h" +struct EffectBufferBase; struct EffectState; @@ -23,6 +24,7 @@ enum { /* Internal events. */ EventType_ReleaseEffectState = 65536, + EventType_ReleaseEffectBuffer, }; struct AsyncEvent { @@ -44,6 +46,7 @@ struct AsyncEvent { ALchar msg[232]; } user; EffectState *mEffectState; + EffectBufferBase *mEffectBuffer; } u{}; AsyncEvent() noexcept = default; -- cgit v1.2.3