From 5383bbb2310648065c713aec8f91964c4a0c0f4c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 5 Mar 2020 13:50:57 +0100 Subject: [PATCH] Add a serialization function for AEffect structs --- src/common/communication.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/common/communication.h b/src/common/communication.h index 7244c578..655eea44 100644 --- a/src/common/communication.h +++ b/src/common/communication.h @@ -63,8 +63,9 @@ using InputAdapter = bitsery::InputBufferAdapter>; struct Event { int32_t opcode; int32_t index; - // TODO: This is an intptr_t, is this actually a poitner that should be - // dereferenced? + // TODO: This is an intptr_t, if we want to support 32 bit Wine plugins all + // of these these intptr_t types should be replace by `uint64_t` to + // remain compatible with the Linux VST plugin. intptr_t value; float option; /** @@ -113,6 +114,28 @@ struct EventResult { } }; +/** + * The serialization function for `AEffect` structs. This will s serialize all + * of the values but it will not touch any of the pointer fields. That way you + * can deserialize to an existing `AEffect` instance. + */ +template +void serialize(S& s, AEffect& plugin) { + s.value4b(plugin.magic); + s.value4b(plugin.numPrograms); + s.value4b(plugin.numInputs); + s.value4b(plugin.numOutputs); + s.value4b(plugin.flags); + + // These fields can contain some values that are rarely used and/or + // deprecated, but we should pass them along anyway + s.container1b(plugin.empty3); + s.value4b(plugin.unknown_float); + + s.value4b(plugin.uniqueID); + s.container1b(plugin.unknown1); +} + /** * Serialize an object using bitsery and write it to a socket. *