diff options
author | Chris Robinson <[email protected]> | 2022-07-15 06:14:25 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-07-15 06:14:25 -0700 |
commit | 0f4679981b575cc76158126dec7d9bdda3ba1c29 (patch) | |
tree | 77e9176befdeb963e7dd791fc50df3db34f789bc /alc | |
parent | 0b9fc03545f7418be89bb9a8901b342ce84a5f67 (diff) |
Allocate EffectSlots in clusters
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alc.cpp | 14 | ||||
-rw-r--r-- | alc/context.cpp | 7 |
2 files changed, 20 insertions, 1 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 3ce14dac..4a142ca6 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2224,6 +2224,20 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) context->mWetBuffers.end(), buffer_not_in_use); context->mWetBuffers.erase(wetbuffer_iter, context->mWetBuffers.end()); + /* Clear out unused effect slot clusters. */ + auto slot_cluster_not_in_use = [](ContextBase::EffectSlotCluster &cluster) + { + for(size_t i{0};i < ContextBase::EffectSlotClusterSize;++i) + { + if(cluster[i].InUse) + return false; + } + return true; + }; + auto slotcluster_iter = std::remove_if(context->mEffectSlotClusters.begin(), + context->mEffectSlotClusters.end(), slot_cluster_not_in_use); + context->mEffectSlotClusters.erase(slotcluster_iter, context->mEffectSlotClusters.end()); + if(ALeffectslot *slot{context->mDefaultSlot.get()}) { aluInitEffectPanning(slot->mSlot, context); diff --git a/alc/context.cpp b/alc/context.cpp index 456e42da..4d04526a 100644 --- a/alc/context.cpp +++ b/alc/context.cpp @@ -128,6 +128,9 @@ ALCcontext::~ALCcontext() eax_uninitialize(); #endif // ALSOFT_EAX + /* Delete the ALeffectslots, so the EffectSlots can be deleted before the + * WetBuffers are deleted. + */ mDefaultSlot = nullptr; count = std::accumulate(mEffectSlotList.cbegin(), mEffectSlotList.cend(), size_t{0u}, [](size_t cur, const EffectSlotSubList &sublist) noexcept -> size_t @@ -136,13 +139,15 @@ ALCcontext::~ALCcontext() WARN("%zu AuxiliaryEffectSlot%s not deleted\n", count, (count==1)?"":"s"); mEffectSlotList.clear(); mNumEffectSlots = 0; + + mEffectSlotClusters.clear(); } void ALCcontext::init() { if(sDefaultEffect.type != AL_EFFECT_NULL && mDevice->Type == DeviceType::Playback) { - mDefaultSlot = std::make_unique<ALeffectslot>(); + mDefaultSlot = std::make_unique<ALeffectslot>(this); aluInitEffectPanning(mDefaultSlot->mSlot, this); } |