diff --git a/src/common/communication/common.h b/src/common/communication/common.h index 3684f95c..465ba7f7 100644 --- a/src/common/communication/common.h +++ b/src/common/communication/common.h @@ -1150,3 +1150,15 @@ class TypedMessageHandler : public AdHocSocketHandler { process_message); } }; + +/** + * Get the actual variant for a request. We need a function for this to be able + * to handle composite types, like `AudioProcessorRequest` that use + * `MesasgeReference` to be able to store persistent objects in the message + * variant. This function should be specialized for those kinds of types. + */ +template +std::variant& get_request_variant( + std::variant& request) noexcept { + return request; +} diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index 2cbec074..b82f89ee 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -138,7 +138,7 @@ using ControlRequest = template void serialize(S& s, ControlRequest& payload) { // All of the objects in `ControlRequest` should have their own - // serialization function. + // serialization function s.ext(payload, bitsery::ext::InPlaceVariant{}); } @@ -204,7 +204,7 @@ struct AudioProcessorRequest { // `Vst3Sockets::add_audio_processor_and_listen`) and then // reassign the reference to point to that boject. s.ext(request_ref, - bitsery::ext::MessageReference(process_request)); + bitsery::ext::MessageReference(process_request_)); }, [](S& s, auto& request) { s.object(request); }}); } @@ -216,9 +216,24 @@ struct AudioProcessorRequest { * to this object. That way we can keep it around as a thread local object * to prevent unnecessary allocations. */ - std::optional process_request; + std::optional process_request_; }; +/** + * Fetch the `std::variant<>` from an audio processor request object. This will + * let us use our regular, simple function call dispatch code, but we can still + * store the process data in a separate field (to reduce allocations). + * + * This overloads the `get_request_variant()` function from + * `../communication/common.h`. + * + * @overload + */ +inline AudioProcessorRequest::Payload& get_request_variant( + AudioProcessorRequest& request) noexcept { + return request.payload; +} + /** * When we do a callback from the Wine plugin host to the plugin, this encodes * the information we want or the operation we want to perform. A request of @@ -262,27 +277,3 @@ void serialize(S& s, CallbackRequest& payload) { // serialization function. s.ext(payload, bitsery::ext::InPlaceVariant{}); } - -/** - * Get the actual variant for a request. We need a function for this to be able - * to handle composite types, like `AudioProcessorRequest` that use - * `MesasgeReference` to be able to store persistent objects in the message - * variant. - */ -template -std::variant& get_request_variant( - std::variant& request) noexcept { - return request; -} - -/** - * Fetch the `std::variant<>` from an audio processor request object. This will - * let us use our regular, simple function call dispatch code, but we can still - * store the process data in a separate field (to reduce allocations). - * - * @overload - */ -inline AudioProcessorRequest::Payload& get_request_variant( - AudioProcessorRequest& request) noexcept { - return request.payload; -}