aboutsummaryrefslogtreecommitdiffstats
path: root/core/context.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-07-15 06:14:25 -0700
committerChris Robinson <[email protected]>2022-07-15 06:14:25 -0700
commit0f4679981b575cc76158126dec7d9bdda3ba1c29 (patch)
tree77e9176befdeb963e7dd791fc50df3db34f789bc /core/context.cpp
parent0b9fc03545f7418be89bb9a8901b342ce84a5f67 (diff)
Allocate EffectSlots in clusters
Diffstat (limited to 'core/context.cpp')
-rw-r--r--core/context.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/context.cpp b/core/context.cpp
index 39fd8522..111802d9 100644
--- a/core/context.cpp
+++ b/core/context.cpp
@@ -136,3 +136,24 @@ void ContextBase::allocVoices(size_t addcount)
delete oldvoices;
}
}
+
+
+EffectSlot *ContextBase::getEffectSlot()
+{
+ for(auto& cluster : mEffectSlotClusters)
+ {
+ for(size_t i{0};i < EffectSlotClusterSize;++i)
+ {
+ if(!cluster[i].InUse)
+ return &cluster[i];
+ }
+ }
+
+ if(1 >= std::numeric_limits<int>::max()/EffectSlotClusterSize - mEffectSlotClusters.size())
+ throw std::runtime_error{"Allocating too many effect slots"};
+ const size_t totalcount{(mEffectSlotClusters.size()+1) * EffectSlotClusterSize};
+ TRACE("Increasing allocated effect slots to %zu\n", totalcount);
+
+ mEffectSlotClusters.emplace_back(std::make_unique<EffectSlot[]>(EffectSlotClusterSize));
+ return getEffectSlot();
+}