diff options
author | Chris Robinson <[email protected]> | 2020-08-22 22:45:26 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-08-24 14:09:26 -0700 |
commit | ff5c9d1c15302473be7e0ea3b5da2643549e8d6c (patch) | |
tree | 9e8e1f07cd2a1c28fd3bc75f41f1cd552c570079 /al | |
parent | 01f76f2b671c21c976b1f88c18845a53000afa6b (diff) |
Use an intrusive_ptr for ALeffectslotProps::State
Diffstat (limited to 'al')
-rw-r--r-- | al/auxeffectslot.cpp | 11 | ||||
-rw-r--r-- | al/auxeffectslot.h | 3 |
2 files changed, 3 insertions, 11 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 7c20ec64..00da51f6 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -640,7 +640,6 @@ ALeffectslot::~ALeffectslot() ALeffectslotProps *props{Params.Update.load()}; if(props) { - if(props->State) props->State->release(); TRACE("Freed unapplied AuxiliaryEffectSlot update %p\n", decltype(std::declval<void*>()){props}); delete props; @@ -707,8 +706,6 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context) ALeffectslotProps *props{context->mFreeEffectslotProps.load()}; while(props) { - if(props->State) - props->State->release(); props->State = nullptr; props = props->next.load(std::memory_order_relaxed); } @@ -741,9 +738,8 @@ void ALeffectslot::updateProps(ALCcontext *context) /* Swap out any stale effect state object there may be in the container, to * delete it. */ - EffectState *oldstate{props->State}; Effect.State->add_ref(); - props->State = Effect.State; + props->State.reset(Effect.State); /* Set the new container for updating internal parameters. */ props = Params.Update.exchange(props, std::memory_order_acq_rel); @@ -752,14 +748,9 @@ void ALeffectslot::updateProps(ALCcontext *context) /* If there was an unused update container, put it back in the * freelist. */ - if(props->State) - props->State->release(); props->State = nullptr; AtomicReplaceHead(context->mFreeEffectslotProps, props); } - - if(oldstate) - oldstate->release(); } void UpdateAllEffectSlotProps(ALCcontext *context) diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index 5f1e6aa8..12411ede 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -12,6 +12,7 @@ #include "almalloc.h" #include "atomic.h" #include "effects/base.h" +#include "intrusive_ptr.h" #include "vector.h" struct ALeffect; @@ -29,7 +30,7 @@ struct ALeffectslotProps { ALenum Type; EffectProps Props; - EffectState *State; + al::intrusive_ptr<EffectState> State; std::atomic<ALeffectslotProps*> next; |