Use the in new place optional extension

This commit is contained in:
Robbert van der Helm
2021-06-10 23:44:47 +02:00
parent f5214b7686
commit 964c150158
20 changed files with 63 additions and 55 deletions
+6
View File
@@ -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
+6 -6
View File
@@ -21,11 +21,11 @@
#endif
#include <boost/filesystem.hpp>
#include <bitsery/ext/std_optional.h>
#include <chrono>
#include <optional>
#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 <typename S>
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,
+7 -7
View File
@@ -18,13 +18,13 @@
#include <variant>
#include <bitsery/ext/std_optional.h>
#include <bitsery/traits/array.h>
#include <bitsery/traits/vector.h>
#include <vestige/aeffectx.h>
#include <boost/container/small_vector.hpp>
#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 <typename S>
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 <typename S>
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); });
}
};
@@ -19,9 +19,9 @@
#include <unordered_map>
#include <bitsery/ext/std_map.h>
#include <bitsery/ext/std_optional.h>
#include <pluginterfaces/vst/ivstmessage.h>
#include "../../bitsery/ext/in-place-optional.h"
#include "base.h"
#pragma GCC diagnostic push
+2 -2
View File
@@ -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<Steinberg::Vst::String128>);
});
s.ext(attributes, bitsery::ext::StdOptional{});
s.ext(attributes, bitsery::ext::InPlaceOptional{});
}
/**
@@ -17,8 +17,8 @@
#pragma once
#include <pluginterfaces/vst/ivstcontextmenu.h>
#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 <typename S>
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 <typename S>
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); });
}
};
@@ -17,8 +17,8 @@
#pragma once
#include <pluginterfaces/vst/ivsteditcontroller.h>
#include "bitsery/ext/std_optional.h"
#include "../../../bitsery/ext/in-place-optional.h"
#include "../../common.h"
#include "../base.h"
#include "../context-menu-proxy.h"
@@ -18,9 +18,9 @@
#include <pluginterfaces/vst/ivsteditcontroller.h>
#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);
});
@@ -17,8 +17,8 @@
#pragma once
#include <pluginterfaces/vst/ivstcontextmenu.h>
#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{});
}
};
@@ -62,7 +62,7 @@ class Vst3HostContextProxy : public YaHostApplication,
template <typename S>
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);
});
@@ -18,10 +18,10 @@
#include <type_traits>
#include <bitsery/ext/std_optional.h>
#include <bitsery/traits/string.h>
#include <pluginterfaces/vst/ivsthostapplication.h>
#include "../../../bitsery/ext/in-place-optional.h"
#include "../../common.h"
#include "../base.h"
@@ -96,7 +96,7 @@ class YaHostApplication : public Steinberg::Vst::IHostApplication {
template <typename S>
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);
});
@@ -16,9 +16,9 @@
#pragma once
#include <bitsery/ext/std_optional.h>
#include <pluginterfaces/vst/ivstpluginterfacesupport.h>
#include "../../../bitsery/ext/in-place-optional.h"
#include "../../common.h"
#include "../base.h"
@@ -84,7 +84,7 @@ class YaPlugInterfaceSupport : public Steinberg::Vst::IPlugInterfaceSupport {
template <typename S>
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);
});
+2 -2
View File
@@ -16,9 +16,9 @@
#pragma once
#include <bitsery/ext/std_optional.h>
#include <pluginterfaces/vst/ivstmessage.h>
#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 <typename S>
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);
}
@@ -17,8 +17,8 @@
#pragma once
#include <pluginterfaces/gui/iplugview.h>
#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 <typename S>
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{});
}
};
@@ -16,10 +16,10 @@
#pragma once
#include <bitsery/ext/std_optional.h>
#include <bitsery/traits/string.h>
#include <pluginterfaces/base/ipluginbase.h>
#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<Steinberg::PClassInfo>& info) {
s.ext(info, bitsery::ext::StdOptional{});
s.ext(info, bitsery::ext::InPlaceOptional{});
});
s.container(class_infos_2, 2048,
[](S& s, std::optional<Steinberg::PClassInfo2>& info) {
s.ext(info, bitsery::ext::StdOptional{});
s.ext(info, bitsery::ext::InPlaceOptional{});
});
s.container(class_infos_unicode, 2048,
[](S& s, std::optional<Steinberg::PClassInfoW>& info) {
s.ext(info, bitsery::ext::StdOptional{});
s.ext(info, bitsery::ext::InPlaceOptional{});
});
}
};
@@ -16,10 +16,10 @@
#pragma once
#include <bitsery/ext/std_optional.h>
#include <pluginterfaces/vst/ivstaudioprocessor.h>
#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); });
}
};
@@ -16,9 +16,9 @@
#pragma once
#include <bitsery/ext/std_optional.h>
#include <pluginterfaces/vst/ivstcomponent.h>
#include "../../../bitsery/ext/in-place-optional.h"
#include "../../common.h"
#include "../base.h"
@@ -18,10 +18,10 @@
#include <variant>
#include <bitsery/ext/std_optional.h>
#include "../../../bitsery/ext/in-place-variant.h"
#include <pluginterfaces/vst/ivstmessage.h>
#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<FUnknown> object,
size_t owner_instance_id) noexcept;
Vst3ConnectionPointProxyConstructArgs(
Steinberg::IPtr<FUnknown> 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 <typename S>
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);
});
@@ -16,9 +16,9 @@
#pragma once
#include <bitsery/ext/std_optional.h>
#include <pluginterfaces/vst/ivsteditcontroller.h>
#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 <typename S>
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 <typename S>
void serialize(S& s) {
s.ext(plug_view_args, bitsery::ext::StdOptional{});
s.ext(plug_view_args, bitsery::ext::InPlaceOptional{});
}
};
+6 -6
View File
@@ -18,10 +18,10 @@
#include <variant>
#include <bitsery/ext/std_optional.h>
#include <pluginterfaces/vst/ivstaudioprocessor.h>
#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