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
24 changes: 24 additions & 0 deletions include/clap/helpers/host.hh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ namespace clap { namespace helpers {
virtual bool implementsThreadPool() const noexcept { return false; }
virtual bool threadPoolRequestExec(uint32_t numTasks) noexcept { return false; }

// clap_host_preset_load
virtual bool implementsPresetLoad() const noexcept { return false; }
virtual void presetLoadLoaded(uint32_t locationKind,
const char *location,
const char *loadKey) noexcept {}
virtual void presetLoadOnError(uint32_t locationKind,
const char *location,
const char *loadKey,
int32_t osError,
const char *msg) noexcept {}

// clap_host_surround
virtual bool implementsSurround() const noexcept { return false; }
virtual void surroundChanged() noexcept {}
Expand Down Expand Up @@ -197,6 +208,18 @@ namespace clap { namespace helpers {
// clap_host_thread_pool
static bool clapThreadPoolRequestExec(const clap_host *host, uint32_t num_tasks) noexcept;

// clap_host_preset_load
static void clapPresetLoadLoaded(const clap_host *host,
uint32_t location_kind,
const char *location,
const char *load_key) noexcept;
static void clapPresetLoadOnError(const clap_host *host,
uint32_t location_kind,
const char *location,
const char *load_key,
int32_t os_error,
const char *msg) noexcept;

// clap_host_surround
static void clapSurroundChanged(const clap_host_t *host) noexcept;

Expand All @@ -210,6 +233,7 @@ namespace clap { namespace helpers {
static const clap_host_log _hostLog;
static const clap_host_params _hostParams;
static const clap_host_posix_fd_support _hostPosixFdSupport;
static const clap_host_preset_load _hostPresetLoad;
static const clap_host_remote_controls _hostRemoteControls;
static const clap_host_state _hostState;
static const clap_host_timer_support _hostTimerSupport;
Expand Down
35 changes: 35 additions & 0 deletions include/clap/helpers/host.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ namespace clap { namespace helpers {
clapPosixFdSupportUnregisterFd,
};

template <MisbehaviourHandler h, CheckingLevel l>
const clap_host_preset_load Host<h, l>::_hostPresetLoad = {
clapPresetLoadOnError,
clapPresetLoadLoaded,
};

template <MisbehaviourHandler h, CheckingLevel l>
const clap_host_remote_controls Host<h, l>::_hostRemoteControls = {
clapRemoteControlsChanged,
Expand Down Expand Up @@ -156,6 +162,10 @@ namespace clap { namespace helpers {
return &_hostParams;
if (!strcmp(extension_id, CLAP_EXT_POSIX_FD_SUPPORT) && self.implementsPosixFdSupport())
return &_hostPosixFdSupport;
if ((!strcmp(extension_id, CLAP_EXT_PRESET_LOAD) ||
!strcmp(extension_id, CLAP_EXT_PRESET_LOAD_COMPAT)) &&
self.implementsPresetLoad())
return &_hostPresetLoad;
if ((!strcmp(extension_id, CLAP_EXT_REMOTE_CONTROLS) ||
!strcmp(extension_id, CLAP_EXT_REMOTE_CONTROLS_COMPAT)) &&
self.implementsRemoteControls())
Expand Down Expand Up @@ -329,6 +339,31 @@ namespace clap { namespace helpers {
return self.posixFdSupportUnregisterFd(fd);
}

//-------------------------//
// clap_host_preset_load //
//-------------------------//
template <MisbehaviourHandler h, CheckingLevel l>
void Host<h, l>::clapPresetLoadLoaded(const clap_host *host,
uint32_t location_kind,
const char *location,
const char *load_key) noexcept {
auto &self = from(host);
self.ensureMainThread("preset_load.loaded");
self.presetLoadLoaded(location_kind, location, load_key);
}

template <MisbehaviourHandler h, CheckingLevel l>
void Host<h, l>::clapPresetLoadOnError(const clap_host *host,
uint32_t location_kind,
const char *location,
const char *load_key,
int32_t os_error,
const char *msg) noexcept {
auto &self = from(host);
self.ensureMainThread("preset_load.on_error");
self.presetLoadOnError(location_kind, location, load_key, os_error, msg);
}

//---------------------------//
// clap_host_remote_controls //
//---------------------------//
Expand Down
Loading