From 9df812952e190625550f49403f6d945f6896ddce Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 13 Dec 2020 16:56:09 +0100 Subject: [PATCH] Implement IComponent::GetBusInfo() --- src/common/logging/vst3.cpp | 19 ++++++++ src/common/logging/vst3.h | 2 + src/common/serialization/vst3.h | 1 + src/common/serialization/vst3/component.h | 53 +++++++++++++++++++++ src/plugin/bridges/vst3-impls/component.cpp | 11 ++++- src/wine-host/bridges/vst3.cpp | 9 ++++ 6 files changed, 93 insertions(+), 2 deletions(-) diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index 98c3ec0e..8b41dc23 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -88,6 +88,15 @@ void Vst3Logger::log_request(bool is_host_vst, }); } +void Vst3Logger::log_request(bool is_host_vst, + const YaComponent::GetBusInfo& request) { + log_request_base(is_host_vst, [&](auto& message) { + message << "::getBusInfo(" + << request.type << ", " << request.dir << ", " << request.index + << ", &bus)"; + }); +} + void Vst3Logger::log_request(bool is_host_vst, const YaPluginFactory::Construct&) { log_request_base(is_host_vst, @@ -126,6 +135,16 @@ void Vst3Logger::log_response( }); } +void Vst3Logger::log_response(bool is_host_vst, + const YaComponent::GetBusInfoResponse& response) { + log_response_base(is_host_vst, [&](auto& message) { + message << response.result.string(); + if (response.result.native() == Steinberg::kResultOk) { + message << ", "; + } + }); +} + void Vst3Logger::log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs& args) { log_response_base(is_host_vst, [&](auto& message) { diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index a272f1f6..2e983e68 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -62,6 +62,7 @@ class Vst3Logger { void log_request(bool is_host_vst, const YaComponent::Terminate&); void log_request(bool is_host_vst, const YaComponent::SetIoMode&); 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 YaPluginFactory::Construct&); void log_request(bool is_host_vst, const YaPluginFactory::SetHostContext&); void log_request(bool is_host_vst, const WantsConfiguration&); @@ -70,6 +71,7 @@ class Vst3Logger { void log_response( bool is_host_vst, const std::variant&); + void log_response(bool is_host_vst, const YaComponent::GetBusInfoResponse&); void log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs&); void log_response(bool is_host_vst, const Configuration&); diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index 5996ebe6..5a8d0845 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -63,6 +63,7 @@ using ControlRequest = std::variant; diff --git a/src/common/serialization/vst3/component.h b/src/common/serialization/vst3/component.h index 9545d59a..8e086017 100644 --- a/src/common/serialization/vst3/component.h +++ b/src/common/serialization/vst3/component.h @@ -216,6 +216,45 @@ class YaComponent : public Steinberg::Vst::IComponent { virtual int32 PLUGIN_API getBusCount(Steinberg::Vst::MediaType type, Steinberg::Vst::BusDirection dir) override = 0; + + /** + * The response code and returned bus information for a call to + * `IComponent::getBusInfo(type, dir, index, bus )`. + */ + struct GetBusInfoResponse { + UniversalTResult result; + Steinberg::Vst::BusInfo updated_bus; + + template + void serialize(S& s) { + s.object(result); + s.object(updated_bus); + } + }; + + /** + * Message to pass through a call to `IComponent::getBusInfo(type, dir, + * index, bus )` to the Wine plugin host. + */ + struct GetBusInfo { + using Response = GetBusInfoResponse; + + native_size_t instance_id; + + Steinberg::Vst::BusType type; + Steinberg::Vst::BusDirection dir; + int32 index; + Steinberg::Vst::BusInfo bus; + + template + void serialize(S& s) { + s.value8b(instance_id); + s.value4b(type); + s.value4b(dir); + s.object(bus); + } + }; + virtual tresult PLUGIN_API getBusInfo(Steinberg::Vst::MediaType type, Steinberg::Vst::BusDirection dir, @@ -246,3 +285,17 @@ void serialize( std::variant& result) { s.ext(result, bitsery::ext::StdVariant{}); } + +namespace Steinberg { +namespace Vst { +template +void serialize(S& s, Steinberg::Vst::BusInfo& info) { + s.value4b(info.mediaType); + s.value4b(info.direction); + s.value4b(info.channelCount); + s.container2b(info.name); + s.value4b(info.busType); + s.value4b(info.flags); +} +} // namespace Vst +} // namespace Steinberg diff --git a/src/plugin/bridges/vst3-impls/component.cpp b/src/plugin/bridges/vst3-impls/component.cpp index 5f6b9c24..c570a313 100644 --- a/src/plugin/bridges/vst3-impls/component.cpp +++ b/src/plugin/bridges/vst3-impls/component.cpp @@ -94,8 +94,15 @@ YaComponentPluginImpl::getBusInfo(Steinberg::Vst::MediaType type, Steinberg::Vst::BusDirection dir, int32 index, Steinberg::Vst::BusInfo& bus /*out*/) { - // TODO: Implement - return Steinberg::kNotImplemented; + const GetBusInfoResponse response = bridge.send_message( + YaComponent::GetBusInfo{.instance_id = arguments.instance_id, + .type = type, + .dir = dir, + .index = index, + .bus = bus}); + + bus = response.updated_bus; + return response.result.native(); } tresult PLUGIN_API YaComponentPluginImpl::getRoutingInfo( diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 97e817e4..a5be655b 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -117,6 +117,15 @@ void Vst3Bridge::run() { return component_instances[request.instance_id]->getBusCount( request.type, request.dir); }, + [&](YaComponent::GetBusInfo& request) + -> YaComponent::GetBusInfo::Response { + const tresult result = + component_instances[request.instance_id]->getBusInfo( + request.type, request.dir, request.index, request.bus); + + return YaComponent::GetBusInfoResponse{ + .result = result, .updated_bus = request.bus}; + }, [&](const YaPluginFactory::Construct&) -> YaPluginFactory::Construct::Response { return YaPluginFactory::ConstructArgs(