void SymbiosisComponent::updateMaxFramesPerSlice(int newFramesPerSlice) {
if (maxFramesPerSlice != newFramesPerSlice) {
maxFramesPerSlice = newFramesPerSlice;
reallocateIOBuffers();
propertyChanged(kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0);
vst->setBlockSize(maxFramesPerSlice);
}
}
the "if" is what causes this behavior, as the maxFramesPerSlice default value is 4096 (see the kDefaultMaxFramesPerSlice static constant), so the expression will evaluate to false and the setBlockSize call will never happen.
In my case, if the setBlockSize method is never called before processing, my plug-in is left in a partially initialized state and crashes. Am I wrong in supposing that setBlockSize must be called at least once before calling processReplacing(...)?
What's supposed to be the best way to fix this issue?
1) change the code to:
void SymbiosisComponent::updateMaxFramesPerSlice(int newFramesPerSlice) {
if (maxFramesPerSlice != newFramesPerSlice) {
maxFramesPerSlice = newFramesPerSlice;
reallocateIOBuffers();
propertyChanged(kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0);
}
if (vst->getBlockSize() != maxFramesPerSlice)
vst->setBlockSize(maxFramesPerSlice);
}
2) same as 1), but without the if (vst->getBlockSize() != maxFramesPerSlice) check. We basically let the VST implementation (and not Symbiosis) decide whether or not do something with the supplied block size when it's identical to the current one
3) Perform a check on the process calls of the VST implementation and eventually call setBlockSize there if it has never been called before (I really hate this solution, as it may lead to performing memory allocations on the audio thread, plus the block size passed on the process method may be different (smaller) from the one set during the setBlockSize call, so I must also perform some kind of rounding which may still cause a new call to setBlockSize in the successive process calls, if my block size guess is wrong...)
Thanks in advance,
Federico Berti - Ignite Amps