aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-07-15 04:28:13 -0700
committerChris Robinson <[email protected]>2022-07-15 04:28:13 -0700
commit0b9fc03545f7418be89bb9a8901b342ce84a5f67 (patch)
tree38e5cbf58a3444938116867a8c78e7fc6f7d280b
parent07c2e786f5959f15c50f380f347d345e59218af2 (diff)
Dynamically allocate EffectSlot objects
-rw-r--r--al/auxeffectslot.cpp21
-rw-r--r--al/auxeffectslot.h2
-rw-r--r--al/source.cpp4
-rw-r--r--alc/alc.cpp4
-rw-r--r--alc/context.cpp4
-rw-r--r--core/effectslot.h2
6 files changed, 20 insertions, 17 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
diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h
index df760117..8b80a2d4 100644
--- a/al/auxeffectslot.h
+++ b/al/auxeffectslot.h
@@ -63,7 +63,7 @@ struct ALeffectslot {
RefCount ref{0u};
- EffectSlot mSlot;
+ EffectSlot *mSlot{nullptr};
/* Self ID */
ALuint id{};
diff --git a/al/source.cpp b/al/source.cpp
index 88eeba99..e5241a39 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -160,7 +160,7 @@ void UpdateSourceProps(const ALsource *source, Voice *voice, ALCcontext *context
auto copy_send = [](const ALsource::SendData &srcsend) noexcept -> VoiceProps::SendData
{
VoiceProps::SendData ret{};
- ret.Slot = srcsend.Slot ? &srcsend.Slot->mSlot : nullptr;
+ ret.Slot = srcsend.Slot ? srcsend.Slot->mSlot : nullptr;
ret.Gain = srcsend.Gain;
ret.GainHF = srcsend.GainHF;
ret.HFReference = srcsend.HFReference;
@@ -170,7 +170,7 @@ void UpdateSourceProps(const ALsource *source, Voice *voice, ALCcontext *context
};
std::transform(source->Send.cbegin(), source->Send.cend(), props->Send, copy_send);
if(!props->Send[0].Slot && context->mDefaultSlot)
- props->Send[0].Slot = &context->mDefaultSlot->mSlot;
+ props->Send[0].Slot = context->mDefaultSlot->mSlot;
/* Set the new container for updating internal parameters. */
props = voice->mUpdate.exchange(props, std::memory_order_acq_rel);
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 07c9372c..3ce14dac 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2226,7 +2226,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
if(ALeffectslot *slot{context->mDefaultSlot.get()})
{
- aluInitEffectPanning(&slot->mSlot, context);
+ aluInitEffectPanning(slot->mSlot, context);
EffectState *state{slot->Effect.State.get()};
state->mOutTarget = device->Dry.Buffer;
@@ -2245,7 +2245,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
ALeffectslot *slot{sublist.EffectSlots + idx};
usemask &= ~(1_u64 << idx);
- aluInitEffectPanning(&slot->mSlot, context);
+ aluInitEffectPanning(slot->mSlot, context);
EffectState *state{slot->Effect.State.get()};
state->mOutTarget = device->Dry.Buffer;
diff --git a/alc/context.cpp b/alc/context.cpp
index a6b56d1d..456e42da 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -143,7 +143,7 @@ void ALCcontext::init()
if(sDefaultEffect.type != AL_EFFECT_NULL && mDevice->Type == DeviceType::Playback)
{
mDefaultSlot = std::make_unique<ALeffectslot>();
- aluInitEffectPanning(&mDefaultSlot->mSlot, this);
+ aluInitEffectPanning(mDefaultSlot->mSlot, this);
}
EffectSlotArray *auxslots;
@@ -152,7 +152,7 @@ void ALCcontext::init()
else
{
auxslots = EffectSlot::CreatePtrArray(1);
- (*auxslots)[0] = &mDefaultSlot->mSlot;
+ (*auxslots)[0] = mDefaultSlot->mSlot;
mDefaultSlot->mState = SlotState::Playing;
}
mActiveAuxSlots.store(auxslots, std::memory_order_relaxed);
diff --git a/core/effectslot.h b/core/effectslot.h
index 8b7b977c..92fd1961 100644
--- a/core/effectslot.h
+++ b/core/effectslot.h
@@ -82,7 +82,7 @@ struct EffectSlot {
static EffectSlotArray *CreatePtrArray(size_t count) noexcept;
- DISABLE_ALLOC()
+ DEF_NEWDEL(EffectSlot)
};
#endif /* CORE_EFFECTSLOT_H */