From bb99a539d57fc4468a6380defb2aba6b20edf0b1 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 19 Dec 2020 15:45:24 +0100 Subject: [PATCH] Implement IComponentHandler::performEdit() --- src/common/logging/vst3.cpp | 11 +++++++++- src/common/logging/vst3.h | 1 + src/common/serialization/vst3.h | 5 +++-- .../component-handler/component-handler.h | 21 +++++++++++++++++++ src/plugin/bridges/vst3.cpp | 7 +++++++ .../vst3-impls/component-handler-proxy.cpp | 7 ++++--- 6 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index f0a3aa6e..3f970d2a 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -450,7 +450,16 @@ bool Vst3Logger::log_request(bool is_host_vst, const YaComponentHandler::BeginEdit& request) { return log_request_base(is_host_vst, [&](auto& message) { message << request.owner_instance_id - << ": IComponentHandler::beginEdit(" << request.id << ")"; + << ": IComponentHandler::beginEdit(id = " << request.id << ")"; + }); +} + +bool Vst3Logger::log_request(bool is_host_vst, + const YaComponentHandler::PerformEdit& request) { + return log_request_base(is_host_vst, [&](auto& message) { + message << request.owner_instance_id + << ": IComponentHandler::performEdit(id = " << request.id + << ", valueNormalized = " << request.value_normalized << ")"; }); } diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index 20a1abd0..71fbbef6 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -111,6 +111,7 @@ class Vst3Logger { bool log_request(bool is_host_vst, const WantsConfiguration&); bool log_request(bool is_host_vst, const YaComponentHandler::BeginEdit&); + bool log_request(bool is_host_vst, const YaComponentHandler::PerformEdit&); void log_response(bool is_host_vst, const Ack&); void log_response( diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index 0172facf..c6ab00fb 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -105,8 +105,9 @@ void serialize(S& s, ControlRequest& payload) { * information we want or the operation we want to perform. A request of type * `CallbackRequest(T)` should send back a `T::Response`. */ -using CallbackRequest = - std::variant; +using CallbackRequest = std::variant; template void serialize(S& s, CallbackRequest& payload) { diff --git a/src/common/serialization/vst3/component-handler/component-handler.h b/src/common/serialization/vst3/component-handler/component-handler.h index b907d297..a17d05a2 100644 --- a/src/common/serialization/vst3/component-handler/component-handler.h +++ b/src/common/serialization/vst3/component-handler/component-handler.h @@ -81,6 +81,27 @@ class YaComponentHandler : public Steinberg::Vst::IComponentHandler { virtual tresult PLUGIN_API beginEdit(Steinberg::Vst::ParamID id) override = 0; + + /** + * Message to pass through a call to `IComponentHandler::performEdit(id, + * value_normalized)` to the component handler provided by the host. + */ + struct PerformEdit { + using Response = UniversalTResult; + + native_size_t owner_instance_id; + + Steinberg::Vst::ParamID id; + Steinberg::Vst::ParamValue value_normalized; + + template + void serialize(S& s) { + s.value8b(owner_instance_id); + s.value4b(id); + s.value8b(value_normalized); + } + }; + virtual tresult PLUGIN_API performEdit(Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue valueNormalized) override = 0; diff --git a/src/plugin/bridges/vst3.cpp b/src/plugin/bridges/vst3.cpp index ab8a44fe..741ba9e8 100644 --- a/src/plugin/bridges/vst3.cpp +++ b/src/plugin/bridges/vst3.cpp @@ -89,6 +89,13 @@ Vst3PluginBridge::Vst3PluginBridge() .get() .component_handler->beginEdit(request.id); }, + [&](const YaComponentHandler::PerformEdit& request) + -> YaComponentHandler::PerformEdit::Response { + return plugin_proxies.at(request.owner_instance_id) + .get() + .component_handler->performEdit( + request.id, request.value_normalized); + }, }); }); } diff --git a/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp b/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp index 7f76a54f..388eaa31 100644 --- a/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp @@ -48,9 +48,10 @@ Vst3ComponentHandlerProxyImpl::beginEdit(Steinberg::Vst::ParamID id) { tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::performEdit( Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue valueNormalized) { - // TODO: Implement - std::cerr << "TODO: IComponentHandler::performEdit()" << std::endl; - return Steinberg::kNotImplemented; + return bridge.send_message(YaComponentHandler::PerformEdit{ + .owner_instance_id = owner_instance_id(), + .id = id, + .value_normalized = valueNormalized}); } tresult PLUGIN_API