Implement the CLAP latency extension

This commit is contained in:
Robbert van der Helm
2022-09-26 18:26:42 +02:00
parent 3e0cd725a3
commit c7ea37309d
16 changed files with 171 additions and 5 deletions
+15
View File
@@ -217,6 +217,13 @@ bool ClapLogger::log_request(
}); });
} }
bool ClapLogger::log_request(bool is_host_plugin,
const clap::ext::latency::plugin::Get& request) {
return log_request_base(is_host_plugin, [&](auto& message) {
message << request.instance_id << ": clap_plugin_latency::get()";
});
}
bool ClapLogger::log_request(bool is_host_plugin, bool ClapLogger::log_request(bool is_host_plugin,
const clap::plugin::StartProcessing& request) { const clap::plugin::StartProcessing& request) {
return log_request_base(is_host_plugin, [&](auto& message) { return log_request_base(is_host_plugin, [&](auto& message) {
@@ -343,6 +350,14 @@ bool ClapLogger::log_request(
}); });
} }
bool ClapLogger::log_request(bool is_host_plugin,
const clap::ext::latency::host::Changed& request) {
return log_request_base(is_host_plugin, [&](auto& message) {
message << request.owner_instance_id
<< ": clap_host_latency::changed()";
});
}
bool ClapLogger::log_request(bool is_host_plugin, bool ClapLogger::log_request(bool is_host_plugin,
const clap::ext::tail::host::Changed& request) { const clap::ext::tail::host::Changed& request) {
return log_request_base(is_host_plugin, [&](auto& message) { return log_request_base(is_host_plugin, [&](auto& message) {
+4
View File
@@ -96,6 +96,8 @@ class ClapLogger {
const clap::ext::params::plugin::ValueToText&); const clap::ext::params::plugin::ValueToText&);
bool log_request(bool is_host_plugin, bool log_request(bool is_host_plugin,
const clap::ext::params::plugin::TextToValue&); const clap::ext::params::plugin::TextToValue&);
bool log_request(bool is_host_plugin,
const clap::ext::latency::plugin::Get&);
// Audio thread control messages // Audio thread control messages
bool log_request(bool is_host_plugin, const clap::plugin::StartProcessing&); bool log_request(bool is_host_plugin, const clap::plugin::StartProcessing&);
@@ -124,6 +126,8 @@ class ClapLogger {
const clap::ext::params::host::Clear&); const clap::ext::params::host::Clear&);
bool log_request(bool is_host_plugin, bool log_request(bool is_host_plugin,
const clap::ext::params::host::RequestFlush&); const clap::ext::params::host::RequestFlush&);
bool log_request(bool is_host_plugin,
const clap::ext::latency::host::Changed&);
// Audio thread callbacks // Audio thread callbacks
bool log_request(bool is_host_plugin, bool log_request(bool is_host_plugin,
+3
View File
@@ -23,6 +23,7 @@
#include "../bitsery/ext/message-reference.h" #include "../bitsery/ext/message-reference.h"
#include "../utils.h" #include "../utils.h"
#include "clap/ext/audio-ports.h" #include "clap/ext/audio-ports.h"
#include "clap/ext/latency.h"
#include "clap/ext/note-ports.h" #include "clap/ext/note-ports.h"
#include "clap/ext/params.h" #include "clap/ext/params.h"
#include "clap/ext/tail.h" #include "clap/ext/tail.h"
@@ -53,6 +54,7 @@ using ClapMainThreadControlRequest =
clap::plugin::Deactivate, clap::plugin::Deactivate,
clap::ext::audio_ports::plugin::Count, clap::ext::audio_ports::plugin::Count,
clap::ext::audio_ports::plugin::Get, clap::ext::audio_ports::plugin::Get,
clap::ext::latency::plugin::Get,
clap::ext::note_ports::plugin::Count, clap::ext::note_ports::plugin::Count,
clap::ext::note_ports::plugin::Get, clap::ext::note_ports::plugin::Get,
clap::ext::params::plugin::Count, clap::ext::params::plugin::Count,
@@ -147,6 +149,7 @@ using ClapMainThreadCallbackRequest =
std::variant<WantsConfiguration, std::variant<WantsConfiguration,
clap::host::RequestRestart, clap::host::RequestRestart,
clap::host::RequestProcess, clap::host::RequestProcess,
clap::ext::latency::host::Changed,
clap::ext::audio_ports::host::IsRescanFlagSupported, clap::ext::audio_ports::host::IsRescanFlagSupported,
clap::ext::audio_ports::host::Rescan, clap::ext::audio_ports::host::Rescan,
clap::ext::note_ports::host::SupportedDialects, clap::ext::note_ports::host::SupportedDialects,
+1 -1
View File
@@ -18,7 +18,7 @@ Yabridge currently tracks CLAP 1.1.1. The implementation status for CLAP's core
| `clap.audio-ports-config` | :x: Not supported yet | | `clap.audio-ports-config` | :x: Not supported yet |
| `clap.event-registry` | :x: Not supported yet | | `clap.event-registry` | :x: Not supported yet |
| `clap.gui` | :x: Not supported yet | | `clap.gui` | :x: Not supported yet |
| `clap.latency` | :x: Not supported yet | | `clap.latency` | :heavy_check_mark: |
| `clap.log` | :x: Not supported yet | | `clap.log` | :x: Not supported yet |
| `clap.note-name` | :x: Not supported yet | | `clap.note-name` | :x: Not supported yet |
| `clap.note-ports` | :heavy_check_mark: | | `clap.note-ports` | :heavy_check_mark: |
@@ -0,0 +1,67 @@
// yabridge: a Wine plugin bridge
// Copyright (C) 2020-2022 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more delatencys.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <clap/ext/latency.h>
#include "../../common.h"
// Serialization messages for `clap/ext/latency.h`
namespace clap {
namespace ext {
namespace latency {
namespace plugin {
/**
* Message struct for `clap_plugin_latency::get()`.
*/
struct Get {
using Response = PrimitiveResponse<uint32_t>;
native_size_t instance_id;
template <typename S>
void serialize(S& s) {
s.value8b(instance_id);
}
};
} // namespace plugin
namespace host {
/**
* Message struct for `clap_host_latency::changed()`.
*/
struct Changed {
using Response = Ack;
native_size_t owner_instance_id;
template <typename S>
void serialize(S& s) {
s.value8b(owner_instance_id);
}
};
} // namespace host
} // namespace latency
} // namespace ext
} // namespace clap
+3 -1
View File
@@ -17,6 +17,7 @@
#include "host.h" #include "host.h"
#include <clap/ext/audio-ports.h> #include <clap/ext/audio-ports.h>
#include <clap/ext/latency.h>
#include <clap/ext/note-ports.h> #include <clap/ext/note-ports.h>
#include <clap/ext/params.h> #include <clap/ext/params.h>
#include <clap/ext/tail.h> #include <clap/ext/tail.h>
@@ -31,9 +32,10 @@ Host::Host(const clap_host_t& original)
url(original.url ? std::optional(original.url) : std::nullopt), url(original.url ? std::optional(original.url) : std::nullopt),
version((assert(original.version), original.version)) {} version((assert(original.version), original.version)) {}
std::array<std::pair<bool, const char*>, 4> SupportedHostExtensions::list() std::array<std::pair<bool, const char*>, 5> SupportedHostExtensions::list()
const noexcept { const noexcept {
return {std::pair(supports_audio_ports, CLAP_EXT_AUDIO_PORTS), return {std::pair(supports_audio_ports, CLAP_EXT_AUDIO_PORTS),
std::pair(supports_latency, CLAP_EXT_LATENCY),
std::pair(supports_note_ports, CLAP_EXT_NOTE_PORTS), std::pair(supports_note_ports, CLAP_EXT_NOTE_PORTS),
std::pair(supports_params, CLAP_EXT_PARAMS), std::pair(supports_params, CLAP_EXT_PARAMS),
std::pair(supports_tail, CLAP_EXT_TAIL)}; std::pair(supports_tail, CLAP_EXT_TAIL)};
+3 -1
View File
@@ -82,6 +82,7 @@ struct Host {
struct SupportedHostExtensions { struct SupportedHostExtensions {
// Don't forget to add new extensions to below method // Don't forget to add new extensions to below method
bool supports_audio_ports = false; bool supports_audio_ports = false;
bool supports_latency = false;
bool supports_note_ports = false; bool supports_note_ports = false;
bool supports_params = false; bool supports_params = false;
bool supports_tail = false; bool supports_tail = false;
@@ -90,11 +91,12 @@ struct SupportedHostExtensions {
* Get a list of `<bool, extension_name>` tuples for the supported * Get a list of `<bool, extension_name>` tuples for the supported
* extensions. Used during logging. * extensions. Used during logging.
*/ */
std::array<std::pair<bool, const char*>, 4> list() const noexcept; std::array<std::pair<bool, const char*>, 5> list() const noexcept;
template <typename S> template <typename S>
void serialize(S& s) { void serialize(S& s) {
s.value1b(supports_audio_ports); s.value1b(supports_audio_ports);
s.value1b(supports_latency);
s.value1b(supports_note_ports); s.value1b(supports_note_ports);
s.value1b(supports_params); s.value1b(supports_params);
s.value1b(supports_tail); s.value1b(supports_tail);
+3 -1
View File
@@ -17,6 +17,7 @@
#include "plugin.h" #include "plugin.h"
#include <clap/ext/audio-ports.h> #include <clap/ext/audio-ports.h>
#include <clap/ext/latency.h>
#include <clap/ext/note-ports.h> #include <clap/ext/note-ports.h>
#include <clap/ext/params.h> #include <clap/ext/params.h>
#include <clap/ext/tail.h> #include <clap/ext/tail.h>
@@ -79,9 +80,10 @@ const clap_plugin_descriptor_t* Descriptor::get() const {
return &clap_descriptor; return &clap_descriptor;
} }
std::array<std::pair<bool, const char*>, 4> SupportedPluginExtensions::list() std::array<std::pair<bool, const char*>, 5> SupportedPluginExtensions::list()
const noexcept { const noexcept {
return {std::pair(supports_audio_ports, CLAP_EXT_AUDIO_PORTS), return {std::pair(supports_audio_ports, CLAP_EXT_AUDIO_PORTS),
std::pair(supports_latency, CLAP_EXT_LATENCY),
std::pair(supports_note_ports, CLAP_EXT_NOTE_PORTS), std::pair(supports_note_ports, CLAP_EXT_NOTE_PORTS),
std::pair(supports_params, CLAP_EXT_PARAMS), std::pair(supports_params, CLAP_EXT_PARAMS),
std::pair(supports_tail, CLAP_EXT_TAIL)}; std::pair(supports_tail, CLAP_EXT_TAIL)};
+3 -1
View File
@@ -115,6 +115,7 @@ struct Descriptor {
struct SupportedPluginExtensions { struct SupportedPluginExtensions {
// Don't forget to add new extensions to below method // Don't forget to add new extensions to below method
bool supports_audio_ports = false; bool supports_audio_ports = false;
bool supports_latency = false;
bool supports_note_ports = false; bool supports_note_ports = false;
bool supports_params = false; bool supports_params = false;
bool supports_tail = false; bool supports_tail = false;
@@ -123,11 +124,12 @@ struct SupportedPluginExtensions {
* Get a list of `<bool, extension_name>` tuples for the supported * Get a list of `<bool, extension_name>` tuples for the supported
* extensions. Used during logging. * extensions. Used during logging.
*/ */
std::array<std::pair<bool, const char*>, 3> list() const noexcept; std::array<std::pair<bool, const char*>, 5> list() const noexcept;
template <typename S> template <typename S>
void serialize(S& s) { void serialize(S& s) {
s.value1b(supports_audio_ports); s.value1b(supports_audio_ports);
s.value1b(supports_latency);
s.value1b(supports_note_ports); s.value1b(supports_note_ports);
s.value1b(supports_params); s.value1b(supports_params);
s.value1b(supports_tail); s.value1b(supports_tail);
@@ -21,6 +21,8 @@
ClapHostExtensions::ClapHostExtensions(const clap_host& host) noexcept ClapHostExtensions::ClapHostExtensions(const clap_host& host) noexcept
: audio_ports(static_cast<const clap_host_audio_ports_t*>( : audio_ports(static_cast<const clap_host_audio_ports_t*>(
host.get_extension(&host, CLAP_EXT_AUDIO_PORTS))), host.get_extension(&host, CLAP_EXT_AUDIO_PORTS))),
latency(static_cast<const clap_host_latency_t*>(
host.get_extension(&host, CLAP_EXT_LATENCY))),
note_ports(static_cast<const clap_host_note_ports_t*>( note_ports(static_cast<const clap_host_note_ports_t*>(
host.get_extension(&host, CLAP_EXT_NOTE_PORTS))), host.get_extension(&host, CLAP_EXT_NOTE_PORTS))),
params(static_cast<const clap_host_params_t*>( params(static_cast<const clap_host_params_t*>(
@@ -34,6 +36,7 @@ clap::host::SupportedHostExtensions ClapHostExtensions::supported()
const noexcept { const noexcept {
return clap::host::SupportedHostExtensions{ return clap::host::SupportedHostExtensions{
.supports_audio_ports = audio_ports != nullptr, .supports_audio_ports = audio_ports != nullptr,
.supports_latency = latency != nullptr,
.supports_note_ports = note_ports != nullptr, .supports_note_ports = note_ports != nullptr,
.supports_params = params != nullptr, .supports_params = params != nullptr,
.supports_tail = tail != nullptr}; .supports_tail = tail != nullptr};
@@ -65,6 +68,9 @@ clap_plugin_proxy::clap_plugin_proxy(ClapPluginBridge& bridge,
.count = ext_audio_ports_count, .count = ext_audio_ports_count,
.get = ext_audio_ports_get, .get = ext_audio_ports_get,
}), }),
ext_latency_vtable(clap_plugin_latency_t{
.get = ext_latency_get,
}),
ext_note_ports_vtable(clap_plugin_note_ports_t{ ext_note_ports_vtable(clap_plugin_note_ports_t{
.count = ext_note_ports_count, .count = ext_note_ports_count,
.get = ext_note_ports_get, .get = ext_note_ports_get,
@@ -210,6 +216,9 @@ clap_plugin_proxy::plugin_get_extension(const struct clap_plugin* plugin,
if (self->supported_extensions_.supports_audio_ports && if (self->supported_extensions_.supports_audio_ports &&
strcmp(id, CLAP_EXT_AUDIO_PORTS) == 0) { strcmp(id, CLAP_EXT_AUDIO_PORTS) == 0) {
extension_ptr = &self->ext_audio_ports_vtable; extension_ptr = &self->ext_audio_ports_vtable;
} else if (self->supported_extensions_.supports_latency &&
strcmp(id, CLAP_EXT_LATENCY) == 0) {
extension_ptr = &self->ext_latency_vtable;
} else if (self->supported_extensions_.supports_note_ports && } else if (self->supported_extensions_.supports_note_ports &&
strcmp(id, CLAP_EXT_NOTE_PORTS) == 0) { strcmp(id, CLAP_EXT_NOTE_PORTS) == 0) {
extension_ptr = &self->ext_note_ports_vtable; extension_ptr = &self->ext_note_ports_vtable;
@@ -274,6 +283,15 @@ clap_plugin_proxy::ext_audio_ports_get(const clap_plugin_t* plugin,
} }
} }
uint32_t CLAP_ABI
clap_plugin_proxy::ext_latency_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_main_thread_message(
clap::ext::latency::plugin::Get{.instance_id = self->instance_id()});
}
uint32_t CLAP_ABI uint32_t CLAP_ABI
clap_plugin_proxy::ext_note_ports_count(const clap_plugin_t* plugin, clap_plugin_proxy::ext_note_ports_count(const clap_plugin_t* plugin,
bool is_input) { bool is_input) {
@@ -21,6 +21,7 @@
#include <vector> #include <vector>
#include <clap/ext/audio-ports.h> #include <clap/ext/audio-ports.h>
#include <clap/ext/latency.h>
#include <clap/ext/note-ports.h> #include <clap/ext/note-ports.h>
#include <clap/ext/params.h> #include <clap/ext/params.h>
#include <clap/ext/tail.h> #include <clap/ext/tail.h>
@@ -60,6 +61,7 @@ struct ClapHostExtensions {
clap::host::SupportedHostExtensions supported() const noexcept; clap::host::SupportedHostExtensions supported() const noexcept;
const clap_host_audio_ports_t* audio_ports = nullptr; const clap_host_audio_ports_t* audio_ports = nullptr;
const clap_host_latency_t* latency = nullptr;
const clap_host_note_ports_t* note_ports = nullptr; const clap_host_note_ports_t* note_ports = nullptr;
const clap_host_params_t* params = nullptr; const clap_host_params_t* params = nullptr;
const clap_host_tail_t* tail = nullptr; const clap_host_tail_t* tail = nullptr;
@@ -137,6 +139,8 @@ class clap_plugin_proxy {
bool is_input, bool is_input,
clap_audio_port_info_t* info); clap_audio_port_info_t* info);
static uint32_t CLAP_ABI ext_latency_get(const clap_plugin_t* plugin);
static uint32_t CLAP_ABI ext_note_ports_count(const clap_plugin_t* plugin, static uint32_t CLAP_ABI ext_note_ports_count(const clap_plugin_t* plugin,
bool is_input); bool is_input);
static bool CLAP_ABI ext_note_ports_get(const clap_plugin_t* plugin, static bool CLAP_ABI ext_note_ports_get(const clap_plugin_t* plugin,
@@ -240,6 +244,7 @@ class clap_plugin_proxy {
// depends on whether the plugin supported this extension when we called // depends on whether the plugin supported this extension when we called
// `clap_plugin::init()`. // `clap_plugin::init()`.
const clap_plugin_audio_ports_t ext_audio_ports_vtable; const clap_plugin_audio_ports_t ext_audio_ports_vtable;
const clap_plugin_latency_t ext_latency_vtable;
const clap_plugin_note_ports_t ext_note_ports_vtable; const clap_plugin_note_ports_t ext_note_ports_vtable;
const clap_plugin_params_t ext_params_vtable; const clap_plugin_params_t ext_params_vtable;
const clap_plugin_tail_t ext_tail_vtable; const clap_plugin_tail_t ext_tail_vtable;
+16
View File
@@ -115,6 +115,22 @@ ClapPluginBridge::ClapPluginBridge(const ghc::filesystem::path& plugin_path)
return Ack{}; return Ack{};
}, },
[&](const clap::ext::latency::host::Changed& request)
-> clap::ext::latency::host::Changed::Response {
const auto& [plugin_proxy, _] =
get_proxy(request.owner_instance_id);
plugin_proxy
.run_on_main_thread(
[&, host = plugin_proxy.host_,
latency =
plugin_proxy.host_extensions_.latency]() {
latency->changed(host);
})
.wait();
return Ack{};
},
[&](const clap::ext::note_ports::host::SupportedDialects& [&](const clap::ext::note_ports::host::SupportedDialects&
request) request)
-> clap::ext::note_ports::host::SupportedDialects:: -> clap::ext::note_ports::host::SupportedDialects::
@@ -48,6 +48,9 @@ clap_host_proxy::clap_host_proxy(ClapBridge& bridge,
.is_rescan_flag_supported = ext_audio_ports_is_rescan_flag_supported, .is_rescan_flag_supported = ext_audio_ports_is_rescan_flag_supported,
.rescan = ext_audio_ports_rescan, .rescan = ext_audio_ports_rescan,
}), }),
ext_latency_vtable(clap_host_latency_t{
.changed = ext_latency_changed,
}),
ext_note_ports_vtable(clap_host_note_ports_t{ ext_note_ports_vtable(clap_host_note_ports_t{
.supported_dialects = ext_note_ports_supported_dialects, .supported_dialects = ext_note_ports_supported_dialects,
.rescan = ext_note_ports_rescan, .rescan = ext_note_ports_rescan,
@@ -71,6 +74,9 @@ clap_host_proxy::host_get_extension(const struct clap_host* host,
if (self->supported_extensions_.supports_audio_ports && if (self->supported_extensions_.supports_audio_ports &&
strcmp(extension_id, CLAP_EXT_AUDIO_PORTS) == 0) { strcmp(extension_id, CLAP_EXT_AUDIO_PORTS) == 0) {
extension_ptr = &self->ext_audio_ports_vtable; extension_ptr = &self->ext_audio_ports_vtable;
} else if (self->supported_extensions_.supports_latency &&
strcmp(extension_id, CLAP_EXT_LATENCY) == 0) {
extension_ptr = &self->ext_latency_vtable;
} else if (self->supported_extensions_.supports_note_ports && } else if (self->supported_extensions_.supports_note_ports &&
strcmp(extension_id, CLAP_EXT_NOTE_PORTS) == 0) { strcmp(extension_id, CLAP_EXT_NOTE_PORTS) == 0) {
extension_ptr = &self->ext_note_ports_vtable; extension_ptr = &self->ext_note_ports_vtable;
@@ -157,6 +163,14 @@ void CLAP_ABI clap_host_proxy::ext_audio_ports_rescan(const clap_host_t* host,
.owner_instance_id = self->owner_instance_id(), .flags = flags}); .owner_instance_id = self->owner_instance_id(), .flags = flags});
} }
void CLAP_ABI clap_host_proxy::ext_latency_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::latency::host::Changed{
.owner_instance_id = self->owner_instance_id()});
}
uint32_t CLAP_ABI uint32_t CLAP_ABI
clap_host_proxy::ext_note_ports_supported_dialects(const clap_host_t* host) { clap_host_proxy::ext_note_ports_supported_dialects(const clap_host_t* host) {
assert(host && host->host_data); assert(host && host->host_data);
@@ -19,6 +19,7 @@
#include <atomic> #include <atomic>
#include <clap/ext/audio-ports.h> #include <clap/ext/audio-ports.h>
#include <clap/ext/latency.h>
#include <clap/ext/note-ports.h> #include <clap/ext/note-ports.h>
#include <clap/ext/params.h> #include <clap/ext/params.h>
#include <clap/ext/tail.h> #include <clap/ext/tail.h>
@@ -72,6 +73,8 @@ class clap_host_proxy {
static void CLAP_ABI ext_audio_ports_rescan(const clap_host_t* host, static void CLAP_ABI ext_audio_ports_rescan(const clap_host_t* host,
uint32_t flags); uint32_t flags);
static void CLAP_ABI ext_latency_changed(const clap_host_t* host);
static uint32_t CLAP_ABI static uint32_t CLAP_ABI
ext_note_ports_supported_dialects(const clap_host_t* host); ext_note_ports_supported_dialects(const clap_host_t* host);
static void CLAP_ABI ext_note_ports_rescan(const clap_host_t* host, static void CLAP_ABI ext_note_ports_rescan(const clap_host_t* host,
@@ -109,6 +112,7 @@ class clap_host_proxy {
// depends on whether the plugin supported this extension when the host // depends on whether the plugin supported this extension when the host
// called `clap_plugin::init()`. // called `clap_plugin::init()`.
const clap_host_audio_ports_t ext_audio_ports_vtable; const clap_host_audio_ports_t ext_audio_ports_vtable;
const clap_host_latency_t ext_latency_vtable;
const clap_host_note_ports_t ext_note_ports_vtable; const clap_host_note_ports_t ext_note_ports_vtable;
const clap_host_params_t ext_params_vtable; const clap_host_params_t ext_params_vtable;
const clap_host_tail_t ext_tail_vtable; const clap_host_tail_t ext_tail_vtable;
+11
View File
@@ -29,6 +29,8 @@ namespace fs = ghc::filesystem;
ClapPluginExtensions::ClapPluginExtensions(const clap_plugin& plugin) noexcept ClapPluginExtensions::ClapPluginExtensions(const clap_plugin& plugin) noexcept
: audio_ports(static_cast<const clap_plugin_audio_ports_t*>( : audio_ports(static_cast<const clap_plugin_audio_ports_t*>(
plugin.get_extension(&plugin, CLAP_EXT_AUDIO_PORTS))), plugin.get_extension(&plugin, CLAP_EXT_AUDIO_PORTS))),
latency(static_cast<const clap_plugin_latency_t*>(
plugin.get_extension(&plugin, CLAP_EXT_LATENCY))),
note_ports(static_cast<const clap_plugin_note_ports_t*>( note_ports(static_cast<const clap_plugin_note_ports_t*>(
plugin.get_extension(&plugin, CLAP_EXT_NOTE_PORTS))), plugin.get_extension(&plugin, CLAP_EXT_NOTE_PORTS))),
params(static_cast<const clap_plugin_params_t*>( params(static_cast<const clap_plugin_params_t*>(
@@ -42,6 +44,7 @@ clap::plugin::SupportedPluginExtensions ClapPluginExtensions::supported()
const noexcept { const noexcept {
return clap::plugin::SupportedPluginExtensions{ return clap::plugin::SupportedPluginExtensions{
.supports_audio_ports = audio_ports != nullptr, .supports_audio_ports = audio_ports != nullptr,
.supports_latency = latency != nullptr,
.supports_note_ports = note_ports != nullptr, .supports_note_ports = note_ports != nullptr,
.supports_params = params != nullptr, .supports_params = params != nullptr,
.supports_tail = tail != nullptr}; .supports_tail = tail != nullptr};
@@ -342,6 +345,14 @@ void ClapBridge::run() {
.result = std::nullopt}; .result = std::nullopt};
} }
}, },
[&](clap::ext::latency::plugin::Get& request)
-> clap::ext::latency::plugin::Get::Response {
const auto& [instance, _] = get_instance(request.instance_id);
// We'll ignore the main thread requirement for simple lookups
// to avoid the synchronisation costs in hot code paths
return instance.extensions.latency->get(instance.plugin.get());
},
[&](const clap::ext::note_ports::plugin::Count& request) [&](const clap::ext::note_ports::plugin::Count& request)
-> clap::ext::note_ports::plugin::Count::Response { -> clap::ext::note_ports::plugin::Count::Response {
const auto& [instance, _] = get_instance(request.instance_id); const auto& [instance, _] = get_instance(request.instance_id);
+1
View File
@@ -67,6 +67,7 @@ struct ClapPluginExtensions {
clap::plugin::SupportedPluginExtensions supported() const noexcept; clap::plugin::SupportedPluginExtensions supported() const noexcept;
const clap_plugin_audio_ports_t* audio_ports = nullptr; const clap_plugin_audio_ports_t* audio_ports = nullptr;
const clap_plugin_latency_t* latency = nullptr;
const clap_plugin_note_ports_t* note_ports = nullptr; const clap_plugin_note_ports_t* note_ports = nullptr;
const clap_plugin_params_t* params = nullptr; const clap_plugin_params_t* params = nullptr;
const clap_plugin_tail_t* tail = nullptr; const clap_plugin_tail_t* tail = nullptr;