From a444bb67764499855ad736219b5f2cad08b817ba Mon Sep 17 00:00:00 2001 From: MeijisIrlnd Date: Sat, 14 Sep 2024 15:37:10 +0100 Subject: [PATCH 1/3] added support for configurable-audio-ports in plugin.hh / plugin.hxx --- include/clap/helpers/plugin.hh | 21 ++++++++++++++++++ include/clap/helpers/plugin.hxx | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/clap/helpers/plugin.hh b/include/clap/helpers/plugin.hh index 6e71e16..364d66d 100644 --- a/include/clap/helpers/plugin.hh +++ b/include/clap/helpers/plugin.hh @@ -150,6 +150,18 @@ namespace clap { namespace helpers { return false; } + //------------------------------------// + // clap_configurable_audio_ports // + //------------------------------------// + virtual bool implementsConfigurableAudioPorts() const noexcept { return false; }; + virtual bool configurableAudioPortsCanApplyConfiguration(const clap_audio_port_configuration_request* requests, + uint32_t requests_count) noexcept { + return false; + } + virtual bool configurableAudioPortsApplyConfiguration(const clap_audio_port_configuration_request* requests, + uint32_t requests_count) noexcept { + return false; + } //--------------------// // clap_plugin_params // //--------------------// @@ -427,6 +439,14 @@ namespace clap { namespace helpers { bool is_active, uint32_t sample_size) noexcept; + static bool clapConfigurableAudioPortsCanApplyConfiguration(const clap_plugin_t* plugin, + const clap_audio_port_configuration_request* requests, + uint32_t requests_count) noexcept; + + static bool clapConfigurableAudioPortsApplyConfiguration(const clap_plugin_t* plugin, + const clap_audio_port_configuration_request* requests, + uint32_t requests_count) noexcept; + // clap_plugin_params static uint32_t clapParamsCount(const clap_plugin *plugin) noexcept; static bool clapParamsInfo(const clap_plugin *plugin, @@ -552,6 +572,7 @@ namespace clap { namespace helpers { static const clap_plugin_audio_ports _pluginAudioPorts; static const clap_plugin_audio_ports_config _pluginAudioPortsConfig; static const clap_plugin_audio_ports_activation _pluginAudioPortsActivation; + static const clap_plugin_configurable_audio_ports _pluginConfigurableAudioPorts; static const clap_plugin_gui _pluginGui; static const clap_plugin_latency _pluginLatency; static const clap_plugin_note_name _pluginNoteName; diff --git a/include/clap/helpers/plugin.hxx b/include/clap/helpers/plugin.hxx index be29ec5..8798d69 100644 --- a/include/clap/helpers/plugin.hxx +++ b/include/clap/helpers/plugin.hxx @@ -61,6 +61,12 @@ namespace clap { namespace helpers { clapAudioPortsActivationSetActive, }; + template + const clap_plugin_configurable_audio_ports Plugin::_pluginConfigurableAudioPorts = { + clapConfigurableAudioPortsCanApplyConfiguration, + clapConfigurableAudioPortsApplyConfiguration + }; + template const clap_plugin_params Plugin::_pluginParams = { clapParamsCount, @@ -472,6 +478,8 @@ namespace clap { namespace helpers { return &_pluginAudioPortsActivation; if (!strcmp(id, CLAP_EXT_AUDIO_PORTS_CONFIG) && self.implementsAudioPortsConfig()) return &_pluginAudioPortsConfig; + if(!strcmp(id, CLAP_EXT_CONFIGURABLE_AUDIO_PORTS) && self.implementsConfigurableAudioPorts()) + return &_pluginConfigurableAudioPorts; if (!strcmp(id, CLAP_EXT_PARAMS) && self.implementsParams()) return &_pluginParams; if ((!strcmp(id, CLAP_EXT_PARAM_INDICATION) || @@ -783,6 +791,36 @@ namespace clap { namespace helpers { return self.audioPortsActivationSetActive(is_input, port_index, is_active, sample_size); } + template + bool Plugin::clapConfigurableAudioPortsCanApplyConfiguration(const clap_plugin_t *plugin, const clap_audio_port_configuration_request *requests, uint32_t requests_count) noexcept { + auto& self = from(plugin); + self.ensureMainThread("clap_plugin_configurable_audio_ports.can_apply_configuration"); + if(l >= CheckingLevel::Minimal) { + if(self.isActive()) { + self.hostMisbehaving( + "it is illegal to call clap_plugin_configurable_audio_ports.can_apply_configuration " + "if the plugin is active" + ); + } + } + return self.configurableAudioPortsCanApplyConfiguration(requests, requests_count); + } + + template + bool Plugin::clapConfigurableAudioPortsApplyConfiguration(const clap_plugin_t *plugin, const clap_audio_port_configuration_request *requests, uint32_t requests_count) noexcept { + auto& self = from(plugin); + self.ensureMainThread("clap_plugin_configurable_audio_ports.apply_configuration"); + if(l >= CheckingLevel::Minimal) { + if(self.isActive()) { + self.hostMisbehaving( + "it is illegal to call clap_plugin_configurable_audio_ports.apply_configuration " + "if the plugin is active" + ); + } + } + return self.configurableAudioPortsApplyConfiguration(requests, requests_count); + } + template uint32_t Plugin::clapParamsCount(const clap_plugin *plugin) noexcept { auto &self = from(plugin); From 74834f7885430265d8c685a81108c177e9e1ceb3 Mon Sep 17 00:00:00 2001 From: MeijisIrlnd Date: Sat, 14 Sep 2024 15:58:47 +0100 Subject: [PATCH 2/3] configurable-audio-ports in plugin-proxy --- include/clap/helpers/plugin-proxy.hh | 8 ++++++++ include/clap/helpers/plugin-proxy.hxx | 29 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/clap/helpers/plugin-proxy.hh b/include/clap/helpers/plugin-proxy.hh index a92760d..ecc92e5 100644 --- a/include/clap/helpers/plugin-proxy.hh +++ b/include/clap/helpers/plugin-proxy.hh @@ -35,6 +35,13 @@ namespace clap { namespace helpers { uint32_t audioPortsCount(bool isInput) const noexcept; bool audioPortsGet(uint32_t index, bool isInput, clap_audio_port_info_t *info) const noexcept; + ///////////////////////////// + // clap_plugin_configurable_audio_ports // + ///////////////////////////// + bool canUseConfigurableAudioPorts() const noexcept; + bool configurableAudioPortsCanApplyConfiguration(clap_audio_port_configuration_request* requests, uint32_t requests_count) const noexcept; + bool configurableAudioPortsApplyConfiguration(clap_audio_port_configuration_request* requests, uint32_t requests_count) const noexcept; + ///////////////////// // clap_plugin_gui // ///////////////////// @@ -154,6 +161,7 @@ namespace clap { namespace helpers { const clap_plugin& _plugin; const clap_plugin_audio_ports *_pluginAudioPorts = nullptr; + const clap_plugin_configurable_audio_ports *_pluginConfigurableAudioPorts = nullptr; const clap_plugin_gui *_pluginGui = nullptr; const clap_plugin_latency *_pluginLatency = nullptr; const clap_plugin_note_ports *_pluginNotePorts = nullptr; diff --git a/include/clap/helpers/plugin-proxy.hxx b/include/clap/helpers/plugin-proxy.hxx index e768639..f0f574d 100644 --- a/include/clap/helpers/plugin-proxy.hxx +++ b/include/clap/helpers/plugin-proxy.hxx @@ -13,6 +13,7 @@ namespace clap { namespace helpers { return false; getExtension(_pluginAudioPorts, CLAP_EXT_AUDIO_PORTS); + getExtension(_pluginConfigurableAudioPorts, CLAP_EXT_CONFIGURABLE_AUDIO_PORTS); getExtension(_pluginGui, CLAP_EXT_GUI); getExtension(_pluginLatency, CLAP_EXT_LATENCY); getExtension(_pluginNotePorts, CLAP_EXT_NOTE_PORTS); @@ -48,6 +49,7 @@ namespace clap { namespace helpers { _plugin.destroy(&_plugin); _pluginAudioPorts = nullptr; + _pluginConfigurableAudioPorts = nullptr; _pluginGui = nullptr; _pluginParams = nullptr; _pluginPosixFdSupport = nullptr; @@ -137,6 +139,33 @@ namespace clap { namespace helpers { return _pluginAudioPorts->get(&_plugin, index, isInput, info); } + ///////////////////////////// + // clap_plugin_configurable_audio_ports // + ///////////////////////////// + template + bool PluginProxy::canUseConfigurableAudioPorts() const noexcept { + if(!_pluginConfigurableAudioPorts) { + return false; + } + return true; + } + + template + bool PluginProxy::configurableAudioPortsCanApplyConfiguration(clap_audio_port_configuration_request *requests, uint32_t requests_count) const noexcept { + if(!_pluginConfigurableAudioPorts) return false; + ensureMainThread("clap_plugin_configurable_audio_ports.can_apply_configuration"); + return _pluginConfigurableAudioPorts->can_apply_configuration(requests, requests_count); + } + + template + bool PluginProxy::configurableAudioPortsApplyConfiguration(clap_audio_port_configuration_request *requests, uint32_t requests_count) const noexcept { + if(!_pluginConfigurableAudioPorts) return false; + ensureMainThread("clap_plugin_configurable_audio_ports.apply_configuration"); + return _pluginConfigurableAudioPorts->apply_configuration(requests, requests_count); + } + + + ///////////////////// // clap_plugin_gui // ///////////////////// From 6829da7c4f182fa85ac38db3a389aba96a46c495 Mon Sep 17 00:00:00 2001 From: MeijisIrlnd Date: Sat, 14 Sep 2024 21:54:32 +0100 Subject: [PATCH 3/3] fixed missing arg in proxy --- include/clap/helpers/plugin-proxy.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clap/helpers/plugin-proxy.hxx b/include/clap/helpers/plugin-proxy.hxx index f0f574d..6076c7f 100644 --- a/include/clap/helpers/plugin-proxy.hxx +++ b/include/clap/helpers/plugin-proxy.hxx @@ -154,14 +154,14 @@ namespace clap { namespace helpers { bool PluginProxy::configurableAudioPortsCanApplyConfiguration(clap_audio_port_configuration_request *requests, uint32_t requests_count) const noexcept { if(!_pluginConfigurableAudioPorts) return false; ensureMainThread("clap_plugin_configurable_audio_ports.can_apply_configuration"); - return _pluginConfigurableAudioPorts->can_apply_configuration(requests, requests_count); + return _pluginConfigurableAudioPorts->can_apply_configuration(&_plugin, requests, requests_count); } template bool PluginProxy::configurableAudioPortsApplyConfiguration(clap_audio_port_configuration_request *requests, uint32_t requests_count) const noexcept { if(!_pluginConfigurableAudioPorts) return false; ensureMainThread("clap_plugin_configurable_audio_ports.apply_configuration"); - return _pluginConfigurableAudioPorts->apply_configuration(requests, requests_count); + return _pluginConfigurableAudioPorts->apply_configuration(&_plugin, requests, requests_count); }