diff --git a/CHANGELOG.md b/CHANGELOG.md index 8de0759b..889cb869 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,12 @@ Versioning](https://semver.org/spec/v2.0.0.html). has been rewritten using both shared memory and message passing to reduce memory copies to a minimum. With this change the DSP load overhead during audio processing should now be as low as it's going to get. +- Prevented some more potential unnecessary memory operations during yabridge's + communication. The underlying serialization library was recreating some + objects even when that wasn't needed, which could in theory result in memory + allocations in certain situations. This is related to the similar issue that + got fixed with yabridge 3.3.0. A fix for this issue has also been upstreamed + to the library. ### Fixed diff --git a/src/common/configuration.h b/src/common/configuration.h index c9b91af4..b3da404d 100644 --- a/src/common/configuration.h +++ b/src/common/configuration.h @@ -21,11 +21,11 @@ #endif #include -#include #include #include #include "bitsery/ext/boost-path.h" +#include "bitsery/ext/in-place-optional.h" /** * An object that's used to provide plugin-specific configuration. Right now @@ -197,23 +197,23 @@ class Configuration { template void serialize(S& s) { - s.ext(group, bitsery::ext::StdOptional(), + s.ext(group, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.text1b(v, 4096); }); - s.ext(disable_pipes, bitsery::ext::StdOptional(), + s.ext(disable_pipes, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.ext(v, bitsery::ext::BoostPath{}); }); s.value1b(editor_double_embed); s.value1b(editor_force_dnd); s.value1b(editor_xembed); - s.ext(frame_rate, bitsery::ext::StdOptional(), + s.ext(frame_rate, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.value4b(v); }); s.value1b(hide_daw); s.value1b(vst3_no_scaling); s.value1b(vst3_prefer_32bit); - s.ext(matched_file, bitsery::ext::StdOptional(), + s.ext(matched_file, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.ext(v, bitsery::ext::BoostPath{}); }); - s.ext(matched_pattern, bitsery::ext::StdOptional(), + s.ext(matched_pattern, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.text1b(v, 4096); }); s.container(invalid_options, 1024, diff --git a/src/common/serialization/vst2.h b/src/common/serialization/vst2.h index 0e49d494..65451f1c 100644 --- a/src/common/serialization/vst2.h +++ b/src/common/serialization/vst2.h @@ -18,13 +18,13 @@ #include -#include #include #include #include #include #include "../audio-shm.h" +#include "../bitsery/ext/in-place-optional.h" #include "../bitsery/ext/in-place-variant.h" #include "../bitsery/traits/small-vector.h" #include "../utils.h" @@ -347,7 +347,7 @@ struct Vst2EventResult { s.value8b(return_value); s.object(payload); - s.ext(value_payload, bitsery::ext::StdOptional(), + s.ext(value_payload, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.object(v); }); } }; @@ -456,7 +456,7 @@ struct Vst2Event { s.value4b(option); s.object(payload); - s.ext(value_payload, bitsery::ext::StdOptional(), + s.ext(value_payload, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.object(v); }); } }; @@ -484,7 +484,7 @@ struct ParameterResult { template void serialize(S& s) { - s.ext(value, bitsery::ext::StdOptional(), + s.ext(value, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.value4b(v); }); } }; @@ -502,7 +502,7 @@ struct Parameter { template void serialize(S& s) { s.value4b(index); - s.ext(value, bitsery::ext::StdOptional(), + s.ext(value, bitsery::ext::InPlaceOptional(), [](S& s, auto& v) { s.value4b(v); }); } }; @@ -558,10 +558,10 @@ struct Vst2ProcessRequest { s.value4b(sample_frames); s.value1b(double_precision); - s.ext(current_time_info, bitsery::ext::StdOptional{}); + s.ext(current_time_info, bitsery::ext::InPlaceOptional{}); s.value4b(current_process_level); - s.ext(new_realtime_priority, bitsery::ext::StdOptional{}, + s.ext(new_realtime_priority, bitsery::ext::InPlaceOptional{}, [](S& s, int& priority) { s.value4b(priority); }); } }; diff --git a/src/common/serialization/vst3/attribute-list.h b/src/common/serialization/vst3/attribute-list.h index 04d40350..5157502e 100644 --- a/src/common/serialization/vst3/attribute-list.h +++ b/src/common/serialization/vst3/attribute-list.h @@ -19,9 +19,9 @@ #include #include -#include #include +#include "../../bitsery/ext/in-place-optional.h" #include "base.h" #pragma GCC diagnostic push diff --git a/src/common/serialization/vst3/bstream.h b/src/common/serialization/vst3/bstream.h index fb18c374..d8e29196 100644 --- a/src/common/serialization/vst3/bstream.h +++ b/src/common/serialization/vst3/bstream.h @@ -94,11 +94,11 @@ class YaBStream : public Steinberg::IBStream, // The seek position should always be initialized at 0 s.value1b(supports_stream_attributes); - s.ext(file_name, bitsery::ext::StdOptional{}, + s.ext(file_name, bitsery::ext::InPlaceOptional{}, [](S& s, std::u16string& name) { s.text2b(name, std::extent_v); }); - s.ext(attributes, bitsery::ext::StdOptional{}); + s.ext(attributes, bitsery::ext::InPlaceOptional{}); } /** diff --git a/src/common/serialization/vst3/component-handler/component-handler-3.h b/src/common/serialization/vst3/component-handler/component-handler-3.h index 70b42a82..5b832d75 100644 --- a/src/common/serialization/vst3/component-handler/component-handler-3.h +++ b/src/common/serialization/vst3/component-handler/component-handler-3.h @@ -17,8 +17,8 @@ #pragma once #include -#include "bitsery/ext/std_optional.h" +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" #include "../context-menu-proxy.h" @@ -74,7 +74,7 @@ class YaComponentHandler3 : public Steinberg::Vst::IComponentHandler3 { template void serialize(S& s) { - s.ext(context_menu_args, bitsery::ext::StdOptional{}); + s.ext(context_menu_args, bitsery::ext::InPlaceOptional{}); } }; @@ -100,7 +100,7 @@ class YaComponentHandler3 : public Steinberg::Vst::IComponentHandler3 { template void serialize(S& s) { s.value8b(owner_instance_id); - s.ext(param_id, bitsery::ext::StdOptional{}, + s.ext(param_id, bitsery::ext::InPlaceOptional{}, [](S& s, Steinberg::Vst::ParamID& id) { s.value4b(id); }); } }; diff --git a/src/common/serialization/vst3/component-handler/component-handler-bus-activation.h b/src/common/serialization/vst3/component-handler/component-handler-bus-activation.h index 6963c616..ec0cc275 100644 --- a/src/common/serialization/vst3/component-handler/component-handler-bus-activation.h +++ b/src/common/serialization/vst3/component-handler/component-handler-bus-activation.h @@ -17,8 +17,8 @@ #pragma once #include -#include "bitsery/ext/std_optional.h" +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" #include "../context-menu-proxy.h" diff --git a/src/common/serialization/vst3/component-handler/progress.h b/src/common/serialization/vst3/component-handler/progress.h index 6ad4ed33..1d9b031e 100644 --- a/src/common/serialization/vst3/component-handler/progress.h +++ b/src/common/serialization/vst3/component-handler/progress.h @@ -18,9 +18,9 @@ #include +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" -#include "bitsery/ext/std_optional.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" @@ -98,7 +98,7 @@ class YaProgress : public Steinberg::Vst::IProgress { void serialize(S& s) { s.value8b(owner_instance_id); s.value4b(type); - s.ext(optional_description, bitsery::ext::StdOptional{}, + s.ext(optional_description, bitsery::ext::InPlaceOptional{}, [](S& s, std::u16string& description) { s.text2b(description, 1024); }); diff --git a/src/common/serialization/vst3/context-menu/context-menu.h b/src/common/serialization/vst3/context-menu/context-menu.h index dd90524c..08e3b202 100644 --- a/src/common/serialization/vst3/context-menu/context-menu.h +++ b/src/common/serialization/vst3/context-menu/context-menu.h @@ -17,8 +17,8 @@ #pragma once #include -#include "bitsery/ext/std_optional.h" +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" #include "../context-menu-target.h" @@ -119,7 +119,7 @@ class YaContextMenu : public Steinberg::Vst::IContextMenu { s.value8b(owner_instance_id); s.value8b(context_menu_id); s.object(item); - s.ext(target, bitsery::ext::StdOptional{}); + s.ext(target, bitsery::ext::InPlaceOptional{}); } }; diff --git a/src/common/serialization/vst3/host-context-proxy.h b/src/common/serialization/vst3/host-context-proxy.h index 5a4fd313..99b52f08 100644 --- a/src/common/serialization/vst3/host-context-proxy.h +++ b/src/common/serialization/vst3/host-context-proxy.h @@ -62,7 +62,7 @@ class Vst3HostContextProxy : public YaHostApplication, template void serialize(S& s) { - s.ext(owner_instance_id, bitsery::ext::StdOptional{}, + s.ext(owner_instance_id, bitsery::ext::InPlaceOptional{}, [](S& s, native_size_t& instance_id) { s.value8b(instance_id); }); diff --git a/src/common/serialization/vst3/host-context/host-application.h b/src/common/serialization/vst3/host-context/host-application.h index 77d2308b..f79a470a 100644 --- a/src/common/serialization/vst3/host-context/host-application.h +++ b/src/common/serialization/vst3/host-context/host-application.h @@ -18,10 +18,10 @@ #include -#include #include #include +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" @@ -96,7 +96,7 @@ class YaHostApplication : public Steinberg::Vst::IHostApplication { template void serialize(S& s) { - s.ext(owner_instance_id, bitsery::ext::StdOptional{}, + s.ext(owner_instance_id, bitsery::ext::InPlaceOptional{}, [](S& s, native_size_t& instance_id) { s.value8b(instance_id); }); diff --git a/src/common/serialization/vst3/host-context/plug-interface-support.h b/src/common/serialization/vst3/host-context/plug-interface-support.h index 3860fdea..d51907bd 100644 --- a/src/common/serialization/vst3/host-context/plug-interface-support.h +++ b/src/common/serialization/vst3/host-context/plug-interface-support.h @@ -16,9 +16,9 @@ #pragma once -#include #include +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" @@ -84,7 +84,7 @@ class YaPlugInterfaceSupport : public Steinberg::Vst::IPlugInterfaceSupport { template void serialize(S& s) { - s.ext(owner_instance_id, bitsery::ext::StdOptional{}, + s.ext(owner_instance_id, bitsery::ext::InPlaceOptional{}, [](S& s, native_size_t& instance_id) { s.value8b(instance_id); }); diff --git a/src/common/serialization/vst3/message.h b/src/common/serialization/vst3/message.h index 7337f110..770473dc 100644 --- a/src/common/serialization/vst3/message.h +++ b/src/common/serialization/vst3/message.h @@ -16,9 +16,9 @@ #pragma once -#include #include +#include "../../bitsery/ext/in-place-optional.h" #include "../common.h" #include "attribute-list.h" #include "base.h" @@ -72,7 +72,7 @@ class YaMessagePtr : public Steinberg::Vst::IMessage { template void serialize(S& s) { - s.ext(message_id, bitsery::ext::StdOptional{}, + s.ext(message_id, bitsery::ext::InPlaceOptional{}, [](S& s, std::string& id) { s.text1b(id, 1024); }); s.value8b(original_message_ptr); } diff --git a/src/common/serialization/vst3/plug-view/plug-view.h b/src/common/serialization/vst3/plug-view/plug-view.h index 25909ce8..4ccc1918 100644 --- a/src/common/serialization/vst3/plug-view/plug-view.h +++ b/src/common/serialization/vst3/plug-view/plug-view.h @@ -17,8 +17,8 @@ #pragma once #include -#include "bitsery/ext/std_optional.h" +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" #include "../plug-frame-proxy.h" @@ -300,7 +300,7 @@ class YaPlugView : public Steinberg::IPlugView { template void serialize(S& s) { s.value8b(owner_instance_id); - s.ext(plug_frame_args, bitsery::ext::StdOptional{}); + s.ext(plug_frame_args, bitsery::ext::InPlaceOptional{}); } }; diff --git a/src/common/serialization/vst3/plugin-factory/plugin-factory.h b/src/common/serialization/vst3/plugin-factory/plugin-factory.h index 219a0ca0..2fc8af55 100644 --- a/src/common/serialization/vst3/plugin-factory/plugin-factory.h +++ b/src/common/serialization/vst3/plugin-factory/plugin-factory.h @@ -16,10 +16,10 @@ #pragma once -#include #include #include +#include "../../../bitsery/ext/in-place-optional.h" #include "../base.h" #include "../host-context-proxy.h" @@ -101,19 +101,19 @@ class YaPluginFactory3 : public Steinberg::IPluginFactory3 { s.value1b(supports_plugin_factory); s.value1b(supports_plugin_factory_2); s.value1b(supports_plugin_factory_3); - s.ext(factory_info, bitsery::ext::StdOptional{}); + s.ext(factory_info, bitsery::ext::InPlaceOptional{}); s.value4b(num_classes); s.container(class_infos_1, 2048, [](S& s, std::optional& info) { - s.ext(info, bitsery::ext::StdOptional{}); + s.ext(info, bitsery::ext::InPlaceOptional{}); }); s.container(class_infos_2, 2048, [](S& s, std::optional& info) { - s.ext(info, bitsery::ext::StdOptional{}); + s.ext(info, bitsery::ext::InPlaceOptional{}); }); s.container(class_infos_unicode, 2048, [](S& s, std::optional& info) { - s.ext(info, bitsery::ext::StdOptional{}); + s.ext(info, bitsery::ext::InPlaceOptional{}); }); } }; diff --git a/src/common/serialization/vst3/plugin/audio-processor.h b/src/common/serialization/vst3/plugin/audio-processor.h index 2d3743e3..6ee9d3d0 100644 --- a/src/common/serialization/vst3/plugin/audio-processor.h +++ b/src/common/serialization/vst3/plugin/audio-processor.h @@ -16,10 +16,10 @@ #pragma once -#include #include #include "../../../audio-shm.h" +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" #include "../process-data.h" @@ -279,7 +279,7 @@ class YaAudioProcessor : public Steinberg::Vst::IAudioProcessor { s.value8b(instance_id); s.object(data); - s.ext(new_realtime_priority, bitsery::ext::StdOptional{}, + s.ext(new_realtime_priority, bitsery::ext::InPlaceOptional{}, [](S& s, int& priority) { s.value4b(priority); }); } }; diff --git a/src/common/serialization/vst3/plugin/component.h b/src/common/serialization/vst3/plugin/component.h index 087bfa85..5633dfa2 100644 --- a/src/common/serialization/vst3/plugin/component.h +++ b/src/common/serialization/vst3/plugin/component.h @@ -16,9 +16,9 @@ #pragma once -#include #include +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" diff --git a/src/common/serialization/vst3/plugin/connection-point.h b/src/common/serialization/vst3/plugin/connection-point.h index 6e31109e..26197a56 100644 --- a/src/common/serialization/vst3/plugin/connection-point.h +++ b/src/common/serialization/vst3/plugin/connection-point.h @@ -18,10 +18,10 @@ #include -#include -#include "../../../bitsery/ext/in-place-variant.h" #include +#include "../../../bitsery/ext/in-place-variant.h" +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" #include "../message.h" @@ -79,8 +79,9 @@ class YaConnectionPoint : public Steinberg::Vst::IConnectionPoint { * `IConnectionPoint`, but let's stay consistent with the overall style * here. */ - Vst3ConnectionPointProxyConstructArgs(Steinberg::IPtr object, - size_t owner_instance_id) noexcept; + Vst3ConnectionPointProxyConstructArgs( + Steinberg::IPtr object, + size_t owner_instance_id) noexcept; /** * The unique instance identifier of the proxy object instance this @@ -164,7 +165,7 @@ class YaConnectionPoint : public Steinberg::Vst::IConnectionPoint { template void serialize(S& s) { s.value8b(instance_id); - s.ext(other_instance_id, bitsery::ext::StdOptional{}, + s.ext(other_instance_id, bitsery::ext::InPlaceOptional{}, [](S& s, native_size_t& instance_id) { s.value8b(instance_id); }); diff --git a/src/common/serialization/vst3/plugin/edit-controller.h b/src/common/serialization/vst3/plugin/edit-controller.h index 51c03b68..a0f0ff8f 100644 --- a/src/common/serialization/vst3/plugin/edit-controller.h +++ b/src/common/serialization/vst3/plugin/edit-controller.h @@ -16,9 +16,9 @@ #pragma once -#include #include +#include "../../../bitsery/ext/in-place-optional.h" #include "../../common.h" #include "../base.h" #include "../bstream.h" @@ -354,7 +354,8 @@ class YaEditController : public Steinberg::Vst::IEditController { template void serialize(S& s) { s.value8b(instance_id); - s.ext(component_handler_proxy_args, bitsery::ext::StdOptional{}); + s.ext(component_handler_proxy_args, + bitsery::ext::InPlaceOptional{}); } }; @@ -372,7 +373,7 @@ class YaEditController : public Steinberg::Vst::IEditController { template void serialize(S& s) { - s.ext(plug_view_args, bitsery::ext::StdOptional{}); + s.ext(plug_view_args, bitsery::ext::InPlaceOptional{}); } }; diff --git a/src/common/serialization/vst3/process-data.h b/src/common/serialization/vst3/process-data.h index a8a21c55..b0ddc54c 100644 --- a/src/common/serialization/vst3/process-data.h +++ b/src/common/serialization/vst3/process-data.h @@ -18,10 +18,10 @@ #include -#include #include -#include "../../bitsery/ext/in-place-variant.h" +#include "../../bitsery/ext/in-place-optional.h" +#include "../../bitsery/ext/in-place-variant.h" #include "base.h" #include "event-list.h" #include "parameter-changes.h" @@ -196,8 +196,8 @@ class YaProcessData { // an existing object, since our serializing code doesn't touch the // actual pointers. s.container(*outputs, max_num_speakers); - s.ext(*output_parameter_changes, bitsery::ext::StdOptional{}); - s.ext(*output_events, bitsery::ext::StdOptional{}); + s.ext(*output_parameter_changes, bitsery::ext::InPlaceOptional{}); + s.ext(*output_events, bitsery::ext::InPlaceOptional{}); } }; @@ -230,9 +230,9 @@ class YaProcessData { s.container4b(outputs_num_channels, max_num_speakers); s.object(input_parameter_changes); s.value1b(output_parameter_changes_supported); - s.ext(input_events, bitsery::ext::StdOptional{}); + s.ext(input_events, bitsery::ext::InPlaceOptional{}); s.value1b(output_events_supported); - s.ext(process_context, bitsery::ext::StdOptional{}); + s.ext(process_context, bitsery::ext::InPlaceOptional{}); // We of course won't serialize the `reconstructed_process_data` and all // of the `output*` fields defined below it