mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Move get_request_variant template function
This needs to be specialized for the CLAP and VST3 request variant types.
This commit is contained in:
@@ -1150,3 +1150,15 @@ class TypedMessageHandler : public AdHocSocketHandler<Thread> {
|
|||||||
process_message);
|
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 <typename... Ts>
|
||||||
|
std::variant<Ts...>& get_request_variant(
|
||||||
|
std::variant<Ts...>& request) noexcept {
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ using ControlRequest =
|
|||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s, ControlRequest& payload) {
|
void serialize(S& s, ControlRequest& payload) {
|
||||||
// All of the objects in `ControlRequest` should have their own
|
// All of the objects in `ControlRequest` should have their own
|
||||||
// serialization function.
|
// serialization function
|
||||||
s.ext(payload, bitsery::ext::InPlaceVariant{});
|
s.ext(payload, bitsery::ext::InPlaceVariant{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ struct AudioProcessorRequest {
|
|||||||
// `Vst3Sockets::add_audio_processor_and_listen`) and then
|
// `Vst3Sockets::add_audio_processor_and_listen`) and then
|
||||||
// reassign the reference to point to that boject.
|
// reassign the reference to point to that boject.
|
||||||
s.ext(request_ref,
|
s.ext(request_ref,
|
||||||
bitsery::ext::MessageReference(process_request));
|
bitsery::ext::MessageReference(process_request_));
|
||||||
},
|
},
|
||||||
[](S& s, auto& request) { s.object(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 this object. That way we can keep it around as a thread local object
|
||||||
* to prevent unnecessary allocations.
|
* to prevent unnecessary allocations.
|
||||||
*/
|
*/
|
||||||
std::optional<YaAudioProcessor::Process> process_request;
|
std::optional<YaAudioProcessor::Process> 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
|
* 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
|
* 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.
|
// serialization function.
|
||||||
s.ext(payload, bitsery::ext::InPlaceVariant{});
|
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 <typename... Ts>
|
|
||||||
std::variant<Ts...>& get_request_variant(
|
|
||||||
std::variant<Ts...>& 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;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user