Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/pullreq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions include/clap/helpers/host.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
/////////////////////
Expand Down Expand Up @@ -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;
Expand All @@ -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
17 changes: 17 additions & 0 deletions include/clap/helpers/host.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ namespace clap { namespace helpers {
clapThreadPoolRequestExec,
};

template <MisbehaviourHandler h, CheckingLevel l>
const clap_host_surround Host<h, l>::_hostSurround = {
clapSurroundChanged,
};

template <MisbehaviourHandler h, CheckingLevel l>
Host<h, l>::Host(const char *name, const char *vendor, const char *url, const char *version)
: _host{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -397,6 +404,16 @@ namespace clap { namespace helpers {
return self.threadPoolRequestExec(num_tasks);
}

//--------------------//
// clap_host_surround //
//--------------------//
template <MisbehaviourHandler h, CheckingLevel l>
void Host<h, l>::clapSurroundChanged(const clap_host *host) noexcept {
auto &self = from(host);
self.ensureMainThread("surround.changed");
self.surroundChanged();
}

/////////////////////
// Thread Checking //
/////////////////////
Expand Down
22 changes: 22 additions & 0 deletions include/clap/helpers/plugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
//--------------------//
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
44 changes: 44 additions & 0 deletions include/clap/helpers/plugin.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ namespace clap { namespace helpers {
clapConfigurableAudioPortsApplyConfiguration,
};

template <MisbehaviourHandler h, CheckingLevel l>
const clap_plugin_surround_t Plugin<h, l>::_pluginSurroundConfig = {
clapSurroundIsChannelMaskSupported,
clapSurroundGetChannelMap,
};

template <MisbehaviourHandler h, CheckingLevel l>
const clap_plugin_params Plugin<h, l>::_pluginParams = {
clapParamsCount,
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -888,6 +896,42 @@ namespace clap { namespace helpers {
return applyConfigurationSuccess;
}

//----------------------//
// clap_plugin_surround //
//----------------------//
template <MisbehaviourHandler h, CheckingLevel l>
bool Plugin<h, l>::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);

return self.isChannelMaskSupported(channel_mask);
}

template <MisbehaviourHandler h, CheckingLevel l>
uint32_t Plugin<h, l>::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);

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 //
//--------------------//
Expand Down