Fully implement the CLAP tail extension

Trivial extension, but this required us to be able to send audio thread
callbacks first.
This commit is contained in:
Robbert van der Helm
2022-09-26 17:57:49 +02:00
parent 53c9fbb376
commit de028faf70
13 changed files with 91 additions and 29 deletions
@@ -56,6 +56,9 @@ clap_host_proxy::clap_host_proxy(ClapBridge& bridge,
.rescan = ext_params_rescan,
.clear = ext_params_clear,
.request_flush = ext_params_request_flush,
}),
ext_tail_vtable(clap_host_tail_t{
.changed = ext_tail_changed,
}) {}
const void* CLAP_ABI
@@ -74,6 +77,9 @@ clap_host_proxy::host_get_extension(const struct clap_host* host,
} else if (self->supported_extensions_.supports_params &&
strcmp(extension_id, CLAP_EXT_PARAMS) == 0) {
extension_ptr = &self->ext_params_vtable;
} else if (self->supported_extensions_.supports_tail &&
strcmp(extension_id, CLAP_EXT_TAIL) == 0) {
extension_ptr = &self->ext_tail_vtable;
}
self->bridge_.logger_.log_extension_query("clap_host::get_extension",
@@ -135,7 +141,7 @@ bool CLAP_ABI clap_host_proxy::ext_audio_ports_is_rescan_flag_supported(
const clap_host_t* host,
uint32_t flag) {
assert(host && host->host_data);
auto self = static_cast<clap_host_proxy*>(host->host_data);
auto self = static_cast<const clap_host_proxy*>(host->host_data);
return self->bridge_.send_main_thread_message(
clap::ext::audio_ports::host::IsRescanFlagSupported{
@@ -145,7 +151,7 @@ bool CLAP_ABI clap_host_proxy::ext_audio_ports_is_rescan_flag_supported(
void CLAP_ABI clap_host_proxy::ext_audio_ports_rescan(const clap_host_t* host,
uint32_t flags) {
assert(host && host->host_data);
auto self = static_cast<clap_host_proxy*>(host->host_data);
auto self = static_cast<const clap_host_proxy*>(host->host_data);
self->bridge_.send_main_thread_message(clap::ext::audio_ports::host::Rescan{
.owner_instance_id = self->owner_instance_id(), .flags = flags});
@@ -154,7 +160,7 @@ void CLAP_ABI clap_host_proxy::ext_audio_ports_rescan(const clap_host_t* host,
uint32_t CLAP_ABI
clap_host_proxy::ext_note_ports_supported_dialects(const clap_host_t* host) {
assert(host && host->host_data);
auto self = static_cast<clap_host_proxy*>(host->host_data);
auto self = static_cast<const clap_host_proxy*>(host->host_data);
return self->bridge_.send_main_thread_message(
clap::ext::note_ports::host::SupportedDialects{
@@ -164,7 +170,7 @@ clap_host_proxy::ext_note_ports_supported_dialects(const clap_host_t* host) {
void CLAP_ABI clap_host_proxy::ext_note_ports_rescan(const clap_host_t* host,
uint32_t flags) {
assert(host && host->host_data);
auto self = static_cast<clap_host_proxy*>(host->host_data);
auto self = static_cast<const clap_host_proxy*>(host->host_data);
self->bridge_.send_main_thread_message(clap::ext::note_ports::host::Rescan{
.owner_instance_id = self->owner_instance_id(), .flags = flags});
@@ -174,7 +180,7 @@ void CLAP_ABI
clap_host_proxy::ext_params_rescan(const clap_host_t* host,
clap_param_rescan_flags flags) {
assert(host && host->host_data);
auto self = static_cast<clap_host_proxy*>(host->host_data);
auto self = static_cast<const clap_host_proxy*>(host->host_data);
self->bridge_.send_main_thread_message(clap::ext::params::host::Rescan{
.owner_instance_id = self->owner_instance_id(), .flags = flags});
@@ -184,7 +190,7 @@ void CLAP_ABI clap_host_proxy::ext_params_clear(const clap_host_t* host,
clap_id param_id,
clap_param_clear_flags flags) {
assert(host && host->host_data);
auto self = static_cast<clap_host_proxy*>(host->host_data);
auto self = static_cast<const clap_host_proxy*>(host->host_data);
self->bridge_.send_main_thread_message(clap::ext::params::host::Clear{
.owner_instance_id = self->owner_instance_id(),
@@ -195,9 +201,17 @@ void CLAP_ABI clap_host_proxy::ext_params_clear(const clap_host_t* host,
void CLAP_ABI
clap_host_proxy::ext_params_request_flush(const clap_host_t* host) {
assert(host && host->host_data);
auto self = static_cast<clap_host_proxy*>(host->host_data);
auto self = static_cast<const clap_host_proxy*>(host->host_data);
self->bridge_.send_audio_thread_message(
clap::ext::params::host::RequestFlush{.owner_instance_id =
self->owner_instance_id()});
}
void CLAP_ABI clap_host_proxy::ext_tail_changed(const clap_host_t* host) {
assert(host && host->host_data);
auto self = static_cast<const clap_host_proxy*>(host->host_data);
self->bridge_.send_audio_thread_message(clap::ext::tail::host::Changed{
.owner_instance_id = self->owner_instance_id()});
}
@@ -21,6 +21,7 @@
#include <clap/ext/audio-ports.h>
#include <clap/ext/note-ports.h>
#include <clap/ext/params.h>
#include <clap/ext/tail.h>
#include <clap/host.h>
#include "../../common/serialization/clap/plugin-factory.h"
@@ -83,6 +84,8 @@ class clap_host_proxy {
clap_param_clear_flags flags);
static void CLAP_ABI ext_params_request_flush(const clap_host_t* host);
static void CLAP_ABI ext_tail_changed(const clap_host_t* host);
/**
* The extensions supported by the host, set just before calling
* `clap_plugin::init()` on the bridged plugin. We'll allow the plugin to
@@ -105,9 +108,10 @@ class clap_host_proxy {
// Extensions also have vtables. Whether or not we expose these to the host
// depends on whether the plugin supported this extension when the host
// called `clap_plugin::init()`.
const clap_host_audio_ports ext_audio_ports_vtable;
const clap_host_note_ports ext_note_ports_vtable;
const clap_host_params ext_params_vtable;
const clap_host_audio_ports_t ext_audio_ports_vtable;
const clap_host_note_ports_t ext_note_ports_vtable;
const clap_host_params_t ext_params_vtable;
const clap_host_tail_t ext_tail_vtable;
/**
* Keeps track of whether there are pending host callbacks. Used to prevent
+13 -2
View File
@@ -32,7 +32,9 @@ ClapPluginExtensions::ClapPluginExtensions(const clap_plugin& plugin) noexcept
note_ports(static_cast<const clap_plugin_note_ports_t*>(
plugin.get_extension(&plugin, CLAP_EXT_NOTE_PORTS))),
params(static_cast<const clap_plugin_params_t*>(
plugin.get_extension(&plugin, CLAP_EXT_PARAMS))) {}
plugin.get_extension(&plugin, CLAP_EXT_PARAMS))),
tail(static_cast<const clap_plugin_tail_t*>(
plugin.get_extension(&plugin, CLAP_EXT_TAIL))) {}
ClapPluginExtensions::ClapPluginExtensions() noexcept {}
@@ -41,7 +43,8 @@ clap::plugin::SupportedPluginExtensions ClapPluginExtensions::supported()
return clap::plugin::SupportedPluginExtensions{
.supports_audio_ports = audio_ports != nullptr,
.supports_note_ports = note_ports != nullptr,
.supports_params = params != nullptr};
.supports_params = params != nullptr,
.supports_tail = tail != nullptr};
}
ClapPluginInstance::ClapPluginInstance(
@@ -660,6 +663,14 @@ void ClapBridge::register_plugin_instance(
return clap::ext::params::plugin::FlushResponse{};
},
[&](const clap::ext::tail::plugin::Get& request)
-> clap::ext::tail::plugin::Get::Response {
const auto& [instance, _] =
get_instance(request.instance_id);
return instance.extensions.tail->get(
instance.plugin.get());
},
});
});
+1
View File
@@ -69,6 +69,7 @@ struct ClapPluginExtensions {
const clap_plugin_audio_ports_t* audio_ports = nullptr;
const clap_plugin_note_ports_t* note_ports = nullptr;
const clap_plugin_params_t* params = nullptr;
const clap_plugin_tail_t* tail = nullptr;
};
/**