mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Implement the host side of the GUI functions
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "host.h"
|
||||
|
||||
#include <clap/ext/audio-ports.h>
|
||||
#include <clap/ext/gui.h>
|
||||
#include <clap/ext/latency.h>
|
||||
#include <clap/ext/note-ports.h>
|
||||
#include <clap/ext/params.h>
|
||||
@@ -33,9 +34,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*>, 6> SupportedHostExtensions::list()
|
||||
std::array<std::pair<bool, const char*>, 7> SupportedHostExtensions::list()
|
||||
const noexcept {
|
||||
return {std::pair(supports_audio_ports, CLAP_EXT_AUDIO_PORTS),
|
||||
std::pair(supports_gui, CLAP_EXT_GUI),
|
||||
std::pair(supports_latency, CLAP_EXT_LATENCY),
|
||||
std::pair(supports_note_ports, CLAP_EXT_NOTE_PORTS),
|
||||
std::pair(supports_params, CLAP_EXT_PARAMS),
|
||||
|
||||
@@ -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_gui = false;
|
||||
bool supports_latency = false;
|
||||
bool supports_note_ports = false;
|
||||
bool supports_params = false;
|
||||
@@ -92,11 +93,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*>, 6> list() const noexcept;
|
||||
std::array<std::pair<bool, const char*>, 7> list() const noexcept;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value1b(supports_audio_ports);
|
||||
s.value1b(supports_gui);
|
||||
s.value1b(supports_latency);
|
||||
s.value1b(supports_note_ports);
|
||||
s.value1b(supports_params);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
ClapHostExtensions::ClapHostExtensions(const clap_host& host) noexcept
|
||||
: audio_ports(static_cast<const clap_host_audio_ports_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_AUDIO_PORTS))),
|
||||
gui(static_cast<const clap_host_gui_t*>(
|
||||
host.get_extension(&host, CLAP_EXT_GUI))),
|
||||
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*>(
|
||||
@@ -38,6 +40,7 @@ clap::host::SupportedHostExtensions ClapHostExtensions::supported()
|
||||
const noexcept {
|
||||
return clap::host::SupportedHostExtensions{
|
||||
.supports_audio_ports = audio_ports != nullptr,
|
||||
.supports_gui = gui != nullptr,
|
||||
.supports_latency = latency != nullptr,
|
||||
.supports_note_ports = note_ports != nullptr,
|
||||
.supports_params = params != nullptr,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <clap/ext/audio-ports.h>
|
||||
#include <clap/ext/gui.h>
|
||||
#include <clap/ext/latency.h>
|
||||
#include <clap/ext/note-ports.h>
|
||||
#include <clap/ext/params.h>
|
||||
@@ -62,6 +63,7 @@ struct ClapHostExtensions {
|
||||
clap::host::SupportedHostExtensions supported() const noexcept;
|
||||
|
||||
const clap_host_audio_ports_t* audio_ports = nullptr;
|
||||
const clap_host_gui_t* gui = nullptr;
|
||||
const clap_host_latency_t* latency = nullptr;
|
||||
const clap_host_note_ports_t* note_ports = nullptr;
|
||||
const clap_host_params_t* params = nullptr;
|
||||
|
||||
@@ -115,6 +115,55 @@ ClapPluginBridge::ClapPluginBridge(const ghc::filesystem::path& plugin_path)
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
[&](const clap::ext::gui::host::ResizeHintsChanged& request)
|
||||
-> clap::ext::gui::host::ResizeHintsChanged::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
// This callback is thread-safe
|
||||
plugin_proxy.host_extensions_.gui->resize_hints_changed(
|
||||
plugin_proxy.host_);
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
[&](const clap::ext::gui::host::RequestResize& request)
|
||||
-> clap::ext::gui::host::RequestResize::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
// This callback is thread-safe
|
||||
return plugin_proxy.host_extensions_.gui->request_resize(
|
||||
plugin_proxy.host_, request.width, request.height);
|
||||
},
|
||||
[&](const clap::ext::gui::host::RequestShow& request)
|
||||
-> clap::ext::gui::host::RequestShow::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
// This callback is thread-safe
|
||||
return plugin_proxy.host_extensions_.gui->request_show(
|
||||
plugin_proxy.host_);
|
||||
},
|
||||
[&](const clap::ext::gui::host::RequestHide& request)
|
||||
-> clap::ext::gui::host::RequestHide::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
// This callback is thread-safe
|
||||
return plugin_proxy.host_extensions_.gui->request_hide(
|
||||
plugin_proxy.host_);
|
||||
},
|
||||
[&](const clap::ext::gui::host::Closed& request)
|
||||
-> clap::ext::gui::host::Closed::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
get_proxy(request.owner_instance_id);
|
||||
|
||||
// This callback is thread-safe
|
||||
plugin_proxy.host_extensions_.gui->closed(
|
||||
plugin_proxy.host_, request.was_destroyed);
|
||||
|
||||
return Ack{};
|
||||
},
|
||||
[&](const clap::ext::latency::host::Changed& request)
|
||||
-> clap::ext::latency::host::Changed::Response {
|
||||
const auto& [plugin_proxy, _] =
|
||||
|
||||
Reference in New Issue
Block a user