From c8735dbe368e7341435f99cb7fbc9a9bca65e696 Mon Sep 17 00:00:00 2001 From: David Schornsheim <6382400+Schroedingers-Cat@users.noreply.github.com> Date: Mon, 7 Jul 2025 10:40:21 +0200 Subject: [PATCH 1/4] Add base implementation of surround extension --- include/clap/helpers/host.hh | 8 ++++++ include/clap/helpers/host.hxx | 17 ++++++++++++ include/clap/helpers/plugin.hh | 22 ++++++++++++++++ include/clap/helpers/plugin.hxx | 46 +++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) diff --git a/include/clap/helpers/host.hh b/include/clap/helpers/host.hh index d712214..4a9a9e7 100644 --- a/include/clap/helpers/host.hh +++ b/include/clap/helpers/host.hh @@ -108,6 +108,10 @@ namespace clap { namespace helpers { virtual bool implementsThreadPool() const noexcept { return false; } virtual bool threadPoolRequestExec(uint32_t numTasks) noexcept { return false; } + // clap_host_surround + virtual bool implementsSurround() const noexcept { return false; } + virtual void surroundChanged() noexcept {} + ///////////////////// // Thread Checking // ///////////////////// @@ -187,6 +191,9 @@ namespace clap { namespace helpers { // clap_host_thread_pool static bool clapThreadPoolRequestExec(const clap_host *host, uint32_t num_tasks) noexcept; + // clap_host_surround + static void clapSurroundChanged(const clap_host_t *host) noexcept; + // interfaces static const clap_host_audio_ports _hostAudioPorts; static const clap_host_gui _hostGui; @@ -200,5 +207,6 @@ namespace clap { namespace helpers { static const clap_host_tail _hostTail; static const clap_host_thread_check _hostThreadCheck; static const clap_host_thread_pool _hostThreadPool; + static const clap_host_surround _hostSurround; }; }} // namespace clap::helpers diff --git a/include/clap/helpers/host.hxx b/include/clap/helpers/host.hxx index d0a6b1d..c466d32 100644 --- a/include/clap/helpers/host.hxx +++ b/include/clap/helpers/host.hxx @@ -81,6 +81,11 @@ namespace clap { namespace helpers { clapThreadPoolRequestExec, }; + template + const clap_host_surround Host::_hostSurround = { + clapSurroundChanged, + }; + template Host::Host(const char *name, const char *vendor, const char *url, const char *version) : _host{ @@ -160,6 +165,8 @@ namespace clap { namespace helpers { return &_hostThreadCheck; if (!strcmp(extension_id, CLAP_EXT_THREAD_POOL) && self.implementsThreadPool()) return &_hostThreadPool; + if (!std::strcmp(extension_id, CLAP_EXT_SURROUND) && self.implementsSurround()) + return &_hostSurround; if (self.enableDraftExtensions()) { // put draft ext here @@ -397,6 +404,16 @@ namespace clap { namespace helpers { return self.threadPoolRequestExec(num_tasks); } + //--------------------// + // clap_host_surround // + //--------------------// + template + void Host::clapSurroundChanged(const clap_host *host) noexcept { + auto &self = from(host); + self.ensureMainThread("surround.changed"); + self.surroundChanged(); + } + ///////////////////// // Thread Checking // ///////////////////// diff --git a/include/clap/helpers/plugin.hh b/include/clap/helpers/plugin.hh index 84dc9da..e7a5c26 100644 --- a/include/clap/helpers/plugin.hh +++ b/include/clap/helpers/plugin.hh @@ -163,6 +163,18 @@ namespace clap { namespace helpers { return false; } + //----------------------// + // clap_plugin_surround // + //----------------------// + virtual bool implementsSurround() const noexcept { return false; } + virtual bool isChannelMaskSupported(uint64_t channel_mask) const noexcept { return false; } + virtual uint32_t getChannelMap(bool is_input, + uint32_t port_index, + uint8_t *channel_map, + uint32_t channel_map_capacity) const noexcept { + return 0; + } + //--------------------// // clap_plugin_params // //--------------------// @@ -505,6 +517,15 @@ namespace clap { namespace helpers { const clap_audio_port_configuration_request *requests, uint32_t request_count) noexcept; + // clap_plugin_surround + static bool clapSurroundIsChannelMaskSupported(const clap_plugin_t *plugin, + uint64_t channel_mask) noexcept; + static uint32_t clapSurroundGetChannelMap(const clap_plugin_t *plugin, + bool is_input, + uint32_t port_index, + uint8_t *channel_map, + uint32_t channel_map_capacity) noexcept; + // clap_plugin_params static uint32_t clapParamsCount(const clap_plugin *plugin) noexcept; static bool clapParamsInfo(const clap_plugin *plugin, @@ -661,6 +682,7 @@ namespace clap { namespace helpers { 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_surround_t _pluginSurroundConfig; 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 179cfcc..8ab7a56 100644 --- a/include/clap/helpers/plugin.hxx +++ b/include/clap/helpers/plugin.hxx @@ -69,6 +69,12 @@ namespace clap { namespace helpers { clapConfigurableAudioPortsApplyConfiguration, }; + template + const clap_plugin_surround_t Plugin::_pluginSurroundConfig = { + clapSurroundIsChannelMaskSupported, + clapSurroundGetChannelMap, + }; + template const clap_plugin_params Plugin::_pluginParams = { clapParamsCount, @@ -509,6 +515,8 @@ namespace clap { namespace helpers { return &_pluginAudioPortsActivation; if (!strcmp(id, CLAP_EXT_AUDIO_PORTS_CONFIG) && self.implementsAudioPortsConfig()) return &_pluginAudioPortsConfig; + if (!strcmp(id, CLAP_EXT_SURROUND) && self.implementsSurround()) + return &_pluginSurroundConfig; if (!strcmp(id, CLAP_EXT_CONFIGURABLE_AUDIO_PORTS) && self.implementsConfigurableAudioPorts()) return &_pluginConfigurableAudioPorts; if (!strcmp(id, CLAP_EXT_PARAMS) && self.implementsParams()) @@ -888,6 +896,44 @@ namespace clap { namespace helpers { return applyConfigurationSuccess; } + //----------------------// + // clap_plugin_surround // + //----------------------// + template + bool Plugin::clapSurroundIsChannelMaskSupported(const clap_plugin_t *plugin, + uint64_t channel_mask) noexcept { + auto &self = from(plugin); + auto methodName = "clap_plugin_surround.is_channel_mask_supported"; + self.ensureMainThread(methodName); + self.ensureIsInactive(methodName); + + return self.isChannelMaskSupported(channel_mask); + } + + template + uint32_t Plugin::clapSurroundGetChannelMap(const clap_plugin_t *plugin, + bool is_input, + uint32_t port_index, + uint8_t *channel_map, + uint32_t channel_map_capacity) noexcept { + auto &self = from(plugin); + auto methodName = "clap_plugin_surround.get_channel_map"; + self.ensureMainThread(methodName); + self.ensureIsInactive(methodName); + + const uint32_t channel_count = + self.getChannelMap(is_input, port_index, channel_map, channel_map_capacity); + + if (l >= CheckingLevel::Minimal && channel_count > channel_map_capacity) { + self._host.pluginMisbehaving( + "Plugin's functions clap_plugin_surround.get_channel_map cannot return a channel " + "count greater than channel_map_capacity."); + return channel_map_capacity; + } + + return channel_count; + } + //--------------------// // clap_plugin_params // //--------------------// From aa0a04a915bd1044070d55388e111b9c23bf3c8e Mon Sep 17 00:00:00 2001 From: David Schornsheim <6382400+Schroedingers-Cat@users.noreply.github.com> Date: Tue, 8 Jul 2025 09:15:00 +0200 Subject: [PATCH 2/4] Comment out windows clang test due to broken env --- .github/workflows/pullreq.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pullreq.yml b/.github/workflows/pullreq.yml index a9d916b..ac0c521 100644 --- a/.github/workflows/pullreq.yml +++ b/.github/workflows/pullreq.yml @@ -31,11 +31,11 @@ jobs: # name: Windows gcc/minGW # exe: .exe - - os: windows-latest - cmakeargs: -GNinja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang - install_ninja: true - name: Windows clang - exe: .exe +# - os: windows-latest +# cmakeargs: -GNinja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang +# install_ninja: true +# name: Windows clang +# exe: .exe - os: ubuntu-latest cmakeargs: -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_C_COMPILER=gcc-12 -DCLAP_HELPERS_TESTS_CXX_STANDARD=11 From a2989d03b74c78bd28a493e9c9eba4c37335bb20 Mon Sep 17 00:00:00 2001 From: David Schornsheim <6382400+Schroedingers-Cat@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:14:11 +0200 Subject: [PATCH 3/4] Remove wrong check #84#discussion_r2192490266 --- include/clap/helpers/plugin.hxx | 1 - 1 file changed, 1 deletion(-) diff --git a/include/clap/helpers/plugin.hxx b/include/clap/helpers/plugin.hxx index 8ab7a56..a9a3568 100644 --- a/include/clap/helpers/plugin.hxx +++ b/include/clap/helpers/plugin.hxx @@ -919,7 +919,6 @@ namespace clap { namespace helpers { auto &self = from(plugin); auto methodName = "clap_plugin_surround.get_channel_map"; self.ensureMainThread(methodName); - self.ensureIsInactive(methodName); const uint32_t channel_count = self.getChannelMap(is_input, port_index, channel_map, channel_map_capacity); From 9a3baa7ca5c70f3486bd16e05903d324c8f56214 Mon Sep 17 00:00:00 2001 From: David Schornsheim <6382400+Schroedingers-Cat@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:14:22 +0200 Subject: [PATCH 4/4] Remove wrong check #84#discussion_r2192491651 --- include/clap/helpers/plugin.hxx | 1 - 1 file changed, 1 deletion(-) diff --git a/include/clap/helpers/plugin.hxx b/include/clap/helpers/plugin.hxx index a9a3568..f844101 100644 --- a/include/clap/helpers/plugin.hxx +++ b/include/clap/helpers/plugin.hxx @@ -905,7 +905,6 @@ namespace clap { namespace helpers { auto &self = from(plugin); auto methodName = "clap_plugin_surround.is_channel_mask_supported"; self.ensureMainThread(methodName); - self.ensureIsInactive(methodName); return self.isChannelMaskSupported(channel_mask); }