mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Implement the voice-info CLAP extension
This commit is contained in:
@@ -84,6 +84,9 @@ clap_host_proxy::clap_host_proxy(ClapBridge& bridge,
|
||||
ext_thread_check_vtable(clap_host_thread_check_t{
|
||||
.is_main_thread = ext_thread_check_is_main_thread,
|
||||
.is_audio_thread = ext_thread_check_is_audio_thread,
|
||||
}),
|
||||
ext_voice_info_vtable(clap_host_voice_info_t{
|
||||
.changed = ext_voice_info_changed,
|
||||
}) {}
|
||||
|
||||
const void* CLAP_ABI
|
||||
@@ -122,6 +125,9 @@ clap_host_proxy::host_get_extension(const struct clap_host* host,
|
||||
} else if (strcmp(extension_id, CLAP_EXT_THREAD_CHECK) == 0) {
|
||||
// This extension doesn't require any bridging
|
||||
extension_ptr = &self->ext_thread_check_vtable;
|
||||
} else if (self->supported_extensions_.supports_voice_info &&
|
||||
strcmp(extension_id, CLAP_EXT_VOICE_INFO) == 0) {
|
||||
extension_ptr = &self->ext_voice_info_vtable;
|
||||
}
|
||||
|
||||
self->bridge_.logger_.log_extension_query("clap_host::get_extension",
|
||||
@@ -432,3 +438,11 @@ clap_host_proxy::ext_thread_check_is_audio_thread(const clap_host_t* host) {
|
||||
// do audio thread stuff on the GUI thread everything's fine
|
||||
return !self->bridge_.main_context_.is_gui_thread();
|
||||
}
|
||||
|
||||
void CLAP_ABI clap_host_proxy::ext_voice_info_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_main_thread_message(clap::ext::voice_info::host::Changed{
|
||||
.owner_instance_id = self->owner_instance_id()});
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <clap/ext/state.h>
|
||||
#include <clap/ext/tail.h>
|
||||
#include <clap/ext/thread-check.h>
|
||||
#include <clap/ext/voice-info.h>
|
||||
#include <clap/host.h>
|
||||
|
||||
#include "../../common/serialization/clap/plugin-factory.h"
|
||||
@@ -121,6 +122,8 @@ class clap_host_proxy {
|
||||
static bool CLAP_ABI
|
||||
ext_thread_check_is_audio_thread(const clap_host_t* host);
|
||||
|
||||
static void CLAP_ABI ext_voice_info_changed(const clap_host_t* host);
|
||||
|
||||
private:
|
||||
ClapBridge& bridge_;
|
||||
size_t owner_instance_id_;
|
||||
@@ -149,6 +152,7 @@ class clap_host_proxy {
|
||||
const clap_host_tail_t ext_tail_vtable;
|
||||
// This is always available regardless of the proxied host
|
||||
const clap_host_thread_check_t ext_thread_check_vtable;
|
||||
const clap_host_voice_info_t ext_voice_info_vtable;
|
||||
|
||||
/**
|
||||
* Keeps track of whether there are pending host callbacks. Used to prevent
|
||||
|
||||
@@ -40,7 +40,9 @@ ClapPluginExtensions::ClapPluginExtensions(const clap_plugin& plugin) noexcept
|
||||
state(static_cast<const clap_plugin_state_t*>(
|
||||
plugin.get_extension(&plugin, CLAP_EXT_STATE))),
|
||||
tail(static_cast<const clap_plugin_tail_t*>(
|
||||
plugin.get_extension(&plugin, CLAP_EXT_TAIL))) {}
|
||||
plugin.get_extension(&plugin, CLAP_EXT_TAIL))),
|
||||
voice_info(static_cast<const clap_plugin_voice_info_t*>(
|
||||
plugin.get_extension(&plugin, CLAP_EXT_VOICE_INFO))) {}
|
||||
|
||||
ClapPluginExtensions::ClapPluginExtensions() noexcept {}
|
||||
|
||||
@@ -53,7 +55,8 @@ clap::plugin::SupportedPluginExtensions ClapPluginExtensions::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};
|
||||
}
|
||||
|
||||
ClapPluginInstance::ClapPluginInstance(
|
||||
@@ -736,6 +739,25 @@ void ClapBridge::run() {
|
||||
})
|
||||
.get();
|
||||
},
|
||||
[&](clap::ext::voice_info::plugin::Get& request)
|
||||
-> clap::ext::voice_info::plugin::Get::Response {
|
||||
const auto& [instance, _] = get_instance(request.instance_id);
|
||||
|
||||
return main_context_
|
||||
.run_in_context([&, plugin = instance.plugin.get(),
|
||||
voice_info =
|
||||
instance.extensions.voice_info]() {
|
||||
clap_voice_info_t info{};
|
||||
if (voice_info->get(plugin, &info)) {
|
||||
return clap::ext::voice_info::plugin::GetResponse{
|
||||
.result = std::move(info)};
|
||||
} else {
|
||||
return clap::ext::voice_info::plugin::GetResponse{
|
||||
.result = std::nullopt};
|
||||
}
|
||||
})
|
||||
.get();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ struct ClapPluginExtensions {
|
||||
const clap_plugin_params_t* params = nullptr;
|
||||
const clap_plugin_state_t* state = nullptr;
|
||||
const clap_plugin_tail_t* tail = nullptr;
|
||||
const clap_plugin_voice_info_t* voice_info = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user