From 10b79307794767fff2ba2e176153c6c76d1576a0 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 30 Jan 2021 01:42:20 +0100 Subject: [PATCH] Also clear bus cache on IAudioProcessor::setActive Now we need a workaround for our REAPER workaround because REAPER doesn't follow the audio processing workflow diagram, amazing! --- src/plugin/bridges/vst3-impls/plugin-proxy.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index 373edb58..87233b6d 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -310,6 +310,22 @@ Vst3PluginProxyImpl::activateBus(Steinberg::Vst::MediaType type, } tresult PLUGIN_API Vst3PluginProxyImpl::setActive(TBool state) { + // HACK: Even though we have implemented this cache specifically for REAPER, + // REAPER mixes up `IComponent::setActive` and + // `IAudioProcessor::setProcessing`. `IAudioProcessor::setProcessing` + // is called before setting up bus arrangements, so without this the + // cache would be filled with default data rather than the bus + // arrangement chosen by REAPER. So now our workaround to get + // acceptable performance in REAPER needs a workaround of its ownn. + // Great! + // TODO: We probably also need a reset on + // `IComponentHandler::restartComponent()` + if (state) { + processing_bus_cache.emplace(); + } else { + processing_bus_cache.reset(); + } + return bridge.send_audio_processor_message( YaComponent::SetActive{.instance_id = instance_id(), .state = state}); }