mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
VST3 Client: Allow setBusArrangements to succeed if called during setActive
This commit is contained in:
parent
0cb135a2ce
commit
78a0fc6fa5
1 changed files with 20 additions and 15 deletions
|
|
@ -2551,26 +2551,31 @@ public:
|
|||
//==============================================================================
|
||||
tresult PLUGIN_API setActive (TBool state) override
|
||||
{
|
||||
active = (state != 0);
|
||||
const auto willBeActive = (state != 0);
|
||||
|
||||
if (! state)
|
||||
active = false;
|
||||
// Some hosts may call setBusArrangements in response to calls made during prepareToPlay
|
||||
// or releaseResources. Specifically, Wavelab 11.1 calls setBusArrangements in the same
|
||||
// call stack when the AudioProcessor calls setLatencySamples inside prepareToPlay.
|
||||
// In order for setBusArrangements to return successfully, the plugin must not be activated
|
||||
// until after prepareToPlay has completely finished.
|
||||
const ScopeGuard scope { [&] { active = willBeActive; } };
|
||||
|
||||
if (willBeActive)
|
||||
{
|
||||
getPluginInstance().releaseResources();
|
||||
const auto sampleRate = processSetup.sampleRate > 0.0
|
||||
? processSetup.sampleRate
|
||||
: getPluginInstance().getSampleRate();
|
||||
|
||||
const auto bufferSize = processSetup.maxSamplesPerBlock > 0
|
||||
? (int) processSetup.maxSamplesPerBlock
|
||||
: getPluginInstance().getBlockSize();
|
||||
|
||||
preparePlugin (sampleRate, bufferSize, CallPrepareToPlay::yes);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto sampleRate = getPluginInstance().getSampleRate();
|
||||
auto bufferSize = getPluginInstance().getBlockSize();
|
||||
|
||||
sampleRate = processSetup.sampleRate > 0.0
|
||||
? processSetup.sampleRate
|
||||
: sampleRate;
|
||||
|
||||
bufferSize = processSetup.maxSamplesPerBlock > 0
|
||||
? (int) processSetup.maxSamplesPerBlock
|
||||
: bufferSize;
|
||||
|
||||
preparePlugin (sampleRate, bufferSize, CallPrepareToPlay::yes);
|
||||
getPluginInstance().releaseResources();
|
||||
}
|
||||
|
||||
return kResultOk;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue