From 6231ab7816b7bf3f2f71ff824bc81f521edee259 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 6 May 2021 16:34:23 +0200 Subject: [PATCH] Reuse YaProcessData object on the plugin side Well, kind of. This doesn't do anything yet since the default assignment operator will just destroy and recreate objects as normal. --- src/plugin/bridges/vst3-impls/plugin-proxy.cpp | 9 ++++++--- src/plugin/bridges/vst3-impls/plugin-proxy.h | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index 34411f05..3fe48d6a 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -186,12 +186,15 @@ Vst3PluginProxyImpl::process(Steinberg::Vst::ProcessData& data) { last_audio_thread_priority_synchronization = now; } - // TODO: Check whether reusing a `YaProcessData` object make a difference in - // terms of performance + // TODO: Document + // TODO: Actually repopulate `process_data` with new data, right now this + // assignment just destroys the old object and creates a new object. + process_data = data; + ProcessResponse response = bridge.send_audio_processor_message(YaAudioProcessor::Process{ .instance_id = instance_id(), - .data = data, + .data = process_data, .new_realtime_priority = new_realtime_priority}); response.output_data.write_back_outputs(data); diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.h b/src/plugin/bridges/vst3-impls/plugin-proxy.h index ccd60e7c..c8b228b4 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.h +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.h @@ -490,6 +490,12 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { */ std::atomic_size_t current_context_menu_id; + /** + * We'll reuse this process data object and simply fill the objects + * contained with new data to avoid allocations during audio processing. + */ + YaProcessData process_data; + // Caches /**