mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Implement the voice-info CLAP extension
This commit is contained in:
@@ -34,7 +34,9 @@ ClapHostExtensions::ClapHostExtensions(const clap_host& host) noexcept
|
||||
state(static_cast<const clap_host_state_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_STATE))),
|
||||
tail(static_cast<const clap_host_tail_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_TAIL))) {}
|
||||
host.get_extension(&host, CLAP_EXT_TAIL))),
|
||||
voice_info(static_cast<const clap_host_voice_info_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_VOICE_INFO))) {}
|
||||
|
||||
ClapHostExtensions::ClapHostExtensions() noexcept {}
|
||||
|
||||
@@ -48,7 +50,8 @@ clap::host::SupportedHostExtensions ClapHostExtensions::supported()
|
||||
.supports_note_ports = note_ports != nullptr,
|
||||
.supports_params = params != nullptr,
|
||||
.supports_state = state != nullptr,
|
||||
.supports_tail = tail != nullptr};
|
||||
.supports_tail = tail != nullptr,
|
||||
.supports_voice_info = voice_info != nullptr};
|
||||
}
|
||||
|
||||
clap_plugin_proxy::clap_plugin_proxy(ClapPluginBridge& bridge,
|
||||
@@ -116,6 +119,9 @@ clap_plugin_proxy::clap_plugin_proxy(ClapPluginBridge& bridge,
|
||||
ext_tail_vtable(clap_plugin_tail_t{
|
||||
.get = ext_tail_get,
|
||||
}),
|
||||
ext_voice_info_vtable(clap_plugin_voice_info_t{
|
||||
.get = ext_voice_info_get,
|
||||
}),
|
||||
// These function objects are relatively large, and we probably won't be
|
||||
// getting that many of them
|
||||
pending_callbacks_(128) {}
|
||||
@@ -309,6 +315,9 @@ clap_plugin_proxy::plugin_get_extension(const struct clap_plugin* plugin,
|
||||
} else if (self->supported_extensions_.supports_tail &&
|
||||
strcmp(id, CLAP_EXT_TAIL) == 0) {
|
||||
extension_ptr = &self->ext_tail_vtable;
|
||||
} else if (self->supported_extensions_.supports_voice_info &&
|
||||
strcmp(id, CLAP_EXT_VOICE_INFO) == 0) {
|
||||
extension_ptr = &self->ext_voice_info_vtable;
|
||||
}
|
||||
|
||||
self->bridge_.logger_.log_extension_query("clap_plugin::get_extension",
|
||||
@@ -757,3 +766,21 @@ uint32_t CLAP_ABI clap_plugin_proxy::ext_tail_get(const clap_plugin_t* plugin) {
|
||||
return self->bridge_.send_audio_thread_message(
|
||||
clap::ext::tail::plugin::Get{.instance_id = self->instance_id()});
|
||||
}
|
||||
|
||||
bool CLAP_ABI clap_plugin_proxy::ext_voice_info_get(const clap_plugin_t* plugin,
|
||||
clap_voice_info_t* info) {
|
||||
assert(plugin && plugin->plugin_data && info);
|
||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||
|
||||
const clap::ext::voice_info::plugin::GetResponse response =
|
||||
self->bridge_.send_main_thread_message(
|
||||
clap::ext::voice_info::plugin::Get{.instance_id =
|
||||
self->instance_id()});
|
||||
if (response.result) {
|
||||
*info = *response.result;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <clap/ext/params.h>
|
||||
#include <clap/ext/state.h>
|
||||
#include <clap/ext/tail.h>
|
||||
#include <clap/ext/voice-info.h>
|
||||
#include <clap/plugin.h>
|
||||
#include <rigtorp/MPMCQueue.h>
|
||||
#include <function2/function2.hpp>
|
||||
@@ -71,6 +72,7 @@ struct ClapHostExtensions {
|
||||
const clap_host_params_t* params = nullptr;
|
||||
const clap_host_state_t* state = nullptr;
|
||||
const clap_host_tail_t* tail = nullptr;
|
||||
const clap_host_voice_info_t* voice_info = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -263,6 +265,9 @@ class clap_plugin_proxy {
|
||||
|
||||
static uint32_t CLAP_ABI ext_tail_get(const clap_plugin_t* plugin);
|
||||
|
||||
static bool CLAP_ABI ext_voice_info_get(const clap_plugin_t* plugin,
|
||||
clap_voice_info_t* info);
|
||||
|
||||
private:
|
||||
ClapPluginBridge& bridge_;
|
||||
size_t instance_id_;
|
||||
@@ -326,6 +331,7 @@ class clap_plugin_proxy {
|
||||
const clap_plugin_params_t ext_params_vtable;
|
||||
const clap_plugin_state_t ext_state_vtable;
|
||||
const clap_plugin_tail_t ext_tail_vtable;
|
||||
const clap_plugin_voice_info_t ext_voice_info_vtable;
|
||||
|
||||
/**
|
||||
* The extensions supported by the bridged plugin. Set after a successful
|
||||
|
||||
@@ -259,6 +259,22 @@ ClapPluginBridge::ClapPluginBridge(const ghc::filesystem::path& plugin_path)
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
[&](const clap::ext::voice_info::host::Changed& request)
|
||||
-> clap::ext::voice_info::host::Changed::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
plugin_proxy
|
||||
.run_on_main_thread(
|
||||
[&, host = plugin_proxy.host_,
|
||||
voice_info =
|
||||
plugin_proxy.host_extensions_.voice_info]() {
|
||||
voice_info->changed(host);
|
||||
})
|
||||
.wait();
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user