From 70c57925935dba20881d97b5086dd693bab00d7e Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 27 Dec 2020 16:48:47 +0100 Subject: [PATCH] Implement IUnitInfo::getSelectedUnit --- src/common/logging/vst3.cpp | 7 +++++++ src/common/logging/vst3.h | 1 + src/common/serialization/vst3.h | 3 ++- src/common/serialization/vst3/plugin/unit-info.h | 16 ++++++++++++++++ src/plugin/bridges/vst3-impls/plugin-proxy.cpp | 5 ++--- src/wine-host/bridges/vst3.cpp | 5 +++++ 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index 248dbf07..61dcfdcb 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -503,6 +503,13 @@ bool Vst3Logger::log_request(bool is_host_vst, }); } +bool Vst3Logger::log_request(bool is_host_vst, + const YaUnitInfo::GetSelectedUnit& request) { + return log_request_base(is_host_vst, [&](auto& message) { + message << request.instance_id << ": IUnitInfo::getSelectedUnit()"; + }); +} + bool Vst3Logger::log_request( bool is_host_vst, const YaAudioProcessor::SetBusArrangements& request) { diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index 173b0b63..3556df14 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -116,6 +116,7 @@ class Vst3Logger { bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramInfo&); bool log_request(bool is_host_vst, const YaUnitInfo::HasProgramPitchNames&); bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramPitchName&); + bool log_request(bool is_host_vst, const YaUnitInfo::GetSelectedUnit&); bool log_request(bool is_host_vst, const YaAudioProcessor::SetBusArrangements&); diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index d40757f3..b8c88840 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -107,7 +107,8 @@ using ControlRequest = std::variant; + YaUnitInfo::GetProgramPitchName, + YaUnitInfo::GetSelectedUnit>; template void serialize(S& s, ControlRequest& payload) { diff --git a/src/common/serialization/vst3/plugin/unit-info.h b/src/common/serialization/vst3/plugin/unit-info.h index 48402fdd..a206537d 100644 --- a/src/common/serialization/vst3/plugin/unit-info.h +++ b/src/common/serialization/vst3/plugin/unit-info.h @@ -324,6 +324,22 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo { int32 programIndex, int16 midiPitch, Steinberg::Vst::String128 name /*out*/) override = 0; + + /** + * Message to pass through a call to `IUnitInfo::getSelectedUnit()` to the + * Wine plugin host. + */ + struct GetSelectedUnit { + using Response = PrimitiveWrapper; + + native_size_t instance_id; + + template + void serialize(S& s) { + s.value8b(instance_id); + } + }; + virtual Steinberg::Vst::UnitID PLUGIN_API getSelectedUnit() override = 0; virtual tresult PLUGIN_API selectUnit(Steinberg::Vst::UnitID unitId) override = 0; diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index db48af26..7916333a 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -536,9 +536,8 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramPitchName( } Steinberg::Vst::UnitID PLUGIN_API Vst3PluginProxyImpl::getSelectedUnit() { - // TODO: Implement - bridge.logger.log("TODO: IUnitInfo::getSelectedUnit()"); - return Steinberg::kNotImplemented; + return bridge.send_message( + YaUnitInfo::GetSelectedUnit{.instance_id = instance_id()}); } tresult PLUGIN_API diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index bfd15565..17a2a650 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -639,6 +639,11 @@ void Vst3Bridge::run() { return YaUnitInfo::GetProgramPitchNameResponse{ .result = result, .name = tchar_pointer_to_u16string(name)}; }, + [&](const YaUnitInfo::GetSelectedUnit& request) + -> YaUnitInfo::GetSelectedUnit::Response { + return object_instances[request.instance_id] + .unit_info->getSelectedUnit(); + }, }); }