diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index 7026922f..cc43a3f3 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -99,6 +99,19 @@ void Vst3Logger::log_request(bool is_host_vst, }); } +void Vst3Logger::log_request(bool is_host_vst, + const YaComponent::GetRoutingInfo& request) { + log_request_base(is_host_vst, [&](auto& message) { + message << "::getRoutingInfo(inInfo = , outInfo = )"; + }); +} + void Vst3Logger::log_request(bool is_host_vst, const YaPluginFactory::Construct&) { log_request_base(is_host_vst, @@ -147,6 +160,22 @@ void Vst3Logger::log_response(bool is_host_vst, }); } +void Vst3Logger::log_response( + bool is_host_vst, + const YaComponent::GetRoutingInfoResponse& 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 2e983e68..b9a6ea9c 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -63,6 +63,7 @@ class Vst3Logger { 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 YaComponent::GetRoutingInfo&); 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&); @@ -72,6 +73,8 @@ class Vst3Logger { 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 YaComponent::GetRoutingInfoResponse&); 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 5a8d0845..5c1abb87 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -64,6 +64,7 @@ using ControlRequest = std::variant; diff --git a/src/common/serialization/vst3/component.h b/src/common/serialization/vst3/component.h index 8e086017..a92c9a63 100644 --- a/src/common/serialization/vst3/component.h +++ b/src/common/serialization/vst3/component.h @@ -260,6 +260,44 @@ class YaComponent : public Steinberg::Vst::IComponent { Steinberg::Vst::BusDirection dir, int32 index, Steinberg::Vst::BusInfo& bus /*out*/) override = 0; + + /** + * The response code and returned routing information for a call to + * `IComponent::getRoutingInfo(inInfo, outInfo )`. + */ + struct GetRoutingInfoResponse { + UniversalTResult result; + Steinberg::Vst::RoutingInfo updated_in_info; + Steinberg::Vst::RoutingInfo updated_out_info; + + template + void serialize(S& s) { + s.object(result); + s.object(updated_in_info); + s.object(updated_out_info); + } + }; + + /** + * Message to pass through a call to `IComponent::getRoutingInfo(inInfo, + * outInfo )` to the Wine plugin host. + */ + struct GetRoutingInfo { + using Response = GetRoutingInfoResponse; + + native_size_t instance_id; + + Steinberg::Vst::RoutingInfo in_info; + Steinberg::Vst::RoutingInfo out_info; + + template + void serialize(S& s) { + s.value8b(instance_id); + s.object(in_info); + s.object(out_info); + } + }; + virtual tresult PLUGIN_API getRoutingInfo(Steinberg::Vst::RoutingInfo& inInfo, Steinberg::Vst::RoutingInfo& outInfo /*out*/) override = 0; @@ -297,5 +335,12 @@ void serialize(S& s, Steinberg::Vst::BusInfo& info) { s.value4b(info.busType); s.value4b(info.flags); } + +template +void serialize(S& s, Steinberg::Vst::RoutingInfo& info) { + s.value4b(info.mediaType); + s.value4b(info.busIndex); + s.value4b(info.channel); +} } // namespace Vst } // namespace Steinberg diff --git a/src/plugin/bridges/vst3-impls/component.cpp b/src/plugin/bridges/vst3-impls/component.cpp index c570a313..d362db06 100644 --- a/src/plugin/bridges/vst3-impls/component.cpp +++ b/src/plugin/bridges/vst3-impls/component.cpp @@ -108,9 +108,14 @@ YaComponentPluginImpl::getBusInfo(Steinberg::Vst::MediaType type, tresult PLUGIN_API YaComponentPluginImpl::getRoutingInfo( Steinberg::Vst::RoutingInfo& inInfo, Steinberg::Vst::RoutingInfo& outInfo /*out*/) { - // TODO: Implement - bridge.logger.log("TODO: IComponent::getRoutingInfo()"); - return Steinberg::kNotImplemented; + const GetRoutingInfoResponse response = bridge.send_message( + YaComponent::GetRoutingInfo{.instance_id = arguments.instance_id, + .in_info = inInfo, + .out_info = outInfo}); + + inInfo = response.updated_in_info; + outInfo = response.updated_out_info; + return response.result.native(); } tresult PLUGIN_API diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index f37f6bd8..8480ec65 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -130,6 +130,18 @@ void Vst3Bridge::run() { return YaComponent::GetBusInfoResponse{ .result = result, .updated_bus = request.bus}; }, + [&](YaComponent::GetRoutingInfo& request) + -> YaComponent::GetRoutingInfo::Response { + const tresult result = + component_instances[request.instance_id] + .component->getRoutingInfo(request.in_info, + request.out_info); + + return YaComponent::GetRoutingInfoResponse{ + .result = result, + .updated_in_info = request.in_info, + .updated_out_info = request.out_info}; + }, [&](const YaPluginFactory::Construct&) -> YaPluginFactory::Construct::Response { return YaPluginFactory::ConstructArgs(