From 43296675f6a65e5bd68c5c2e4ebd7a1b2cc51f00 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 13 Dec 2020 22:07:19 +0100 Subject: [PATCH] Implement IComponent::activateBus() --- src/common/logging/vst3.cpp | 10 +++++++++ src/common/logging/vst3.h | 1 + src/common/serialization/vst3.h | 1 + src/common/serialization/vst3/component.h | 25 +++++++++++++++++++++ src/plugin/bridges/vst3-impls/component.cpp | 11 ++++++--- src/wine-host/bridges/vst3.cpp | 6 +++++ 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index b2035a32..4ef9e8e5 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -114,6 +114,16 @@ void Vst3Logger::log_request(bool is_host_vst, }); } +void Vst3Logger::log_request(bool is_host_vst, + const YaComponent::ActivateBus& request) { + log_request_base(is_host_vst, [&](auto& message) { + message << "::activateBus(type = " << request.type + << ", dir = " << request.dir << ", index = " << request.index + << ", state = " << (request.state ? "true" : "false") << ">)"; + }); +} + void Vst3Logger::log_request(bool is_host_vst, const YaPluginFactory::Construct&) { log_request_base(is_host_vst, diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index b9a6ea9c..ffcd7002 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -64,6 +64,7 @@ class Vst3Logger { void log_request(bool is_host_vst, const YaComponent::GetBusCount&); void log_request(bool is_host_vst, const YaComponent::GetBusInfo&); void log_request(bool is_host_vst, const YaComponent::GetRoutingInfo&); + void log_request(bool is_host_vst, const YaComponent::ActivateBus&); void log_request(bool is_host_vst, const YaPluginFactory::Construct&); void log_request(bool is_host_vst, const YaPluginFactory::SetHostContext&); void log_request(bool is_host_vst, const WantsConfiguration&); diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index 5c1abb87..11cf13f3 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -65,6 +65,7 @@ using ControlRequest = std::variant; diff --git a/src/common/serialization/vst3/component.h b/src/common/serialization/vst3/component.h index a92c9a63..0ec6f177 100644 --- a/src/common/serialization/vst3/component.h +++ b/src/common/serialization/vst3/component.h @@ -301,6 +301,31 @@ class YaComponent : public Steinberg::Vst::IComponent { virtual tresult PLUGIN_API getRoutingInfo(Steinberg::Vst::RoutingInfo& inInfo, Steinberg::Vst::RoutingInfo& outInfo /*out*/) override = 0; + + /** + * Message to pass through a call to `IComponent::activateBus(type, dir, + * index, state)` to the Wine plugin host. + */ + struct ActivateBus { + using Response = UniversalTResult; + + native_size_t instance_id; + + Steinberg::Vst::MediaType type; + Steinberg::Vst::BusDirection dir; + int32 index; + TBool state; + + template + void serialize(S& s) { + s.value8b(instance_id); + s.value4b(type); + s.value4b(dir); + s.value4b(index); + s.value1b(state); + } + }; + virtual tresult PLUGIN_API activateBus(Steinberg::Vst::MediaType type, Steinberg::Vst::BusDirection dir, int32 index, diff --git a/src/plugin/bridges/vst3-impls/component.cpp b/src/plugin/bridges/vst3-impls/component.cpp index d362db06..206b89c9 100644 --- a/src/plugin/bridges/vst3-impls/component.cpp +++ b/src/plugin/bridges/vst3-impls/component.cpp @@ -123,9 +123,14 @@ YaComponentPluginImpl::activateBus(Steinberg::Vst::MediaType type, Steinberg::Vst::BusDirection dir, int32 index, TBool state) { - // TODO: Implement - bridge.logger.log("TODO: IComponent::activateBus()"); - return Steinberg::kNotImplemented; + return bridge + .send_message( + YaComponent::ActivateBus{.instance_id = arguments.instance_id, + .type = type, + .dir = dir, + .index = index, + .state = state}) + .native(); } tresult PLUGIN_API YaComponentPluginImpl::setActive(TBool state) { diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 8480ec65..8baee5ae 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -142,6 +142,12 @@ void Vst3Bridge::run() { .updated_in_info = request.in_info, .updated_out_info = request.out_info}; }, + [&](const YaComponent::ActivateBus& request) + -> YaComponent::ActivateBus::Response { + return component_instances[request.instance_id] + .component->activateBus(request.type, request.dir, + request.index, request.state); + }, [&](const YaPluginFactory::Construct&) -> YaPluginFactory::Construct::Response { return YaPluginFactory::ConstructArgs(