diff --git a/src/common/communication.h b/src/common/communication.h index 7d6f1c93..cee572b1 100644 --- a/src/common/communication.h +++ b/src/common/communication.h @@ -57,9 +57,11 @@ template inline void write_object(Socket& socket, const T& object, typename buffer_t::type& buffer) { + bitsery::ext::PointerLinkingContext serializer_context{}; auto length = - bitsery::quickSerialization::type>>( - buffer, object); + bitsery::quickSerialization::type>>( + serializer_context, buffer, object); socket.send(boost::asio::buffer(buffer, length)); } @@ -91,9 +93,11 @@ inline T& read_object(Socket& socket, typename buffer_t::type& buffer) { auto message_length = socket.receive(boost::asio::buffer(buffer)); + bitsery::ext::PointerLinkingContext serializer_context{}; auto [_, success] = - bitsery::quickDeserialization::type>>( - {buffer.begin(), message_length}, object); + bitsery::quickDeserialization::type>>( + serializer_context, {buffer.begin(), message_length}, object); if (!success) { throw std::runtime_error("Deserialization failure in call:" + @@ -172,6 +176,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, [&](const std::string& s) -> void* { return const_cast(s.c_str()); }, + [&](VstEvents& events) -> void* { return &events; }, [&](NeedsBuffer&) -> void* { return buffer.data(); }}, event.payload); const intptr_t return_value = callback(plugin, event.opcode, event.index, diff --git a/src/common/logging.cpp b/src/common/logging.cpp index fbea1107..8a3d02a0 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -145,6 +145,9 @@ void Logger::log_event(bool is_dispatch, overload{ [&](const std::nullptr_t&) { message << ""; }, [&](const std::string& s) { message << "\"" << s << "\""; }, + [&](const VstEvents& events) { + message << "<" << events.numEvents << " midi_events>"; + }, [&](const NeedsBuffer&) { message << ""; }}, payload); diff --git a/src/common/serialization.h b/src/common/serialization.h index c35537f0..2f9921a6 100644 --- a/src/common/serialization.h +++ b/src/common/serialization.h @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -71,13 +72,14 @@ struct NeedsBuffer {}; * opcode `effProcessEvents` comes with a struct containing a list of midi * events. * - * TODO: A lot of these are still missing, beginning with `VstEvents`. + * TODO: A lot of these are still missing * * - Some empty buffer for the plugin to write its own data to, for instance for * a plugin to report its name or the label for a certain parameter. We'll * assume that this is the default if none of the above options apply. */ -using EventPayload = std::variant; +using EventPayload = + std::variant; /** * An event as dispatched by the VST host. These events will get forwarded to @@ -121,12 +123,27 @@ struct Event { // `EventPayload` in a struct s.ext(payload, bitsery::ext::StdVariant{ - // TODO: Some of these oerlaods might not be necessary, check - // if this is the case [](S&, std::nullptr_t&) {}, [](S& s, std::string& string) { s.text1b(string, max_string_length); }, + [](S& s, VstEvents& events) { + s.value4b(events.numEvents); + + // This will only ever read a single event since + // that's how the `VstEvents` struct is defined, + // hence the assertion. If multiple events can be + // passed at once then `VstEvents` should be + // modified. + assert(events.numEvents <= 1); + s.container( + events.events, [](S& s, VstEvent*(&event_ptr)) { + s.ext(event_ptr, bitsery::ext::PointerOwner(), + [](S& s, VstEvent& event) { + s.container1b(event.dump); + }); + }); + }, [](S&, NeedsBuffer&) {}}); } }; diff --git a/src/include/vestige/aeffectx.h b/src/include/vestige/aeffectx.h index edfba549..0af00de2 100644 --- a/src/include/vestige/aeffectx.h +++ b/src/include/vestige/aeffectx.h @@ -208,6 +208,7 @@ class VstMidiEvent { }; class VstEvent { + public: char dump[sizeof(VstMidiEvent)]; };