1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AU Host: Improve allocation checks

If the block size changes from block to block, then it's possible for
inputBuffer to be smaller than buffer, but for buffer to be smaller than
the initially-allocated size of inputBuffer.
This commit is contained in:
reuk 2022-02-15 13:40:03 +00:00
parent e1a7fe671a
commit fb1f94767d
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -1101,8 +1101,9 @@ public:
inMapping .setUpMapping (audioUnit, true);
outMapping.setUpMapping (audioUnit, false);
inputBuffer.setSize (jmax (getTotalNumInputChannels(), getTotalNumOutputChannels()),
estimatedSamplesPerBlock);
preparedChannels = jmax (getTotalNumInputChannels(), getTotalNumOutputChannels());
preparedSamples = estimatedSamplesPerBlock;
inputBuffer.setSize (preparedChannels, preparedSamples);
}
}
@ -1130,8 +1131,8 @@ public:
void processAudio (AudioBuffer<float>& buffer, MidiBuffer& midiMessages, bool processBlockBypassedCalled)
{
// If these are hit, we might allocate in the process block!
jassert (buffer.getNumChannels() <= inputBuffer.getNumChannels());
jassert (buffer.getNumSamples() <= inputBuffer.getNumSamples());
jassert (buffer.getNumChannels() <= preparedChannels);
jassert (buffer.getNumSamples() <= preparedSamples);
// Copy the input buffer to guard against the case where a bus has more output channels
// than input channels, so rendering the output for that bus might stamp over the input
// to the following bus.
@ -1724,7 +1725,7 @@ private:
AudioBuffer<float> inputBuffer;
Array<Array<AudioChannelSet>> supportedInLayouts, supportedOutLayouts;
int numChannelInfos;
int numChannelInfos, preparedChannels = 0, preparedSamples = 0;
HeapBlock<AUChannelInfo> channelInfos;
AudioUnit audioUnit;