aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-07-15 06:24:37 -0700
committerChris Robinson <[email protected]>2022-07-15 06:58:15 -0700
commitaf5d4fb77dd12bee2dd5c4b7feadcbab913d6290 (patch)
tree9a10efe4dd38caa17895b308ba0a42379ec824a1 /alc
parent0f4679981b575cc76158126dec7d9bdda3ba1c29 (diff)
Don't store and manage wet buffers separately
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp20
-rw-r--r--alc/context.cpp5
-rw-r--r--alc/context.h3
-rw-r--r--alc/panning.cpp41
4 files changed, 15 insertions, 54 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 4a142ca6..f9834197 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2217,13 +2217,6 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
std::unique_lock<std::mutex> proplock{context->mPropLock};
std::unique_lock<std::mutex> slotlock{context->mEffectSlotLock};
- /* Clear out unused wet buffers. */
- auto buffer_not_in_use = [](WetBufferPtr &wetbuffer) noexcept -> bool
- { return !wetbuffer->mInUse; };
- auto wetbuffer_iter = std::remove_if(context->mWetBuffers.begin(),
- 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)
{
@@ -2238,6 +2231,19 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
context->mEffectSlotClusters.end(), slot_cluster_not_in_use);
context->mEffectSlotClusters.erase(slotcluster_iter, context->mEffectSlotClusters.end());
+ /* Free all wet buffers. Any in use will be reallocated with an updated
+ * configuration in aluInitEffectPanning.
+ */
+ for(auto&& slots : context->mEffectSlotClusters)
+ {
+ for(size_t i{0};i < ContextBase::EffectSlotClusterSize;++i)
+ {
+ slots[i].mWetBuffer.clear();
+ slots[i].mWetBuffer.shrink_to_fit();
+ slots[i].Wet.Buffer = {};
+ }
+ }
+
if(ALeffectslot *slot{context->mDefaultSlot.get()})
{
aluInitEffectPanning(slot->mSlot, context);
diff --git a/alc/context.cpp b/alc/context.cpp
index 4d04526a..3dbeaea0 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -128,9 +128,6 @@ 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
@@ -139,8 +136,6 @@ ALCcontext::~ALCcontext()
WARN("%zu AuxiliaryEffectSlot%s not deleted\n", count, (count==1)?"":"s");
mEffectSlotList.clear();
mNumEffectSlots = 0;
-
- mEffectSlotClusters.clear();
}
void ALCcontext::init()
diff --git a/alc/context.h b/alc/context.h
index 9095b00a..3046c8b7 100644
--- a/alc/context.h
+++ b/alc/context.h
@@ -68,9 +68,6 @@ struct EffectSlotSubList {
struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
const al::intrusive_ptr<ALCdevice> mALDevice;
- /* Wet buffers used by effect slots. */
- al::vector<WetBufferPtr> mWetBuffers;
-
bool mPropsDirty{true};
bool mDeferUpdates{false};
diff --git a/alc/panning.cpp b/alc/panning.cpp
index 32ccd080..d79d672e 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -1129,49 +1129,12 @@ void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context)
DeviceBase *device{context->mDevice};
const size_t count{AmbiChannelsFromOrder(device->mAmbiOrder)};
- auto wetbuffer_iter = context->mWetBuffers.end();
- if(slot->mWetBuffer)
- {
- /* If the effect slot already has a wet buffer attached, allocate a new
- * one in its place.
- */
- wetbuffer_iter = context->mWetBuffers.begin();
- for(;wetbuffer_iter != context->mWetBuffers.end();++wetbuffer_iter)
- {
- if(wetbuffer_iter->get() == slot->mWetBuffer)
- {
- slot->mWetBuffer = nullptr;
- slot->Wet.Buffer = {};
-
- *wetbuffer_iter = WetBufferPtr{new(FamCount(count)) WetBuffer{count}};
-
- break;
- }
- }
- }
- if(wetbuffer_iter == context->mWetBuffers.end())
- {
- /* Otherwise, search for an unused wet buffer. */
- wetbuffer_iter = context->mWetBuffers.begin();
- for(;wetbuffer_iter != context->mWetBuffers.end();++wetbuffer_iter)
- {
- if(!(*wetbuffer_iter)->mInUse)
- break;
- }
- if(wetbuffer_iter == context->mWetBuffers.end())
- {
- /* Otherwise, allocate a new one to use. */
- context->mWetBuffers.emplace_back(WetBufferPtr{new(FamCount(count)) WetBuffer{count}});
- wetbuffer_iter = context->mWetBuffers.end()-1;
- }
- }
- WetBuffer *wetbuffer{slot->mWetBuffer = wetbuffer_iter->get()};
- wetbuffer->mInUse = true;
+ slot->mWetBuffer.resize(count);
auto acnmap_begin = AmbiIndex::FromACN().begin();
auto iter = std::transform(acnmap_begin, acnmap_begin + count, slot->Wet.AmbiMap.begin(),
[](const uint8_t &acn) noexcept -> BFChannelConfig
{ return BFChannelConfig{1.0f, acn}; });
std::fill(iter, slot->Wet.AmbiMap.end(), BFChannelConfig{});
- slot->Wet.Buffer = wetbuffer->mBuffer;
+ slot->Wet.Buffer = slot->mWetBuffer;
}