From 044b7fa9a2ea5b81730230a7e0c5d7685ceeb580 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 7 May 2020 16:45:11 +0200 Subject: [PATCH] Add a second payload value to events This is for data passed through the `value` `intptr_t` parameter. The only two events that use this are `effSetSpeakerArrangement` and `effGetSpeakerArrangement`. Since this is such a rare occurrence we'll leave the regular `value` field as it is. --- src/common/serialization.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/serialization.h b/src/common/serialization.h index 931f4c78..43b81f34 100644 --- a/src/common/serialization.h +++ b/src/common/serialization.h @@ -389,18 +389,23 @@ struct Event { * Bitsery can do all the hard work for us. */ EventPayload payload; + /** + * The same as the above value, but for values passed through the `intptr_t` + * value parameter. `effGetSpeakerArrangement` and + * `effSetSpeakerArrangement` are the only events that use this. + */ + std::optional value_payload; template void serialize(S& s) { s.value4b(opcode); s.value4b(index); - // Hard coding pointer sizes to 8 bytes should be fine, right? Even if - // we're hosting a 32 bit plugin the native VST plugin will still use 64 - // bit large pointers. s.value8b(value); s.value4b(option); s.object(payload); + s.ext(value_payload, bitsery::ext::StdOptional(), + [](S& s, auto& v) { s.object(v); }); } };