mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-17 14:10:02 +02:00
Run all other lifecycle events on main thread
This is probably where plugins instantiate timers for their GUI updates.
This commit is contained in:
@@ -86,20 +86,35 @@ void Vst3Bridge::run() {
|
|||||||
// Even though we're requesting a specific interface (to mimic
|
// Even though we're requesting a specific interface (to mimic
|
||||||
// what the host is doing), we're immediately upcasting it to an
|
// what the host is doing), we're immediately upcasting it to an
|
||||||
// `FUnknown` so we can create a perfect proxy object.
|
// `FUnknown` so we can create a perfect proxy object.
|
||||||
Steinberg::IPtr<Steinberg::FUnknown> object;
|
// We create the object from the GUI thread in case it
|
||||||
switch (request.requested_interface) {
|
// immediatly starts timers or something (even though it
|
||||||
case Vst3PluginProxy::Construct::Interface::IComponent:
|
// shouldn't)
|
||||||
object =
|
Steinberg::IPtr<Steinberg::FUnknown> object =
|
||||||
module->getFactory()
|
main_context
|
||||||
.createInstance<Steinberg::Vst::IComponent>(
|
.run_in_context<Steinberg::IPtr<Steinberg::FUnknown>>(
|
||||||
cid);
|
[&]() -> Steinberg::IPtr<Steinberg::FUnknown> {
|
||||||
break;
|
switch (request.requested_interface) {
|
||||||
case Vst3PluginProxy::Construct::Interface::IEditController:
|
case Vst3PluginProxy::Construct::Interface::
|
||||||
object = module->getFactory()
|
IComponent:
|
||||||
.createInstance<
|
return module->getFactory()
|
||||||
Steinberg::Vst::IEditController>(cid);
|
.createInstance<
|
||||||
break;
|
Steinberg::Vst::IComponent>(
|
||||||
}
|
cid);
|
||||||
|
break;
|
||||||
|
case Vst3PluginProxy::Construct::Interface::
|
||||||
|
IEditController:
|
||||||
|
return module->getFactory()
|
||||||
|
.createInstance<
|
||||||
|
Steinberg::Vst::
|
||||||
|
IEditController>(cid);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Unreachable
|
||||||
|
return nullptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
if (object) {
|
if (object) {
|
||||||
std::lock_guard lock(object_instances_mutex);
|
std::lock_guard lock(object_instances_mutex);
|
||||||
@@ -490,15 +505,26 @@ void Vst3Bridge::run() {
|
|||||||
nullptr;
|
nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return object_instances[request.instance_id]
|
// XXX: Should `IPlugView::{initialize,terminate}` be run from
|
||||||
.plugin_base->initialize(
|
// the main UI thread? I can see how plugins would want to
|
||||||
object_instances[request.instance_id]
|
// start timers from here.
|
||||||
.host_context_proxy);
|
return main_context
|
||||||
|
.run_in_context<tresult>([&]() {
|
||||||
|
return object_instances[request.instance_id]
|
||||||
|
.plugin_base->initialize(
|
||||||
|
object_instances[request.instance_id]
|
||||||
|
.host_context_proxy);
|
||||||
|
})
|
||||||
|
.get();
|
||||||
},
|
},
|
||||||
[&](const YaPluginBase::Terminate& request)
|
[&](const YaPluginBase::Terminate& request)
|
||||||
-> YaPluginBase::Terminate::Response {
|
-> YaPluginBase::Terminate::Response {
|
||||||
return object_instances[request.instance_id]
|
return main_context
|
||||||
.plugin_base->terminate();
|
.run_in_context<tresult>([&]() {
|
||||||
|
return object_instances[request.instance_id]
|
||||||
|
.plugin_base->terminate();
|
||||||
|
})
|
||||||
|
.get();
|
||||||
},
|
},
|
||||||
[&](const YaPluginFactory::Construct&)
|
[&](const YaPluginFactory::Construct&)
|
||||||
-> YaPluginFactory::Construct::Response {
|
-> YaPluginFactory::Construct::Response {
|
||||||
|
|||||||
Reference in New Issue
Block a user