Unify handling for *::{get,set}State

Since these functions are exactly the same, and for whatever reason they
didn't just add them to the `IPluginBase` both `IComponent` and
`IEditController`. inherit from
This commit is contained in:
Robbert van der Helm
2020-12-17 17:52:51 +01:00
parent d8694b062b
commit fe2de8de8d
9 changed files with 136 additions and 108 deletions
+30 -15
View File
@@ -106,6 +106,36 @@ void Vst3Bridge::run() {
return Ack{};
},
[&](Vst3PluginProxy::SetState& request)
-> Vst3PluginProxy::SetState::Response {
// This same function is defined in both `IComponent` and
// `IEditController`, so the host is calling one or the other
if (object_instances[request.instance_id].component) {
return object_instances[request.instance_id]
.component->setState(&request.state);
} else {
return object_instances[request.instance_id]
.edit_controller->setState(&request.state);
}
},
[&](Vst3PluginProxy::GetState& request)
-> Vst3PluginProxy::GetState::Response {
VectorStream stream;
tresult result;
// This same function is defined in both `IComponent` and
// `IEditController`, so the host is calling one or the other
if (object_instances[request.instance_id].component) {
result = object_instances[request.instance_id]
.component->getState(&stream);
} else {
result = object_instances[request.instance_id]
.edit_controller->getState(&stream);
}
return Vst3PluginProxy::GetStateResponse{
.result = result, .updated_state = std::move(stream)};
},
[&](YaAudioProcessor::SetBusArrangements& request)
-> YaAudioProcessor::SetBusArrangements::Response {
return object_instances[request.instance_id]
@@ -201,21 +231,6 @@ void Vst3Bridge::run() {
return object_instances[request.instance_id]
.component->setActive(request.state);
},
[&](YaComponent::SetState& request)
-> YaComponent::SetState::Response {
return object_instances[request.instance_id]
.component->setState(&request.state);
},
[&](YaComponent::GetState& request)
-> YaComponent::GetState::Response {
VectorStream stream;
const tresult result =
object_instances[request.instance_id].component->getState(
&stream);
return YaComponent::GetStateResponse{
.result = result, .updated_state = std::move(stream)};
},
[&](YaPluginBase::Initialize& request)
-> YaPluginBase::Initialize::Response {
// If we got passed a host context, we'll create a proxy object