Allow more main thread mutual recursion in CLAP

This is also needed to fix that McRocklin Suite plugin. It changes its
latency during the init call.
This commit is contained in:
Robbert van der Helm
2023-04-20 15:48:50 +02:00
parent ead4ca97c5
commit 3b213605e0
3 changed files with 16 additions and 10 deletions
+3
View File
@@ -28,6 +28,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).
request a host callback while the host simultaneously tried to create another request a host callback while the host simultaneously tried to create another
instance of the same plugin. This would result in a deadlock. An example of a instance of the same plugin. This would result in a deadlock. An example of a
plugin that triggered this is _PolyChrome DSP's McRocklin Suite_. plugin that triggered this is _PolyChrome DSP's McRocklin Suite_.
- Mutually recursive callbacks are now enabled for more CLAP lifetime function
calls. This was also needed to avoid a deadlock in _PolyChrome DSP's McRocklin
Suite_, as it changes its latency while being initialized.
### yabridgectl ### yabridgectl
@@ -77,8 +77,9 @@ clap_plugin_factory_proxy::plugin_factory_create_plugin(
} }
const clap::factory::plugin_factory::CreateResponse response = const clap::factory::plugin_factory::CreateResponse response =
self->bridge_.send_main_thread_message(clap::factory::plugin_factory::Create{ self->bridge_.send_mutually_recursive_main_thread_message(
.host = *host, .plugin_id = plugin_id}); clap::factory::plugin_factory::Create{.host = *host,
.plugin_id = plugin_id});
if (response.instance_id) { if (response.instance_id) {
// This plugin proxy is tied to the instance ID created on the Wine // This plugin proxy is tied to the instance ID created on the Wine
// side. That way we can link function calls from the host to the // side. That way we can link function calls from the host to the
+10 -8
View File
@@ -156,10 +156,12 @@ bool CLAP_ABI clap_plugin_proxy::plugin_init(const struct clap_plugin* plugin) {
// plugin host so it can expose the same interfaces there. // plugin host so it can expose the same interfaces there.
self->host_extensions_ = ClapHostExtensions(*self->host_); self->host_extensions_ = ClapHostExtensions(*self->host_);
// NOTE: McRocklin Suite changes the latency during the init call
const clap::plugin::InitResponse response = const clap::plugin::InitResponse response =
self->bridge_.send_main_thread_message(clap::plugin::Init{ self->bridge_.send_mutually_recursive_main_thread_message(
.instance_id = self->instance_id(), clap::plugin::Init{.instance_id = self->instance_id(),
.supported_host_extensions = self->host_extensions_.supported()}); .supported_host_extensions =
self->host_extensions_.supported()});
// This determines which extensions the host is allowed to query in // This determines which extensions the host is allowed to query in
// `clap_plugin::get_extension()` // `clap_plugin::get_extension()`
@@ -175,7 +177,7 @@ clap_plugin_proxy::plugin_destroy(const struct clap_plugin* plugin) {
// This will clean everything related to this instance up on the Wine plugin // This will clean everything related to this instance up on the Wine plugin
// host side // host side
self->bridge_.send_main_thread_message( self->bridge_.send_mutually_recursive_main_thread_message(
clap::plugin::Destroy{.instance_id = self->instance_id()}); clap::plugin::Destroy{.instance_id = self->instance_id()});
// And this deallocates and destroys `self` // And this deallocates and destroys `self`
@@ -220,7 +222,7 @@ clap_plugin_proxy::plugin_deactivate(const struct clap_plugin* plugin) {
assert(plugin && plugin->plugin_data); assert(plugin && plugin->plugin_data);
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data); auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
self->bridge_.send_main_thread_message( self->bridge_.send_mutually_recursive_main_thread_message(
clap::plugin::Deactivate{.instance_id = self->instance_id()}); clap::plugin::Deactivate{.instance_id = self->instance_id()});
} }
@@ -440,7 +442,7 @@ clap_plugin_proxy::ext_audio_ports_config_select(const clap_plugin_t* plugin,
assert(plugin && plugin->plugin_data); assert(plugin && plugin->plugin_data);
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data); auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
return self->bridge_.send_main_thread_message( return self->bridge_.send_mutually_recursive_main_thread_message(
clap::ext::audio_ports_config::plugin::Select{ clap::ext::audio_ports_config::plugin::Select{
.instance_id = self->instance_id(), .config_id = config_id}); .instance_id = self->instance_id(), .config_id = config_id});
} }
@@ -489,7 +491,7 @@ bool CLAP_ABI clap_plugin_proxy::ext_gui_create(const clap_plugin_t* plugin,
return false; return false;
} }
return self->bridge_.send_main_thread_message( return self->bridge_.send_mutually_recursive_main_thread_message(
clap::ext::gui::plugin::Create{ clap::ext::gui::plugin::Create{
.instance_id = self->instance_id(), .instance_id = self->instance_id(),
// This will be translated to WIN32 on the Wine plugin host side // This will be translated to WIN32 on the Wine plugin host side
@@ -501,7 +503,7 @@ void CLAP_ABI clap_plugin_proxy::ext_gui_destroy(const clap_plugin_t* plugin) {
assert(plugin && plugin->plugin_data); assert(plugin && plugin->plugin_data);
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data); auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
self->bridge_.send_main_thread_message( self->bridge_.send_mutually_recursive_main_thread_message(
clap::ext::gui::plugin::Destroy{.instance_id = self->instance_id()}); clap::ext::gui::plugin::Destroy{.instance_id = self->instance_id()});
} }