Split off IComponent and create a monolithic class

We can now use implement all VST3 plugin interfaces through this class,
check whether the object from the plugin also supports these classes,
and then conditionally allow casting to the supported classes. This
should give us a one-to-one proxy of the original object.
This commit is contained in:
Robbert van der Helm
2020-12-17 12:48:10 +01:00
parent d6c28f48d9
commit d8b2646563
22 changed files with 422 additions and 285 deletions
+30 -29
View File
@@ -60,6 +60,34 @@ void Vst3Bridge::run() {
sockets.host_vst_control.receive_messages(
std::nullopt,
overload{
[&](const YaPluginMonolith::Construct& args)
-> YaPluginMonolith::Construct::Response {
Steinberg::TUID cid;
std::copy(args.cid.begin(), args.cid.end(), cid);
Steinberg::IPtr<Steinberg::Vst::IComponent> component =
module->getFactory()
.createInstance<Steinberg::Vst::IComponent>(cid);
if (component) {
std::lock_guard lock(component_instances_mutex);
const size_t instance_id = generate_instance_id();
component_instances[instance_id] = std::move(component);
return YaPluginMonolith::ConstructArgs(
component_instances[instance_id].component,
instance_id);
} else {
// The actual result is lost here
return UniversalTResult(Steinberg::kNotImplemented);
}
},
[&](const YaPluginMonolith::Destruct& request)
-> YaPluginMonolith::Destruct::Response {
std::lock_guard lock(component_instances_mutex);
component_instances.erase(request.instance_id);
return Ack{};
},
[&](YaAudioProcessor::SetBusArrangements& request)
-> YaAudioProcessor::SetBusArrangements::Response {
return component_instances[request.instance_id]
@@ -113,34 +141,6 @@ void Vst3Bridge::run() {
return component_instances[request.instance_id]
.audio_processor->getTailSamples();
},
[&](const YaComponent::Construct& args)
-> YaComponent::Construct::Response {
Steinberg::TUID cid;
std::copy(args.cid.begin(), args.cid.end(), cid);
Steinberg::IPtr<Steinberg::Vst::IComponent> component =
module->getFactory()
.createInstance<Steinberg::Vst::IComponent>(cid);
if (component) {
std::lock_guard lock(component_instances_mutex);
const size_t instance_id = generate_instance_id();
component_instances[instance_id] = std::move(component);
return YaComponent::ConstructArgs(
component_instances[instance_id].component,
instance_id);
} else {
// The actual result is lost here
return UniversalTResult(Steinberg::kNotImplemented);
}
},
[&](const YaComponent::Destruct& request)
-> YaComponent::Destruct::Response {
std::lock_guard lock(component_instances_mutex);
component_instances.erase(request.instance_id);
return Ack{};
},
[&](const YaComponent::SetIoMode& request)
-> YaComponent::SetIoMode::Response {
return component_instances[request.instance_id]
@@ -202,7 +202,8 @@ void Vst3Bridge::run() {
-> YaPluginBase::Initialize::Response {
// If we got passed a host context, we'll create a proxy object
// and pass that to the initialize function. This object should
// be cleaned up again during `YaComponent::Destruct`.
// be cleaned up again during `YaPluginMonolith::Destruct`.
// TOOD: This needs changing when we get to `YaHostMonolith`
Steinberg::FUnknown* context = nullptr;
if (request.host_application_context_args) {
component_instances[request.instance_id]