Fully implement IPluginBase::initialize()

We can now pass host contexts around.
This commit is contained in:
Robbert van der Helm
2020-12-13 15:16:11 +01:00
parent 0c64aabeea
commit 7c5f7a2e0e
4 changed files with 46 additions and 8 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ imcomplete list of things that still have to be done before this can be used:
- Left to implement:
- `YaHostApplicationHostImpl::createComponent`.
- `IPluginFactory3::setHostContext()` using the same host application context proxy method.
- The rest of `IComponent`'s functions after implementing `intialize()`
- The rest of `IComponent`'s functions
- `IPluginFactory3::setHostContext()`
- All other mandatory interfaces
- All other optional interfaces
+1 -1
View File
@@ -180,7 +180,7 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
// always know for sure that the function returns the correct
// type, and we can scrap a lot of boilerplate elsewhere.
std::visit(
[&]<typename T>(const T object) {
[&]<typename T>(T object) {
typename T::Response response = callback(object);
if (logging) {
+29 -6
View File
@@ -20,6 +20,8 @@
#include <public.sdk/source/vst/hosting/module_win32.cpp>
#include "vst3-impls/host-application.h"
Vst3Bridge::Vst3Bridge(MainContext& main_context,
std::string plugin_dll_path,
std::string endpoint_base_dir)
@@ -67,18 +69,39 @@ void Vst3Bridge::run() {
},
[&](const YaComponent::Destruct& request)
-> YaComponent::Destruct::Response {
std::lock_guard lock(component_instances_mutex);
std::scoped_lock lock(
component_instances_mutex,
component_host_application_context_instance_mutex);
component_instances.erase(request.instance_id);
if (component_host_application_context_instances.contains(
request.instance_id)) {
component_host_application_context_instances.erase(
request.instance_id);
}
return Ack{};
},
[&](const YaComponent::Initialize& request)
[&](YaComponent::Initialize& request)
-> YaComponent::Initialize::Response {
// TODO: If `request.host_context_args` has a value, we should
// initialize a proxy object and pass a pointer to that
// instead
// 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`.
Steinberg::FUnknown* context = nullptr;
if (request.host_application_context_args) {
// TODO: Is this safe? These Steinberg smart pointers are
// scary
component_host_application_context_instances
[request.instance_id] =
Steinberg::owned(new YaHostApplicationHostImpl(
*this,
std::move(
*request.host_application_context_args)));
context = component_host_application_context_instances
[request.instance_id];
}
return component_instances[request.instance_id]->initialize(
nullptr);
context);
},
[&](const YaComponent::Terminate& request)
-> YaComponent::Terminate::Response {
+15
View File
@@ -108,4 +108,19 @@ class Vst3Bridge : public HostBridge {
std::map<size_t, Steinberg::IPtr<Steinberg::Vst::IComponent>>
component_instances;
std::mutex component_instances_mutex;
/**
* If an `IHostApplication` was passed during
* `{IPluginBase,IComponent}::initialize()`, then we'll store a proxy object
* here. The instance ID is the same as the corresponding instance ID in
* `component_instances`. When an instance gets removed from
* `component_instances`, it should also be removed from here.
*
* XXX: If it turns out we need to keep track of more of these kinds of
* objects, then we should create a wrapper so that everything can stay
* in `component_instances`
*/
std::map<size_t, Steinberg::IPtr<YaHostApplication>>
component_host_application_context_instances;
std::mutex component_host_application_context_instance_mutex;
};