mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Fully implement IPluginBase::initialize()
We can now pass host contexts around.
This commit is contained in:
@@ -18,7 +18,7 @@ imcomplete list of things that still have to be done before this can be used:
|
|||||||
- Left to implement:
|
- Left to implement:
|
||||||
- `YaHostApplicationHostImpl::createComponent`.
|
- `YaHostApplicationHostImpl::createComponent`.
|
||||||
- `IPluginFactory3::setHostContext()` using the same host application context proxy method.
|
- `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()`
|
- `IPluginFactory3::setHostContext()`
|
||||||
- All other mandatory interfaces
|
- All other mandatory interfaces
|
||||||
- All other optional interfaces
|
- All other optional interfaces
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
|
|||||||
// always know for sure that the function returns the correct
|
// always know for sure that the function returns the correct
|
||||||
// type, and we can scrap a lot of boilerplate elsewhere.
|
// type, and we can scrap a lot of boilerplate elsewhere.
|
||||||
std::visit(
|
std::visit(
|
||||||
[&]<typename T>(const T object) {
|
[&]<typename T>(T object) {
|
||||||
typename T::Response response = callback(object);
|
typename T::Response response = callback(object);
|
||||||
|
|
||||||
if (logging) {
|
if (logging) {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include <public.sdk/source/vst/hosting/module_win32.cpp>
|
#include <public.sdk/source/vst/hosting/module_win32.cpp>
|
||||||
|
|
||||||
|
#include "vst3-impls/host-application.h"
|
||||||
|
|
||||||
Vst3Bridge::Vst3Bridge(MainContext& main_context,
|
Vst3Bridge::Vst3Bridge(MainContext& main_context,
|
||||||
std::string plugin_dll_path,
|
std::string plugin_dll_path,
|
||||||
std::string endpoint_base_dir)
|
std::string endpoint_base_dir)
|
||||||
@@ -67,18 +69,39 @@ void Vst3Bridge::run() {
|
|||||||
},
|
},
|
||||||
[&](const YaComponent::Destruct& request)
|
[&](const YaComponent::Destruct& request)
|
||||||
-> YaComponent::Destruct::Response {
|
-> 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);
|
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{};
|
return Ack{};
|
||||||
},
|
},
|
||||||
[&](const YaComponent::Initialize& request)
|
[&](YaComponent::Initialize& request)
|
||||||
-> YaComponent::Initialize::Response {
|
-> YaComponent::Initialize::Response {
|
||||||
// TODO: If `request.host_context_args` has a value, we should
|
// If we got passed a host context, we'll create a proxy object
|
||||||
// initialize a proxy object and pass a pointer to that
|
// and pass that to the initialize function. This object should
|
||||||
// instead
|
// 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(
|
return component_instances[request.instance_id]->initialize(
|
||||||
nullptr);
|
context);
|
||||||
},
|
},
|
||||||
[&](const YaComponent::Terminate& request)
|
[&](const YaComponent::Terminate& request)
|
||||||
-> YaComponent::Terminate::Response {
|
-> YaComponent::Terminate::Response {
|
||||||
|
|||||||
@@ -108,4 +108,19 @@ class Vst3Bridge : public HostBridge {
|
|||||||
std::map<size_t, Steinberg::IPtr<Steinberg::Vst::IComponent>>
|
std::map<size_t, Steinberg::IPtr<Steinberg::Vst::IComponent>>
|
||||||
component_instances;
|
component_instances;
|
||||||
std::mutex component_instances_mutex;
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user