mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 04:20:13 +02:00
Add restart and process request callbacks
This commit is contained in:
@@ -22,7 +22,8 @@ clap_plugin_proxy::clap_plugin_proxy(ClapPluginBridge& bridge,
|
||||
size_t instance_id,
|
||||
clap::plugin::Descriptor descriptor,
|
||||
const clap_host_t* host)
|
||||
: bridge_(bridge),
|
||||
: host_(host),
|
||||
bridge_(bridge),
|
||||
instance_id_(instance_id),
|
||||
descriptor_(std::move(descriptor)),
|
||||
plugin_vtable_(clap_plugin_t{
|
||||
@@ -39,7 +40,6 @@ clap_plugin_proxy::clap_plugin_proxy(ClapPluginBridge& bridge,
|
||||
.get_extension = plugin_get_extension,
|
||||
.on_main_thread = plugin_on_main_thread,
|
||||
}),
|
||||
host_(host),
|
||||
// These function objects are relatively large, and we probably won't be
|
||||
// getting that many of them
|
||||
pending_callbacks_(128) {}
|
||||
|
||||
@@ -121,6 +121,12 @@ class clap_plugin_proxy {
|
||||
return response_future;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `clap_host_t*` passed when creating the instance. Any callbacks made
|
||||
* by the proxied plugin instance must go through ere.
|
||||
*/
|
||||
const clap_host_t* host_;
|
||||
|
||||
private:
|
||||
ClapPluginBridge& bridge_;
|
||||
size_t instance_id_;
|
||||
@@ -140,12 +146,6 @@ class clap_plugin_proxy {
|
||||
*/
|
||||
clap::plugin::SupportedPluginExtensions supported_extensions_;
|
||||
|
||||
/**
|
||||
* The `clap_host_t*` passed when creating the instance. Any callbacks made
|
||||
* by the proxied plugin instance must go through ere.
|
||||
*/
|
||||
const clap_host_t* host_;
|
||||
|
||||
/**
|
||||
* Pending callbacks that must be sent to the host on the main thread. If a
|
||||
* socket needs to make a main thread function call, it will
|
||||
|
||||
@@ -46,7 +46,6 @@ ClapPluginBridge::ClapPluginBridge(const ghc::filesystem::path& plugin_path)
|
||||
set_realtime_priority(true);
|
||||
pthread_setname_np(pthread_self(), "host-callbacks");
|
||||
|
||||
// TODO: Add the rest of the callbacks
|
||||
sockets_.plugin_host_main_thread_callback_.receive_messages(
|
||||
std::pair<ClapLogger&, bool>(logger_, false),
|
||||
overload{
|
||||
@@ -56,6 +55,32 @@ ClapPluginBridge::ClapPluginBridge(const ghc::filesystem::path& plugin_path)
|
||||
|
||||
return config_;
|
||||
},
|
||||
[&](const clap::host::RequestRestart& request)
|
||||
-> clap::host::RequestRestart::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
plugin_proxy
|
||||
.run_on_main_thread([host = plugin_proxy.host_]() {
|
||||
host->request_restart(host);
|
||||
})
|
||||
.wait();
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
[&](const clap::host::RequestProcess& request)
|
||||
-> clap::host::RequestProcess::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
plugin_proxy
|
||||
.run_on_main_thread([host = plugin_proxy.host_]() {
|
||||
host->request_process(host);
|
||||
})
|
||||
.wait();
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user