Implement IUnitInfo::getProgramName

This commit is contained in:
Robbert van der Helm
2020-12-26 22:37:45 +01:00
parent 60f6b30b84
commit 204765ec0c
6 changed files with 88 additions and 9 deletions
+21
View File
@@ -462,6 +462,15 @@ bool Vst3Logger::log_request(bool is_host_vst,
}); });
} }
bool Vst3Logger::log_request(bool is_host_vst,
const YaUnitInfo::GetProgramName& request) {
return log_request_base(is_host_vst, [&](auto& message) {
message << request.instance_id
<< ": IUnitInfo::getProgramName(listId = " << request.list_id
<< ", programIndex = " << request.program_index << ", &name)";
});
}
bool Vst3Logger::log_request( bool Vst3Logger::log_request(
bool is_host_vst, bool is_host_vst,
const YaAudioProcessor::SetBusArrangements& request) { const YaAudioProcessor::SetBusArrangements& request) {
@@ -883,6 +892,18 @@ void Vst3Logger::log_response(
}); });
} }
void Vst3Logger::log_response(
bool is_host_vst,
const YaUnitInfo::GetProgramNameResponse& response) {
log_response_base(is_host_vst, [&](auto& message) {
message << response.result.string();
if (response.result == Steinberg::kResultOk) {
message << ", \"" << VST3::StringConvert::convert(response.name)
<< "\"";
}
});
}
void Vst3Logger::log_response( void Vst3Logger::log_response(
bool is_host_vst, bool is_host_vst,
const YaAudioProcessor::GetBusArrangementResponse& response) { const YaAudioProcessor::GetBusArrangementResponse& response) {
+3
View File
@@ -112,6 +112,7 @@ class Vst3Logger {
bool log_request(bool is_host_vst, const YaUnitInfo::GetUnitInfo&); bool log_request(bool is_host_vst, const YaUnitInfo::GetUnitInfo&);
bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramListCount&); bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramListCount&);
bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramListInfo&); bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramListInfo&);
bool log_request(bool is_host_vst, const YaUnitInfo::GetProgramName&);
bool log_request(bool is_host_vst, bool log_request(bool is_host_vst,
const YaAudioProcessor::SetBusArrangements&); const YaAudioProcessor::SetBusArrangements&);
@@ -168,6 +169,8 @@ class Vst3Logger {
void log_response(bool is_host_vst, const YaUnitInfo::GetUnitInfoResponse&); void log_response(bool is_host_vst, const YaUnitInfo::GetUnitInfoResponse&);
void log_response(bool is_host_vst, void log_response(bool is_host_vst,
const YaUnitInfo::GetProgramListInfoResponse&); const YaUnitInfo::GetProgramListInfoResponse&);
void log_response(bool is_host_vst,
const YaUnitInfo::GetProgramNameResponse&);
void log_response(bool is_host_vst, void log_response(bool is_host_vst,
const YaAudioProcessor::GetBusArrangementResponse&); const YaAudioProcessor::GetBusArrangementResponse&);
+2 -1
View File
@@ -103,7 +103,8 @@ using ControlRequest = std::variant<Vst3PlugViewProxy::Destruct,
YaUnitInfo::GetUnitCount, YaUnitInfo::GetUnitCount,
YaUnitInfo::GetUnitInfo, YaUnitInfo::GetUnitInfo,
YaUnitInfo::GetProgramListCount, YaUnitInfo::GetProgramListCount,
YaUnitInfo::GetProgramListInfo>; YaUnitInfo::GetProgramListInfo,
YaUnitInfo::GetProgramName>;
template <typename S> template <typename S>
void serialize(S& s, ControlRequest& payload) { void serialize(S& s, ControlRequest& payload) {
@@ -81,7 +81,7 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo {
/** /**
* The response code and returned unit information for a call to * The response code and returned unit information for a call to
* `IUnitInfo::getUnitInfo(unit_index)`. * `IUnitInfo::getUnitInfo(unit_index, &info)`.
*/ */
struct GetUnitInfoResponse { struct GetUnitInfoResponse {
UniversalTResult result; UniversalTResult result;
@@ -95,8 +95,8 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo {
}; };
/** /**
* Message to pass through a call to `IUnitInfo::getUnitInfo(unit_index)` to * Message to pass through a call to `IUnitInfo::getUnitInfo(unit_index,
* the Wine plugin host. * &info)` to the Wine plugin host.
*/ */
struct GetUnitInfo { struct GetUnitInfo {
using Response = GetUnitInfoResponse; using Response = GetUnitInfoResponse;
@@ -135,7 +135,7 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo {
/** /**
* The response code and returned unit information for a call to * The response code and returned unit information for a call to
* `IUnitInfo::getProgramListInfo(list_index)`. * `IUnitInfo::getProgramListInfo(list_index, &info)`.
*/ */
struct GetProgramListInfoResponse { struct GetProgramListInfoResponse {
UniversalTResult result; UniversalTResult result;
@@ -150,7 +150,8 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo {
/** /**
* Message to pass through a call to * Message to pass through a call to
* `IUnitInfo::getProgramListInfo(list_index)` to the Wine plugin host. * `IUnitInfo::getProgramListInfo(list_index, &info)` to the Wine plugin
* host.
*/ */
struct GetProgramListInfo { struct GetProgramListInfo {
using Response = GetProgramListInfoResponse; using Response = GetProgramListInfoResponse;
@@ -169,6 +170,42 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo {
virtual tresult PLUGIN_API getProgramListInfo( virtual tresult PLUGIN_API getProgramListInfo(
int32 listIndex, int32 listIndex,
Steinberg::Vst::ProgramListInfo& info /*out*/) override = 0; Steinberg::Vst::ProgramListInfo& info /*out*/) override = 0;
/**
* The response code and returned name for a call to
* `IUnitInfo::getProgramName(list_id, program_index, &name)`.
*/
struct GetProgramNameResponse {
UniversalTResult result;
std::u16string name;
template <typename S>
void serialize(S& s) {
s.object(result);
s.text2b(name, std::extent_v<Steinberg::Vst::String128>);
}
};
/**
* Message to pass through a call to `IUnitInfo::getProgramName(list_id,
* program_index, &name)` to the Wine plugin host.
*/
struct GetProgramName {
using Response = GetProgramNameResponse;
native_size_t instance_id;
Steinberg::Vst::ProgramListID list_id;
int32 program_index;
template <typename S>
void serialize(S& s) {
s.value8b(instance_id);
s.value4b(list_id);
s.value4b(program_index);
}
};
virtual tresult PLUGIN_API virtual tresult PLUGIN_API
getProgramName(Steinberg::Vst::ProgramListID listId, getProgramName(Steinberg::Vst::ProgramListID listId,
int32 programIndex, int32 programIndex,
@@ -478,9 +478,15 @@ tresult PLUGIN_API
Vst3PluginProxyImpl::getProgramName(Steinberg::Vst::ProgramListID listId, Vst3PluginProxyImpl::getProgramName(Steinberg::Vst::ProgramListID listId,
int32 programIndex, int32 programIndex,
Steinberg::Vst::String128 name /*out*/) { Steinberg::Vst::String128 name /*out*/) {
// TODO: Implement const GetProgramNameResponse response = bridge.send_message(
bridge.logger.log("TODO: IUnitInfo::getProgramName()"); YaUnitInfo::GetProgramName{.instance_id = instance_id(),
return Steinberg::kNotImplemented; .list_id = listId,
.program_index = programIndex});
std::copy(response.name.begin(), response.name.end(), name);
name[response.name.size()] = 0;
return response.result;
} }
tresult PLUGIN_API Vst3PluginProxyImpl::getProgramInfo( tresult PLUGIN_API Vst3PluginProxyImpl::getProgramInfo(
+11
View File
@@ -596,6 +596,17 @@ void Vst3Bridge::run() {
return YaUnitInfo::GetProgramListInfoResponse{.result = result, return YaUnitInfo::GetProgramListInfoResponse{.result = result,
.info = info}; .info = info};
}, },
[&](const YaUnitInfo::GetProgramName& request)
-> YaUnitInfo::GetProgramName::Response {
Steinberg::Vst::String128 name{0};
const tresult result =
object_instances[request.instance_id]
.unit_info->getProgramName(request.list_id,
request.program_index, name);
return YaUnitInfo::GetProgramNameResponse{
.result = result, .name = tchar_pointer_to_u16string(name)};
},
}); });
} }