mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
VST3: Avoid potential memory allocations during buffer remapping
This commit is contained in:
parent
ca8b5f7483
commit
1e902bcdee
1 changed files with 15 additions and 3 deletions
|
|
@ -1119,9 +1119,17 @@ public:
|
|||
{
|
||||
mappings = std::move (arrangements);
|
||||
|
||||
floatBusMap .resize (mappings.size());
|
||||
doubleBusMap.resize (mappings.size());
|
||||
busBuffers .resize (mappings.size());
|
||||
const auto numBuses = mappings.size();
|
||||
floatBusMap .resize (numBuses);
|
||||
doubleBusMap.resize (numBuses);
|
||||
busBuffers .resize (numBuses);
|
||||
|
||||
for (auto [index, busMap] : enumerate (mappings, size_t{}))
|
||||
{
|
||||
const auto numChannels = busMap.size();
|
||||
floatBusMap [index].reserve (numChannels);
|
||||
doubleBusMap[index].reserve (numChannels);
|
||||
}
|
||||
}
|
||||
|
||||
/* Applies the mapping to an AudioBuffer using JUCE channel layout. */
|
||||
|
|
@ -1157,6 +1165,10 @@ private:
|
|||
const ChannelMapping& busMap,
|
||||
int channelStartOffset) const
|
||||
{
|
||||
// If this is hit, we may be about to allocate memory. Ideally, this should have been
|
||||
// allocated in prepare().
|
||||
jassert (busMap.size() <= bus.capacity());
|
||||
|
||||
bus.clear();
|
||||
|
||||
for (size_t i = 0; i < busMap.size(); ++i)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue