Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ ignore/
build/
out/
.DS_Store

# Meson
.meson-subproject*
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ if (${CLAP_HELPERS_BUILD_TESTS})
tests/preset-discovery-indexer.cc
tests/preset-discovery-provider.cc
tests/preset-discovery-metadata-receiver.cc
tests/use-custom-extension.cc
)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD ${CLAP_HELPERS_TESTS_CXX_STANDARD})
set_target_properties(${PROJECT_NAME}-tests PROPERTIES CXX_STANDARD ${CLAP_HELPERS_TESTS_CXX_STANDARD})
Expand Down
2 changes: 1 addition & 1 deletion include/clap/helpers/checking-level.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ namespace clap { namespace helpers {
Minimal,
Maximal,
};
}} // namespace clap::helpers
}} // namespace clap::helpers
9 changes: 8 additions & 1 deletion include/clap/helpers/host-proxy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,18 @@ namespace clap { namespace helpers {
bool canUseMiniCurveDisplay() const noexcept;
void miniCurveDisplaySetDynamic(bool is_dynamic) const noexcept;
void miniCurveDisplayChanged(uint32_t flags) const noexcept;
bool miniCurveDisplayGetHints(uint32_t kind,
clap_mini_curve_display_curve_hints_t *hints) const noexcept;

//////////////////////////////
// Custom extension helpers //
//////////////////////////////

protected:
void ensureMainThread(const char *method) const noexcept;
void ensureAudioThread(const char *method) const noexcept;
const clap_host *clapHost() const noexcept { return _host; }

protected:
const clap_host *const _host;

const clap_host_log *_hostLog = nullptr;
Expand Down
14 changes: 14 additions & 0 deletions include/clap/helpers/host-proxy.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -806,4 +806,18 @@ namespace clap { namespace helpers {
_hostMiniCurveDisplay->changed(_host, flags);
}

template <MisbehaviourHandler h, CheckingLevel l>
bool HostProxy<h, l>::miniCurveDisplayGetHints(
uint32_t kind, clap_mini_curve_display_curve_hints_t *hints) const noexcept {
assert(canUseMiniCurveDisplay());
ensureMainThread("mini_curve_display_get_hints");

if (!hints) {
pluginMisbehaving("mini_curve_display_get_hints() called with a null hints pointer");
return false;
}

return _hostMiniCurveDisplay->get_hints(_host, kind, hints);
}

}} // namespace clap::helpers
9 changes: 9 additions & 0 deletions include/clap/helpers/host.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace clap { namespace helpers {
virtual void requestCallback() noexcept = 0;

virtual bool enableDraftExtensions() const noexcept { return false; }
virtual const void* getExtension(const char* extensionId) const noexcept { return nullptr; }

// clap_host_audio_ports
virtual bool implementsAudioPorts() const noexcept { return false; }
Expand Down Expand Up @@ -107,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 @@ -186,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 @@ -199,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
20 changes: 20 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 @@ -132,6 +137,8 @@ namespace clap { namespace helpers {
const void *Host<h, l>::clapGetExtension(const clap_host_t *host,
const char *extension_id) noexcept {
auto &self = from(host);
if (auto ext = self.getExtension(extension_id))
return ext;
if (!std::strcmp(extension_id, CLAP_EXT_AUDIO_PORTS) && self.implementsAudioPorts())
return &_hostAudioPorts;
if (!std::strcmp(extension_id, CLAP_EXT_GUI) && self.implementsGui())
Expand All @@ -158,10 +165,13 @@ 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
}

return nullptr;
}

Expand Down Expand Up @@ -394,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
2 changes: 1 addition & 1 deletion include/clap/helpers/misbehaviour-handler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace clap { namespace helpers {
Ignore,
Terminate,
};
}} // namespace clap::helpers
}} // namespace clap::helpers
2 changes: 1 addition & 1 deletion include/clap/helpers/param-queue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ namespace clap { namespace helpers {
std::atomic<int> _writeOffset = {0};
std::atomic<int> _readOffset = {0};
};
}} // namespace clap::helpers
}} // namespace clap::helpers
42 changes: 35 additions & 7 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 @@ -339,12 +351,16 @@ namespace clap { namespace helpers {
// clap_plugin_mini_curve_display //
//--------------------------------//
virtual bool implementsMiniCurveDisplay() const noexcept { return false; }
virtual bool miniCurveDisplayRender(uint16_t *data, uint32_t data_size) noexcept {
return false;
virtual uint32_t miniCurveDisplayGetCurveCount() const noexcept { return 0; }
virtual uint32_t miniCurveDisplayRender(clap_mini_curve_display_curve_data_t *curves,
uint32_t curves_size) noexcept {
return 0;
}
virtual void miniCurveDisplaySetObserved(bool is_observed) noexcept {}
virtual bool
miniCurveDisplayGetAxisName(char *x_name, char *y_name, uint32_t name_capacity) noexcept {
virtual bool miniCurveDisplayGetAxisName(uint32_t curve_index,
char *x_name,
char *y_name,
uint32_t name_capacity) noexcept {
return false;
}

Expand Down Expand Up @@ -501,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 @@ -640,12 +665,14 @@ namespace clap { namespace helpers {
static double clapGainAdjustmentMeteringGet(const clap_plugin_t *plugin) noexcept;

// clap_plugin_mini_curve_display
static bool clapMiniCurveDisplayRender(const clap_plugin_t *plugin,
uint16_t *data,
uint32_t data_size) noexcept;
static uint32_t clapMiniCurveDisplayGetCurveCount(const clap_plugin_t *plugin) noexcept;
static uint32_t clapMiniCurveDisplayRender(const clap_plugin_t *plugin,
clap_mini_curve_display_curve_data_t *curves,
uint32_t curves_size) noexcept;
static void clapMiniCurveDisplaySetObserved(const clap_plugin_t *plugin,
bool is_observed) noexcept;
static bool clapMiniCurveDisplayGetAxisName(const clap_plugin_t *plugin,
uint32_t curve_index,
char *x_name,
char *y_name,
uint32_t name_capacity) noexcept;
Expand All @@ -655,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
Loading
Loading