From e39a43c38c2f4a8a7aac603c47540aaab05bebf7 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 12 Sep 2022 17:03:12 +0200 Subject: [PATCH] Add stubs for plugin side audio ports extension --- .../bridges/clap-impls/plugin-proxy.cpp | 37 +++++++++++++++++-- src/plugin/bridges/clap-impls/plugin-proxy.h | 13 +++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/plugin/bridges/clap-impls/plugin-proxy.cpp b/src/plugin/bridges/clap-impls/plugin-proxy.cpp index cb6ed39d..3508d58a 100644 --- a/src/plugin/bridges/clap-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/clap-impls/plugin-proxy.cpp @@ -40,6 +40,10 @@ clap_plugin_proxy::clap_plugin_proxy(ClapPluginBridge& bridge, .get_extension = plugin_get_extension, .on_main_thread = plugin_on_main_thread, }), + ext_audio_ports_vtable(clap_plugin_audio_ports_t{ + .count = ext_audio_ports_count, + .get = ext_audio_ports_get, + }), // These function objects are relatively large, and we probably won't be // getting that many of them pending_callbacks_(128) {} @@ -146,15 +150,18 @@ clap_plugin_proxy::plugin_process(const struct clap_plugin* plugin, const void* CLAP_ABI clap_plugin_proxy::plugin_get_extension(const struct clap_plugin* plugin, const char* id) { - assert(plugin && plugin->plugin_data); + assert(plugin && plugin->plugin_data && id); auto self = static_cast(plugin->plugin_data); // TODO: When implementing the GUI option, add a `clap_no_scaling` option to // disable HiDPI scaling just like we have for VST3. Or rename the // existing one. - - // TODO: Implement - return nullptr; + if (self->supported_extensions_.supports_audio_ports && + strcmp(id, CLAP_EXT_AUDIO_PORTS) == 0) { + return &self->ext_audio_ports_vtable; + } else { + return nullptr; + } } void CLAP_ABI @@ -169,3 +176,25 @@ clap_plugin_proxy::plugin_on_main_thread(const struct clap_plugin* plugin) { callback(); } } + +uint32_t CLAP_ABI +clap_plugin_proxy::ext_audio_ports_count(const clap_plugin_t* plugin, + bool is_input) { + assert(plugin && plugin->plugin_data); + auto self = static_cast(plugin->plugin_data); + + // TODO: Implement + return 0; +} + +bool CLAP_ABI +clap_plugin_proxy::ext_audio_ports_get(const clap_plugin_t* plugin, + uint32_t index, + bool is_input, + clap_audio_port_info_t* info) { + assert(plugin && plugin->plugin_data && info); + auto self = static_cast(plugin->plugin_data); + + // TODO: Implement + return false; +} diff --git a/src/plugin/bridges/clap-impls/plugin-proxy.h b/src/plugin/bridges/clap-impls/plugin-proxy.h index 594ebcb0..3d059fa5 100644 --- a/src/plugin/bridges/clap-impls/plugin-proxy.h +++ b/src/plugin/bridges/clap-impls/plugin-proxy.h @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -93,6 +94,13 @@ class clap_plugin_proxy { static void CLAP_ABI plugin_on_main_thread(const struct clap_plugin* plugin); + static uint32_t CLAP_ABI ext_audio_ports_count(const clap_plugin_t* plugin, + bool is_input); + static bool CLAP_ABI ext_audio_ports_get(const clap_plugin_t* plugin, + uint32_t index, + bool is_input, + clap_audio_port_info_t* info); + /** * Asynchronously run a function on the host's main thread, returning the * result as a future. @@ -139,6 +147,11 @@ class clap_plugin_proxy { */ const clap_plugin_t plugin_vtable_; + // Extensions also have vtables. Whether or not we expose these to the host + // depends on whether the plugin supported this extension when we called + // `clap_plugin::init()`. + const clap_plugin_audio_ports ext_audio_ports_vtable; + /** * The extensions supported by the bridged plugin. Set after a successful * `clap_plugin::init()` call. We'll allow the host to query these same