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
+3
View File
@@ -23,6 +23,7 @@
#include "../bitsery/ext/message-reference.h"
#include "../utils.h"
#include "clap/ext/audio-ports.h"
#include "clap/ext/latency.h"
#include "clap/ext/note-ports.h"
#include "clap/ext/params.h"
#include "clap/ext/tail.h"
@@ -53,6 +54,7 @@ using ClapMainThreadControlRequest =
clap::plugin::Deactivate,
clap::ext::audio_ports::plugin::Count,
clap::ext::audio_ports::plugin::Get,
clap::ext::latency::plugin::Get,
clap::ext::note_ports::plugin::Count,
clap::ext::note_ports::plugin::Get,
clap::ext::params::plugin::Count,
@@ -147,6 +149,7 @@ using ClapMainThreadCallbackRequest =
std::variant<WantsConfiguration,
clap::host::RequestRestart,
clap::host::RequestProcess,
clap::ext::latency::host::Changed,
clap::ext::audio_ports::host::IsRescanFlagSupported,
clap::ext::audio_ports::host::Rescan,
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.event-registry` | :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.note-name` | :x: Not supported yet |
| `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 <clap/ext/audio-ports.h>
#include <clap/ext/latency.h>
#include <clap/ext/note-ports.h>
#include <clap/ext/params.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),
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 {
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_params, CLAP_EXT_PARAMS),
std::pair(supports_tail, CLAP_EXT_TAIL)};
+3 -1
View File
@@ -82,6 +82,7 @@ struct Host {
struct SupportedHostExtensions {
// Don't forget to add new extensions to below method
bool supports_audio_ports = false;
bool supports_latency = false;
bool supports_note_ports = false;
bool supports_params = false;
bool supports_tail = false;
@@ -90,11 +91,12 @@ struct SupportedHostExtensions {
* Get a list of `<bool, extension_name>` tuples for the supported
* 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>
void serialize(S& s) {
s.value1b(supports_audio_ports);
s.value1b(supports_latency);
s.value1b(supports_note_ports);
s.value1b(supports_params);
s.value1b(supports_tail);
+3 -1
View File
@@ -17,6 +17,7 @@
#include "plugin.h"
#include <clap/ext/audio-ports.h>
#include <clap/ext/latency.h>
#include <clap/ext/note-ports.h>
#include <clap/ext/params.h>
#include <clap/ext/tail.h>
@@ -79,9 +80,10 @@ const clap_plugin_descriptor_t* Descriptor::get() const {
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 {
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_params, CLAP_EXT_PARAMS),
std::pair(supports_tail, CLAP_EXT_TAIL)};
+3 -1
View File
@@ -115,6 +115,7 @@ struct Descriptor {
struct SupportedPluginExtensions {
// Don't forget to add new extensions to below method
bool supports_audio_ports = false;
bool supports_latency = false;
bool supports_note_ports = false;
bool supports_params = false;
bool supports_tail = false;
@@ -123,11 +124,12 @@ struct SupportedPluginExtensions {
* Get a list of `<bool, extension_name>` tuples for the supported
* 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>
void serialize(S& s) {
s.value1b(supports_audio_ports);
s.value1b(supports_latency);
s.value1b(supports_note_ports);
s.value1b(supports_params);
s.value1b(supports_tail);