Further reduce allocations by reusing responses

On the plugin's side, still need to do a lot of work on the Wine side of
things.
This commit is contained in:
Robbert van der Helm
2021-05-07 17:00:43 +02:00
parent fcaac219a6
commit 671587f981
5 changed files with 49 additions and 6 deletions
@@ -220,12 +220,15 @@ Vst3PluginProxyImpl::process(Steinberg::Vst::ProcessData& data) {
process_request.data.repopulate(data);
process_request.new_realtime_priority = new_realtime_priority;
ProcessResponse response = bridge.send_audio_processor_message(
MessageReference<YaAudioProcessor::Process>(process_request));
// We'll also receive the response into an existing object so we can also
// avoid heap allocations there
bridge.receive_audio_processor_message_into(
MessageReference<YaAudioProcessor::Process>(process_request),
process_response);
response.output_data.write_back_outputs(data);
process_response.output_data.write_back_outputs(data);
return response.result;
return process_response.result;
}
uint32 PLUGIN_API Vst3PluginProxyImpl::getTailSamples() {
@@ -489,6 +489,13 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
*/
YaAudioProcessor::Process process_request;
/**
* The response object we'll get in return when we send the
* `process_request` object above to the Wine plugin host. This object also
* contains heap data, so we also want to reuse this.
*/
YaAudioProcessor::ProcessResponse process_response;
// Caches
/**
+15
View File
@@ -121,6 +121,21 @@ class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
object, std::pair<Vst3Logger&, bool>(logger, true));
}
/**
* Send an `IAudioProcessor` or `IComponent` control message to a specific
* plugin instance, receiving the results into an existing object. This is
* similar to the `send_audio_processor_message()` above, but this lets us
* avoid allocations in response objects that contain heap data.
*/
template <typename T>
typename T::Response& receive_audio_processor_message_into(
const T& object,
typename T::Response& response_object) {
return sockets.receive_audio_processor_message_into(
object, response_object,
std::pair<Vst3Logger&, bool>(logger, true));
}
/**
* The logging facility used for this instance of yabridge. Wraps around
* `PluginBridge::generic_logger`.