Use an intrusive_ptr to hold on to the EffectState
parent
f35eb64619
commit
339465c91f
|
@ -917,7 +917,7 @@ ALeffectslot::ALeffectslot(ALCcontext *context)
|
|||
|
||||
mSlot = context->getEffectSlot();
|
||||
mSlot->InUse = true;
|
||||
mSlot->mEffectState = state.release();
|
||||
mSlot->mEffectState = std::move(state);
|
||||
}
|
||||
|
||||
ALeffectslot::~ALeffectslot()
|
||||
|
@ -929,16 +929,14 @@ ALeffectslot::~ALeffectslot()
|
|||
DecrementRef(Buffer->ref);
|
||||
Buffer = nullptr;
|
||||
|
||||
EffectSlotProps *props{mSlot->Update.exchange(nullptr)};
|
||||
if(props)
|
||||
if(EffectSlotProps *props{mSlot->Update.exchange(nullptr)})
|
||||
{
|
||||
TRACE("Freed unapplied AuxiliaryEffectSlot update %p\n",
|
||||
decltype(std::declval<void*>()){props});
|
||||
delete props;
|
||||
}
|
||||
|
||||
if(mSlot->mEffectState)
|
||||
mSlot->mEffectState->release();
|
||||
mSlot->mEffectState = nullptr;
|
||||
mSlot->InUse = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -444,8 +444,8 @@ bool CalcEffectSlotParams(EffectSlot *slot, EffectSlot **sorted_slots, ContextBa
|
|||
}
|
||||
|
||||
EffectState *state{props->State.release()};
|
||||
EffectState *oldstate{slot->mEffectState};
|
||||
slot->mEffectState = state;
|
||||
EffectState *oldstate{slot->mEffectState.release()};
|
||||
slot->mEffectState.reset(state);
|
||||
|
||||
/* Only release the old state if it won't get deleted, since we can't be
|
||||
* deleting/freeing anything in the mixer.
|
||||
|
@ -1775,7 +1775,7 @@ void ProcessContexts(DeviceBase *device, const uint SamplesToDo)
|
|||
|
||||
for(const EffectSlot *slot : sorted_slots)
|
||||
{
|
||||
EffectState *state{slot->mEffectState};
|
||||
EffectState *state{slot->mEffectState.get()};
|
||||
state->process(SamplesToDo, slot->Wet.Buffer, state->mOutTarget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ struct EffectSlot {
|
|||
|
||||
EffectSlotType EffectType{EffectSlotType::None};
|
||||
EffectProps mEffectProps{};
|
||||
EffectState *mEffectState{nullptr};
|
||||
al::intrusive_ptr<EffectState> mEffectState;
|
||||
|
||||
float RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */
|
||||
float DecayTime{0.0f};
|
||||
|
|
Loading…
Reference in New Issue