mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 20:40:11 +02:00
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:
@@ -24,7 +24,9 @@ ClapHostExtensions::ClapHostExtensions(const clap_host& host) noexcept
|
||||
note_ports(static_cast<const clap_host_note_ports_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_NOTE_PORTS))),
|
||||
params(static_cast<const clap_host_params_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_PARAMS))) {}
|
||||
host.get_extension(&host, CLAP_EXT_PARAMS))),
|
||||
tail(static_cast<const clap_host_tail_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_TAIL))) {}
|
||||
|
||||
ClapHostExtensions::ClapHostExtensions() noexcept {}
|
||||
|
||||
@@ -33,7 +35,8 @@ clap::host::SupportedHostExtensions ClapHostExtensions::supported()
|
||||
return clap::host::SupportedHostExtensions{
|
||||
.supports_audio_ports = audio_ports != nullptr,
|
||||
.supports_note_ports = note_ports != nullptr,
|
||||
.supports_params = params != nullptr};
|
||||
.supports_params = params != nullptr,
|
||||
.supports_tail = tail != nullptr};
|
||||
}
|
||||
|
||||
clap_plugin_proxy::clap_plugin_proxy(ClapPluginBridge& bridge,
|
||||
@@ -74,6 +77,9 @@ clap_plugin_proxy::clap_plugin_proxy(ClapPluginBridge& bridge,
|
||||
.text_to_value = ext_params_text_to_value,
|
||||
.flush = ext_params_flush,
|
||||
}),
|
||||
ext_tail_vtable(clap_plugin_tail_t{
|
||||
.get = ext_tail_get,
|
||||
}),
|
||||
// These function objects are relatively large, and we probably won't be
|
||||
// getting that many of them
|
||||
pending_callbacks_(128) {}
|
||||
@@ -210,6 +216,9 @@ clap_plugin_proxy::plugin_get_extension(const struct clap_plugin* plugin,
|
||||
} else if (self->supported_extensions_.supports_params &&
|
||||
strcmp(id, CLAP_EXT_PARAMS) == 0) {
|
||||
extension_ptr = &self->ext_params_vtable;
|
||||
} else if (self->supported_extensions_.supports_tail &&
|
||||
strcmp(id, CLAP_EXT_TAIL) == 0) {
|
||||
extension_ptr = &self->ext_tail_vtable;
|
||||
}
|
||||
|
||||
self->bridge_.logger_.log_extension_query("clap_plugin::get_extension",
|
||||
@@ -408,3 +417,11 @@ clap_plugin_proxy::ext_params_flush(const clap_plugin_t* plugin,
|
||||
self->bridge_.send_audio_thread_message(
|
||||
clap::ext::params::plugin::Flush{.instance_id = self->instance_id()});
|
||||
}
|
||||
|
||||
uint32_t CLAP_ABI clap_plugin_proxy::ext_tail_get(const clap_plugin_t* plugin) {
|
||||
assert(plugin && plugin->plugin_data);
|
||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||
|
||||
return self->bridge_.send_audio_thread_message(
|
||||
clap::ext::tail::plugin::Get{.instance_id = self->instance_id()});
|
||||
}
|
||||
|
||||
@@ -23,6 +23,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/plugin.h>
|
||||
#include <rigtorp/MPMCQueue.h>
|
||||
#include <function2/function2.hpp>
|
||||
@@ -61,6 +62,7 @@ struct ClapHostExtensions {
|
||||
const clap_host_audio_ports_t* audio_ports = nullptr;
|
||||
const clap_host_note_ports_t* note_ports = nullptr;
|
||||
const clap_host_params_t* params = nullptr;
|
||||
const clap_host_tail_t* tail = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -162,6 +164,8 @@ class clap_plugin_proxy {
|
||||
const clap_input_events_t* in,
|
||||
const clap_output_events_t* out);
|
||||
|
||||
static uint32_t CLAP_ABI ext_tail_get(const clap_plugin_t* plugin);
|
||||
|
||||
/**
|
||||
* Asynchronously run a function on the host's main thread, returning the
|
||||
* result as a future.
|
||||
@@ -235,9 +239,10 @@ class clap_plugin_proxy {
|
||||
// Extensions also have vtables. Whether or not we expose these to the host
|
||||
// depends on whether the plugin supported this extension when we called
|
||||
// `clap_plugin::init()`.
|
||||
const clap_plugin_audio_ports ext_audio_ports_vtable;
|
||||
const clap_plugin_note_ports ext_note_ports_vtable;
|
||||
const clap_plugin_params ext_params_vtable;
|
||||
const clap_plugin_audio_ports_t ext_audio_ports_vtable;
|
||||
const clap_plugin_note_ports_t ext_note_ports_vtable;
|
||||
const clap_plugin_params_t ext_params_vtable;
|
||||
const clap_plugin_tail_t ext_tail_vtable;
|
||||
|
||||
/**
|
||||
* The extensions supported by the bridged plugin. Set after a successful
|
||||
|
||||
@@ -278,12 +278,13 @@ void ClapPluginBridge::register_plugin_proxy(
|
||||
},
|
||||
[&](const clap::ext::tail::host::Changed& request)
|
||||
-> clap::ext::tail::host::Changed::Response {
|
||||
// FIXME:
|
||||
// const auto& [instance, _] =
|
||||
// get_instance(request.instance_id);
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
// return instance.plugin->start_processing(
|
||||
// instance.plugin.get());
|
||||
plugin_proxy.host_extensions_.tail->changed(
|
||||
plugin_proxy.host_);
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user