mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Implement host side of the note-name extension
This commit is contained in:
@@ -183,6 +183,7 @@ using ClapMainThreadCallbackRequest =
|
||||
clap::ext::gui::host::RequestShow,
|
||||
clap::ext::gui::host::RequestHide,
|
||||
clap::ext::gui::host::Closed,
|
||||
clap::ext::note_name::host::Changed,
|
||||
clap::ext::note_ports::host::SupportedDialects,
|
||||
clap::ext::note_ports::host::Rescan,
|
||||
clap::ext::params::host::Rescan,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <clap/ext/gui.h>
|
||||
#include <clap/ext/latency.h>
|
||||
#include <clap/ext/log.h>
|
||||
#include <clap/ext/note-name.h>
|
||||
#include <clap/ext/note-ports.h>
|
||||
#include <clap/ext/params.h>
|
||||
#include <clap/ext/state.h>
|
||||
@@ -37,13 +38,14 @@ Host::Host(const clap_host_t& original)
|
||||
url(original.url ? std::optional(original.url) : std::nullopt),
|
||||
version((assert(original.version), original.version)) {}
|
||||
|
||||
std::array<std::pair<bool, const char*>, 10> SupportedHostExtensions::list()
|
||||
std::array<std::pair<bool, const char*>, 11> SupportedHostExtensions::list()
|
||||
const noexcept {
|
||||
return {std::pair(supports_audio_ports, CLAP_EXT_AUDIO_PORTS),
|
||||
std::pair(supports_audio_ports_config, CLAP_EXT_AUDIO_PORTS_CONFIG),
|
||||
std::pair(supports_gui, CLAP_EXT_GUI),
|
||||
std::pair(supports_latency, CLAP_EXT_LATENCY),
|
||||
std::pair(supports_log, CLAP_EXT_LOG),
|
||||
std::pair(supports_note_name, CLAP_EXT_NOTE_NAME),
|
||||
std::pair(supports_note_ports, CLAP_EXT_NOTE_PORTS),
|
||||
std::pair(supports_params, CLAP_EXT_PARAMS),
|
||||
std::pair(supports_state, CLAP_EXT_STATE),
|
||||
|
||||
@@ -86,6 +86,7 @@ struct SupportedHostExtensions {
|
||||
bool supports_gui = false;
|
||||
bool supports_latency = false;
|
||||
bool supports_log = false;
|
||||
bool supports_note_name = false;
|
||||
bool supports_note_ports = false;
|
||||
bool supports_params = false;
|
||||
bool supports_state = false;
|
||||
@@ -96,7 +97,7 @@ struct SupportedHostExtensions {
|
||||
* Get a list of `<bool, extension_name>` tuples for the supported
|
||||
* extensions. Used during logging.
|
||||
*/
|
||||
std::array<std::pair<bool, const char*>, 10> list() const noexcept;
|
||||
std::array<std::pair<bool, const char*>, 11> list() const noexcept;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
@@ -105,6 +106,7 @@ struct SupportedHostExtensions {
|
||||
s.value1b(supports_gui);
|
||||
s.value1b(supports_latency);
|
||||
s.value1b(supports_log);
|
||||
s.value1b(supports_note_name);
|
||||
s.value1b(supports_note_ports);
|
||||
s.value1b(supports_params);
|
||||
s.value1b(supports_state);
|
||||
|
||||
@@ -29,6 +29,8 @@ ClapHostExtensions::ClapHostExtensions(const clap_host& host) noexcept
|
||||
host.get_extension(&host, CLAP_EXT_LATENCY))),
|
||||
log(static_cast<const clap_host_log_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_LOG))),
|
||||
note_name(static_cast<const clap_host_note_name_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_NOTE_NAME))),
|
||||
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*>(
|
||||
@@ -50,6 +52,7 @@ clap::host::SupportedHostExtensions ClapHostExtensions::supported()
|
||||
.supports_gui = gui != nullptr,
|
||||
.supports_latency = latency != nullptr,
|
||||
.supports_log = log != nullptr,
|
||||
.supports_note_name = note_name != nullptr,
|
||||
.supports_note_ports = note_ports != nullptr,
|
||||
.supports_params = params != nullptr,
|
||||
.supports_state = state != nullptr,
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <clap/ext/gui.h>
|
||||
#include <clap/ext/latency.h>
|
||||
#include <clap/ext/log.h>
|
||||
#include <clap/ext/note-name.h>
|
||||
#include <clap/ext/note-ports.h>
|
||||
#include <clap/ext/params.h>
|
||||
#include <clap/ext/render.h>
|
||||
@@ -71,6 +72,7 @@ struct ClapHostExtensions {
|
||||
const clap_host_gui_t* gui = nullptr;
|
||||
const clap_host_latency_t* latency = nullptr;
|
||||
const clap_host_log_t* log = nullptr;
|
||||
const clap_host_note_name_t* note_name = nullptr;
|
||||
const clap_host_note_ports_t* note_ports = nullptr;
|
||||
const clap_host_params_t* params = nullptr;
|
||||
const clap_host_state_t* state = nullptr;
|
||||
|
||||
@@ -196,6 +196,22 @@ ClapPluginBridge::ClapPluginBridge(const ghc::filesystem::path& plugin_path)
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
[&](const clap::ext::note_name::host::Changed& request)
|
||||
-> clap::ext::note_name::host::Changed::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
plugin_proxy
|
||||
.run_on_main_thread(
|
||||
[&, host = plugin_proxy.host_,
|
||||
note_name =
|
||||
plugin_proxy.host_extensions_.note_name]() {
|
||||
note_name->changed(host);
|
||||
})
|
||||
.wait();
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
[&](const clap::ext::note_ports::host::SupportedDialects&
|
||||
request)
|
||||
-> clap::ext::note_ports::host::SupportedDialects::
|
||||
|
||||
@@ -69,6 +69,9 @@ clap_host_proxy::clap_host_proxy(ClapBridge& bridge,
|
||||
ext_log_vtable(clap_host_log_t{
|
||||
.log = ext_log_log,
|
||||
}),
|
||||
ext_note_name_vtable(clap_host_note_name_t{
|
||||
.changed = ext_note_name_changed,
|
||||
}),
|
||||
ext_note_ports_vtable(clap_host_note_ports_t{
|
||||
.supported_dialects = ext_note_ports_supported_dialects,
|
||||
.rescan = ext_note_ports_rescan,
|
||||
@@ -116,6 +119,9 @@ clap_host_proxy::host_get_extension(const struct clap_host* host,
|
||||
// supports it, or we'll print the message if it doesn't. That allows us
|
||||
// to filter misbehavior messages.
|
||||
extension_ptr = &self->ext_log_vtable;
|
||||
} else if (self->supported_extensions_.supports_note_name &&
|
||||
strcmp(extension_id, CLAP_EXT_NOTE_NAME) == 0) {
|
||||
extension_ptr = &self->ext_note_name_vtable;
|
||||
} else if (self->supported_extensions_.supports_note_ports &&
|
||||
strcmp(extension_id, CLAP_EXT_NOTE_PORTS) == 0) {
|
||||
extension_ptr = &self->ext_note_ports_vtable;
|
||||
@@ -363,6 +369,15 @@ void CLAP_ABI clap_host_proxy::ext_log_log(const clap_host_t* host,
|
||||
}
|
||||
}
|
||||
|
||||
void CLAP_ABI clap_host_proxy::ext_note_name_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_mutually_recursive_main_thread_message(
|
||||
clap::ext::note_name::host::Changed{.owner_instance_id =
|
||||
self->owner_instance_id()});
|
||||
}
|
||||
|
||||
uint32_t CLAP_ABI
|
||||
clap_host_proxy::ext_note_ports_supported_dialects(const clap_host_t* host) {
|
||||
assert(host && host->host_data);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <clap/ext/gui.h>
|
||||
#include <clap/ext/latency.h>
|
||||
#include <clap/ext/log.h>
|
||||
#include <clap/ext/note-name.h>
|
||||
#include <clap/ext/note-ports.h>
|
||||
#include <clap/ext/params.h>
|
||||
#include <clap/ext/state.h>
|
||||
@@ -104,6 +105,8 @@ class clap_host_proxy {
|
||||
clap_log_severity severity,
|
||||
const char* msg);
|
||||
|
||||
static void CLAP_ABI ext_note_name_changed(const clap_host_t* host);
|
||||
|
||||
static uint32_t CLAP_ABI
|
||||
ext_note_ports_supported_dialects(const clap_host_t* host);
|
||||
static void CLAP_ABI ext_note_ports_rescan(const clap_host_t* host,
|
||||
@@ -150,6 +153,7 @@ class clap_host_proxy {
|
||||
// can filter out plugin/host misbehavior messages on lower yabridge
|
||||
// verbosity levels.
|
||||
const clap_host_log_t ext_log_vtable;
|
||||
const clap_host_note_name_t ext_note_name_vtable;
|
||||
const clap_host_note_ports_t ext_note_ports_vtable;
|
||||
const clap_host_params_t ext_params_vtable;
|
||||
const clap_host_state_t ext_state_vtable;
|
||||
|
||||
Reference in New Issue
Block a user