Only initialize VST2 audio buffers on activation

Ardour apparently always calls `effMainsChanged()` with a value argument
of 0 when unloading the plugin, regardless of whether it has actually
initialized audio processing before that point.
This commit is contained in:
Robbert van der Helm
2021-06-12 20:15:20 +02:00
parent 67e754feb5
commit 8a754b08cf
2 changed files with 23 additions and 9 deletions
+5 -1
View File
@@ -470,7 +470,11 @@ void Vst2Bridge::run() {
// the same buffers. We cannot use `Vst2Bridge::dispatch_wrapper()`
// for this because we need to directly return payload data that
// won't be visible to the plugin at all.
if (event.opcode == effMainsChanged) {
// NOTE: Ardour will call `effMainsChanged()` with a value of 1
// unconditionally when unloading a plugin, even when audio
// playback has never been initialized (and `effSetBlockSize`
// has never been called)
if (event.opcode == effMainsChanged && event.value == 1) {
// Returning another result this way is a bit ugly, but sadly
// optimizations have never made code nicer to read
return Vst2EventResult{.return_value = result.return_value,