diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index 26c51aa2..583b0f59 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -437,6 +437,15 @@ bool Vst3Logger::log_request(bool is_host_vst, }); } +bool Vst3Logger::log_request(bool is_host_vst, + const YaUnitInfo::GetUnitInfo& request) { + return log_request_base(is_host_vst, [&](auto& message) { + message << request.instance_id + << ": IUnitInfo::getUnitInfo(unitIndex = " << request.unit_index + << ", &info)"; + }); +} + bool Vst3Logger::log_request( bool is_host_vst, const YaAudioProcessor::SetBusArrangements& request) { @@ -828,6 +837,23 @@ void Vst3Logger::log_response(bool is_host_vst, }); } +void Vst3Logger::log_response(bool is_host_vst, const Configuration&) { + log_response_base(is_host_vst, + [&](auto& message) { message << ""; }); +} + +void Vst3Logger::log_response(bool is_host_vst, + const YaUnitInfo::GetUnitInfoResponse& response) { + log_response_base(is_host_vst, [&](auto& message) { + message << response.result.string(); + if (response.result == Steinberg::kResultOk) { + message << ", "; + } + }); +} + void Vst3Logger::log_response( bool is_host_vst, const YaAudioProcessor::GetBusArrangementResponse& response) { @@ -919,11 +945,6 @@ void Vst3Logger::log_response( }); } -void Vst3Logger::log_response(bool is_host_vst, const Configuration&) { - log_response_base(is_host_vst, - [&](auto& message) { message << ""; }); -} - void Vst3Logger::log_response( bool is_host_vst, const YaHostApplication::GetNameResponse& response) { diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index 9e9c261d..67d0a7c0 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -109,6 +109,7 @@ class Vst3Logger { bool log_request(bool is_host_vst, const YaPluginFactory::Construct&); bool log_request(bool is_host_vst, const YaPluginFactory::SetHostContext&); bool log_request(bool is_host_vst, const YaUnitInfo::GetUnitCount&); + bool log_request(bool is_host_vst, const YaUnitInfo::GetUnitInfo&); bool log_request(bool is_host_vst, const YaAudioProcessor::SetBusArrangements&); @@ -162,6 +163,7 @@ class Vst3Logger { void log_response(bool is_host_vst, const YaPlugView::GetSizeResponse&); void log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs&); void log_response(bool is_host_vst, const Configuration&); + void log_response(bool is_host_vst, const YaUnitInfo::GetUnitInfoResponse&); void log_response(bool is_host_vst, const YaAudioProcessor::GetBusArrangementResponse&); diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index 270a0bfc..f8406b39 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -100,7 +100,8 @@ using ControlRequest = std::variant; + YaUnitInfo::GetUnitCount, + YaUnitInfo::GetUnitInfo>; template void serialize(S& s, ControlRequest& payload) { diff --git a/src/common/serialization/vst3/plugin/component.h b/src/common/serialization/vst3/plugin/component.h index 9449e6fb..7ca7f0db 100644 --- a/src/common/serialization/vst3/plugin/component.h +++ b/src/common/serialization/vst3/plugin/component.h @@ -32,6 +32,9 @@ * part of `Vst3PluginProxy`. Event though `IComponent` inherits from * `IPlguinBase`, we'll implement that separately in `YaPluginBase` because * `IEditController` also inherits from `IPluginBase`. + * + * TODO: Remove the original fields for out parameters in the structs. They're + * really supposed to be empty. */ class YaComponent : public Steinberg::Vst::IComponent { public: diff --git a/src/common/serialization/vst3/plugin/unit-info.h b/src/common/serialization/vst3/plugin/unit-info.h index 561ff788..78f0af98 100644 --- a/src/common/serialization/vst3/plugin/unit-info.h +++ b/src/common/serialization/vst3/plugin/unit-info.h @@ -78,6 +78,40 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo { }; virtual int32 PLUGIN_API getUnitCount() override = 0; + + /** + * The response code and returned unit information for a call to + * `IUnitInfo::getUnitInfo(unit_index)`. + */ + struct GetUnitInfoResponse { + UniversalTResult result; + Steinberg::Vst::UnitInfo info; + + template + void serialize(S& s) { + s.object(result); + s.object(info); + } + }; + + /** + * Message to pass through a call to `IUnitInfo::getUnitInfo(unit_index)` to + * the Wine plugin host. + */ + struct GetUnitInfo { + using Response = GetUnitInfoResponse; + + native_size_t instance_id; + + int32 unit_index; + + template + void serialize(S& s) { + s.value8b(instance_id); + s.value4b(unit_index); + } + }; + virtual tresult PLUGIN_API getUnitInfo(int32 unitIndex, Steinberg::Vst::UnitInfo& info /*out*/) override = 0; @@ -121,3 +155,15 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo { }; #pragma GCC diagnostic pop + +namespace Steinberg { +namespace Vst { +template +void serialize(S& s, UnitInfo& info) { + s.value4b(info.id); + s.value4b(info.parentUnitId); + s.text2b(info.name); + s.value4b(info.programListId); +} +} // namespace Vst +} // namespace Steinberg diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index 44b1aa06..71fdd72a 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -448,9 +448,13 @@ int32 PLUGIN_API Vst3PluginProxyImpl::getUnitCount() { tresult PLUGIN_API Vst3PluginProxyImpl::getUnitInfo(int32 unitIndex, Steinberg::Vst::UnitInfo& info /*out*/) { - // TODO: Implement - bridge.logger.log("TODO: IUnitInfo::getUnitInfo()"); - return Steinberg::kNotImplemented; + const GetUnitInfoResponse response = + bridge.send_message(YaUnitInfo::GetUnitInfo{ + .instance_id = instance_id(), .unit_index = unitIndex}); + + info = response.info; + + return response.result; } int32 PLUGIN_API Vst3PluginProxyImpl::getProgramListCount() { diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 4bbd69e7..1bd0058c 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -571,6 +571,16 @@ void Vst3Bridge::run() { return object_instances[request.instance_id] .unit_info->getUnitCount(); }, + [&](const YaUnitInfo::GetUnitInfo& request) + -> YaUnitInfo::GetUnitInfo::Response { + Steinberg::Vst::UnitInfo info; + const tresult result = + object_instances[request.instance_id] + .unit_info->getUnitInfo(request.unit_index, info); + + return YaUnitInfo::GetUnitInfoResponse{.result = result, + .info = info}; + }, }); }