diff options
author | Chris Robinson <[email protected]> | 2022-07-15 04:28:13 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-07-15 04:28:13 -0700 |
commit | 0b9fc03545f7418be89bb9a8901b342ce84a5f67 (patch) | |
tree | 38e5cbf58a3444938116867a8c78e7fc6f7d280b /al/auxeffectslot.cpp | |
parent | 07c2e786f5959f15c50f380f347d345e59218af2 (diff) |
Dynamically allocate EffectSlot objects
Diffstat (limited to 'al/auxeffectslot.cpp')
-rw-r--r-- | al/auxeffectslot.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 04e7720d..25814e83 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -143,7 +143,7 @@ void AddActiveEffectSlots(const al::span<ALeffectslot*> auxslots, ALCcontext *co */ EffectSlotArray *newarray = EffectSlot::CreatePtrArray(newcount); auto slotiter = std::transform(auxslots.begin(), auxslots.end(), newarray->begin(), - [](ALeffectslot *auxslot) noexcept { return &auxslot->mSlot; }); + [](ALeffectslot *auxslot) noexcept { return auxslot->mSlot; }); std::copy(curarray->begin(), curarray->end(), slotiter); /* Remove any duplicates (first instance of each will be kept). */ @@ -191,7 +191,7 @@ void RemoveActiveEffectSlots(const al::span<ALeffectslot*> auxslots, ALCcontext for(const ALeffectslot *auxslot : auxslots) { auto slot_match = [auxslot](EffectSlot *slot) noexcept -> bool - { return (slot == &auxslot->mSlot); }; + { return (slot == auxslot->mSlot); }; new_end = std::remove_if(newarray->begin(), new_end, slot_match); } @@ -279,7 +279,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context) ASSUME(slidx < 64); ALeffectslot *slot{al::construct_at(sublist->EffectSlots + slidx)}; - aluInitEffectPanning(&slot->mSlot, context); + aluInitEffectPanning(slot->mSlot, context); /* Add 1 to avoid source ID 0. */ slot->id = ((lidx<<6) | slidx) + 1; @@ -914,7 +914,9 @@ ALeffectslot::ALeffectslot() al::intrusive_ptr<EffectState> state{factory->create()}; Effect.State = state; - mSlot.mEffectState = state.release(); + + mSlot = new EffectSlot{}; + mSlot->mEffectState = state.release(); } ALeffectslot::~ALeffectslot() @@ -926,7 +928,7 @@ ALeffectslot::~ALeffectslot() DecrementRef(Buffer->ref); Buffer = nullptr; - EffectSlotProps *props{mSlot.Update.exchange(nullptr)}; + EffectSlotProps *props{mSlot->Update.exchange(nullptr)}; if(props) { TRACE("Freed unapplied AuxiliaryEffectSlot update %p\n", @@ -934,8 +936,9 @@ ALeffectslot::~ALeffectslot() delete props; } - if(mSlot.mEffectState) - mSlot.mEffectState->release(); + if(mSlot->mEffectState) + mSlot->mEffectState->release(); + delete mSlot; } ALenum ALeffectslot::initEffect(ALenum effectType, const EffectProps &effectProps, @@ -997,14 +1000,14 @@ void ALeffectslot::updateProps(ALCcontext *context) /* Copy in current property values. */ props->Gain = Gain; props->AuxSendAuto = AuxSendAuto; - props->Target = Target ? &Target->mSlot : nullptr; + props->Target = Target ? Target->mSlot : nullptr; props->Type = Effect.Type; props->Props = Effect.Props; props->State = Effect.State; /* Set the new container for updating internal parameters. */ - props = mSlot.Update.exchange(props, std::memory_order_acq_rel); + props = mSlot->Update.exchange(props, std::memory_order_acq_rel); if(props) { /* If there was an unused update container, put it back in the |