Implement IUnitInfo::getUnitInfo

This commit is contained in:
Robbert van der Helm
2020-12-26 22:03:26 +01:00
parent f3e706a39a
commit 5e832a2689
7 changed files with 96 additions and 9 deletions
+26 -5
View File
@@ -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 << "<Configuration>"; });
}
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 << ", <UnitInfo for \""
<< VST3::StringConvert::convert(response.info.name)
<< "\">";
}
});
}
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 << "<Configuration>"; });
}
void Vst3Logger::log_response(
bool is_host_vst,
const YaHostApplication::GetNameResponse& response) {
+2
View File
@@ -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&);
+2 -1
View File
@@ -100,7 +100,8 @@ using ControlRequest = std::variant<Vst3PlugViewProxy::Destruct,
YaPluginBase::Terminate,
YaPluginFactory::Construct,
YaPluginFactory::SetHostContext,
YaUnitInfo::GetUnitCount>;
YaUnitInfo::GetUnitCount,
YaUnitInfo::GetUnitInfo>;
template <typename S>
void serialize(S& s, ControlRequest& payload) {
@@ -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:
@@ -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 <typename S>
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 <typename S>
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 <typename S>
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
@@ -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() {
+10
View File
@@ -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};
},
});
}