mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Implement the thread check extension
This commit is contained in:
@@ -30,7 +30,7 @@ Yabridge currently tracks CLAP 1.1.1. The implementation status for CLAP's core
|
||||
| `clap.render` | :x: Not supported yet |
|
||||
| `clap.state` | :heavy_check_mark: |
|
||||
| `clap.tail` | :heavy_check_mark: |
|
||||
| `clap.thread-check` | :x: Not supported yet |
|
||||
| `clap.thread-check` | :heavy_check_mark: |
|
||||
| `clap.thread-pool` | :x: Not supported yet |
|
||||
| `clap.timer-support` | :x: Not supported yet |
|
||||
| `clap.voice-info` | :x: Not supported yet |
|
||||
|
||||
@@ -72,6 +72,10 @@ clap_host_proxy::clap_host_proxy(ClapBridge& bridge,
|
||||
}),
|
||||
ext_tail_vtable(clap_host_tail_t{
|
||||
.changed = ext_tail_changed,
|
||||
}),
|
||||
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,
|
||||
}) {}
|
||||
|
||||
const void* CLAP_ABI
|
||||
@@ -102,6 +106,9 @@ clap_host_proxy::host_get_extension(const struct clap_host* host,
|
||||
} else if (self->supported_extensions_.supports_tail &&
|
||||
strcmp(extension_id, CLAP_EXT_TAIL) == 0) {
|
||||
extension_ptr = &self->ext_tail_vtable;
|
||||
} else if (strcmp(extension_id, CLAP_EXT_THREAD_CHECK) == 0) {
|
||||
// This extension doesn't require any bridging
|
||||
extension_ptr = &self->ext_thread_check_vtable;
|
||||
}
|
||||
|
||||
self->bridge_.logger_.log_extension_query("clap_host::get_extension",
|
||||
@@ -314,3 +321,21 @@ void CLAP_ABI clap_host_proxy::ext_tail_changed(const clap_host_t* host) {
|
||||
self->bridge_.send_audio_thread_message(clap::ext::tail::host::Changed{
|
||||
.owner_instance_id = self->owner_instance_id()});
|
||||
}
|
||||
|
||||
bool CLAP_ABI
|
||||
clap_host_proxy::ext_thread_check_is_main_thread(const clap_host_t* host) {
|
||||
assert(host && host->host_data);
|
||||
auto self = static_cast<const clap_host_proxy*>(host->host_data);
|
||||
|
||||
return self->bridge_.main_context_.is_gui_thread();
|
||||
}
|
||||
|
||||
bool CLAP_ABI
|
||||
clap_host_proxy::ext_thread_check_is_audio_thread(const clap_host_t* host) {
|
||||
assert(host && host->host_data);
|
||||
auto self = static_cast<const clap_host_proxy*>(host->host_data);
|
||||
|
||||
// We don't keep track of audio threads, but as long as the plugin doesn't
|
||||
// do audio thread stuff on the GUI thread everything's fine
|
||||
return !self->bridge_.main_context_.is_gui_thread();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <clap/ext/params.h>
|
||||
#include <clap/ext/state.h>
|
||||
#include <clap/ext/tail.h>
|
||||
#include <clap/ext/thread-check.h>
|
||||
#include <clap/host.h>
|
||||
|
||||
#include "../../common/serialization/clap/plugin-factory.h"
|
||||
@@ -110,6 +111,11 @@ class clap_host_proxy {
|
||||
|
||||
static void CLAP_ABI ext_tail_changed(const clap_host_t* host);
|
||||
|
||||
static bool CLAP_ABI
|
||||
ext_thread_check_is_main_thread(const clap_host_t* host);
|
||||
static bool CLAP_ABI
|
||||
ext_thread_check_is_audio_thread(const clap_host_t* host);
|
||||
|
||||
private:
|
||||
ClapBridge& bridge_;
|
||||
size_t owner_instance_id_;
|
||||
@@ -132,6 +138,7 @@ class clap_host_proxy {
|
||||
const clap_host_params_t ext_params_vtable;
|
||||
const clap_host_state_t ext_state_vtable;
|
||||
const clap_host_tail_t ext_tail_vtable;
|
||||
const clap_host_thread_check_t ext_thread_check_vtable;
|
||||
|
||||
/**
|
||||
* Keeps track of whether there are pending host callbacks. Used to prevent
|
||||
|
||||
Reference in New Issue
Block a user