Prefix top level VST3 message types

CLAP will use a similar structure. Alternatively we could use
namespaces, but while that would solve clashes for the linker with the
way namespaces in C++ work it would still be ambiguous which one is
being referred to just looking at the code.
This commit is contained in:
Robbert van der Helm
2022-08-24 13:42:47 +02:00
parent 5b4dbdd890
commit 6df0741195
4 changed files with 26 additions and 26 deletions
+6 -6
View File
@@ -905,8 +905,8 @@ class AdHocSocketHandler {
/** /**
* An instance of `AdHocSocketHandler` that encapsulates the simple * An instance of `AdHocSocketHandler` that encapsulates the simple
* communication model we use for sending requests and receiving responses. A * communication model we use for sending requests and receiving responses. A
* request of type `T`, where `T` is in the `{Control,Callback}Request` variatns * request of type `T`, where `T` is in the `*{Control,Callback}Request`
* for the plugin format, should be answered with an object of type * variants for the plugin format, should be answered with an object of type
* `T::Response`. * `T::Response`.
* *
* See the docstrings on `Vst2EventHandler` and `AdHocSocketHandler` for more * See the docstrings on `Vst2EventHandler` and `AdHocSocketHandler` for more
@@ -918,7 +918,7 @@ class AdHocSocketHandler {
* @tparam LoggerImpl The logger instead to use. This should have * @tparam LoggerImpl The logger instead to use. This should have
* `log_request(bool, T)` methods for every T in `Request`, as well as * `log_request(bool, T)` methods for every T in `Request`, as well as
* corresponding `log_response(bool, T::Response)` methods. * corresponding `log_response(bool, T::Response)` methods.
* @tparam Request Either `ControlRequest` or `CallbackRequest`. * @tparam Request Either `Vst3ControlRequest` or `Vst3CallbackRequest`.
*/ */
template <typename Thread, typename LoggerImpl, typename Request> template <typename Thread, typename LoggerImpl, typename Request>
class TypedMessageHandler : public AdHocSocketHandler<Thread> { class TypedMessageHandler : public AdHocSocketHandler<Thread> {
@@ -1114,8 +1114,8 @@ class TypedMessageHandler : public AdHocSocketHandler<Thread> {
auto [logger, is_host_plugin] = *logging; auto [logger, is_host_plugin] = *logging;
return logger.log_request(is_host_plugin, object); return logger.log_request(is_host_plugin, object);
}, },
// In the case of `AudioProcessorRequest`, we need to // In the case of `Vst3AudioProcessorRequest`, we need
// actually fetch the variant field since our object // to actually fetch the variant field since our object
// also contains a persistent object to store process // also contains a persistent object to store process
// data into so we can prevent allocations during audio // data into so we can prevent allocations during audio
// processing // processing
@@ -1153,7 +1153,7 @@ class TypedMessageHandler : public AdHocSocketHandler<Thread> {
/** /**
* Get the actual variant for a request. We need a function for this to be able * Get the actual variant for a request. We need a function for this to be able
* to handle composite types, like `AudioProcessorRequest` that use * to handle composite types, like `Vst3AudioProcessorRequest` that use
* `MesasgeReference` to be able to store persistent objects in the message * `MesasgeReference` to be able to store persistent objects in the message
* variant. This function should be specialized for those kinds of types. * variant. This function should be specialized for those kinds of types.
*/ */
+6 -6
View File
@@ -128,10 +128,10 @@ class Vst3Sockets final : public Sockets {
* that the native plugin already tries to connect to the socket before * that the native plugin already tries to connect to the socket before
* Wine plugin host is even listening on it. * Wine plugin host is even listening on it.
* @param cb An overloaded function that can take every type `T` in the * @param cb An overloaded function that can take every type `T` in the
* `AudioProcessorRequest` variant and then returns `T::Response`. * `Vst3AudioProcessorRequest` variant and then returns `T::Response`.
* *
* @tparam F A function type in the form of `T::Response(T)` for every `T` * @tparam F A function type in the form of `T::Response(T)` for every `T`
* in `AudioProcessorRequest::Payload`. * in `Vst3AudioProcessorRequest::Payload`.
*/ */
template <typename F> template <typename F>
void add_audio_processor_and_listen( void add_audio_processor_and_listen(
@@ -189,7 +189,7 @@ class Vst3Sockets final : public Sockets {
* and thread for handling those. These calls also always reuse buffers to * and thread for handling those. These calls also always reuse buffers to
* minimize allocations. * minimize allocations.
* *
* @tparam T Some object in the `AudioProcessorRequest` variant. * @tparam T Some object in the `Vst3AudioProcessorRequest` variant.
*/ */
template <typename T> template <typename T>
typename T::Response send_audio_processor_message( typename T::Response send_audio_processor_message(
@@ -239,7 +239,7 @@ class Vst3Sockets final : public Sockets {
* This will be listened on by the Wine plugin host when it calls * This will be listened on by the Wine plugin host when it calls
* `receive_multi()`. * `receive_multi()`.
*/ */
TypedMessageHandler<Thread, Vst3Logger, ControlRequest> TypedMessageHandler<Thread, Vst3Logger, Vst3ControlRequest>
host_plugin_control_; host_plugin_control_;
/** /**
@@ -247,7 +247,7 @@ class Vst3Sockets final : public Sockets {
* better idea of what our communication model looks like we'll probably * better idea of what our communication model looks like we'll probably
* want to provide an abstraction similar to `Vst2EventHandler`. * want to provide an abstraction similar to `Vst2EventHandler`.
*/ */
TypedMessageHandler<Thread, Vst3Logger, CallbackRequest> TypedMessageHandler<Thread, Vst3Logger, Vst3CallbackRequest>
plugin_host_callback_; plugin_host_callback_;
private: private:
@@ -284,7 +284,7 @@ class Vst3Sockets final : public Sockets {
*/ */
std::unordered_map< std::unordered_map<
size_t, size_t,
TypedMessageHandler<Thread, Vst3Logger, AudioProcessorRequest>> TypedMessageHandler<Thread, Vst3Logger, Vst3AudioProcessorRequest>>
audio_processor_sockets_; audio_processor_sockets_;
std::mutex audio_processor_sockets_mutex_; std::mutex audio_processor_sockets_mutex_;
}; };
+13 -13
View File
@@ -51,9 +51,9 @@
/** /**
* When we send a control message from the plugin to the Wine plugin host, this * When we send a control message from the plugin to the Wine plugin host, this
* encodes the information we request or the operation we want to perform. A * encodes the information we request or the operation we want to perform. A
* request of type `ControlRequest(T)` should send back a `T::Response`. * request of type `Vst3ControlRequest(T)` should send back a `T::Response`.
*/ */
using ControlRequest = using Vst3ControlRequest =
std::variant<Vst3PluginFactoryProxy::Construct, std::variant<Vst3PluginFactoryProxy::Construct,
Vst3PlugViewProxy::Destruct, Vst3PlugViewProxy::Destruct,
Vst3PluginProxy::Construct, Vst3PluginProxy::Construct,
@@ -136,8 +136,8 @@ using ControlRequest =
YaXmlRepresentationController::GetXmlRepresentationStream>; YaXmlRepresentationController::GetXmlRepresentationStream>;
template <typename S> template <typename S>
void serialize(S& s, ControlRequest& payload) { void serialize(S& s, Vst3ControlRequest& payload) {
// All of the objects in `ControlRequest` should have their own // All of the objects in `Vst3ControlRequest` should have their own
// serialization function // serialization function
s.ext(payload, bitsery::ext::InPlaceVariant{}); s.ext(payload, bitsery::ext::InPlaceVariant{});
} }
@@ -156,15 +156,15 @@ void serialize(S& s, ControlRequest& payload) {
* without needing to create copies. See `MessageReference<T>` and * without needing to create copies. See `MessageReference<T>` and
* `bitsery::ext::MessageReference<T>` for more information. * `bitsery::ext::MessageReference<T>` for more information.
*/ */
struct AudioProcessorRequest { struct Vst3AudioProcessorRequest {
AudioProcessorRequest() {} Vst3AudioProcessorRequest() {}
/** /**
* Initialize the variant with an object. In `Vst3Sockets::send_message()` * Initialize the variant with an object. In `Vst3Sockets::send_message()`
* the object gets implicitly converted to the this variant. * the object gets implicitly converted to the this variant.
*/ */
template <typename T> template <typename T>
AudioProcessorRequest(T request) : payload(std::move(request)) {} Vst3AudioProcessorRequest(T request) : payload(std::move(request)) {}
using Payload = using Payload =
std::variant<YaAudioProcessor::SetBusArrangements, std::variant<YaAudioProcessor::SetBusArrangements,
@@ -229,17 +229,17 @@ struct AudioProcessorRequest {
* *
* @overload * @overload
*/ */
inline AudioProcessorRequest::Payload& get_request_variant( inline Vst3AudioProcessorRequest::Payload& get_request_variant(
AudioProcessorRequest& request) noexcept { Vst3AudioProcessorRequest& request) noexcept {
return request.payload; 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
* type `CallbackRequest(T)` should send back a `T::Response`. * type `Vst3CallbackRequest(T)` should send back a `T::Response`.
*/ */
using CallbackRequest = using Vst3CallbackRequest =
std::variant<Vst3ContextMenuProxy::Destruct, std::variant<Vst3ContextMenuProxy::Destruct,
WantsConfiguration, WantsConfiguration,
YaComponentHandler::BeginEdit, YaComponentHandler::BeginEdit,
@@ -272,8 +272,8 @@ using CallbackRequest =
YaUnitHandler2::NotifyUnitByBusChange>; YaUnitHandler2::NotifyUnitByBusChange>;
template <typename S> template <typename S>
void serialize(S& s, CallbackRequest& payload) { void serialize(S& s, Vst3CallbackRequest& payload) {
// All of the objects in `CallbackRequest` should have their own // All of the objects in `Vst3CallbackRequest` should have their own
// serialization function. // serialization function.
s.ext(payload, bitsery::ext::InPlaceVariant{}); s.ext(payload, bitsery::ext::InPlaceVariant{});
} }
+1 -1
View File
@@ -1628,7 +1628,7 @@ size_t Vst3Bridge::register_object_instance(
// NOTE: To prevent allocations we keep this actual // NOTE: To prevent allocations we keep this actual
// `YaAudioProcessor::Process` object around as // `YaAudioProcessor::Process` object around as
// part of a static thread local // part of a static thread local
// `AudioProcessorRequest` object, and we only // `Vst3AudioProcessorRequest` object, and we only
// store a reference to it in our variant (this is // store a reference to it in our variant (this is
// done during the deserialization in // done during the deserialization in
// `bitsery::ext::MessageReference`) // `bitsery::ext::MessageReference`)