clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit 3b0e211395938637fa647414914d5ec2cedf7093
parent 960ac8ea6bef86d773956c733ca411bd7636dce3
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Fri, 16 Jul 2021 17:41:04 +0200

More work on the host

Diffstat:
Mexamples/host/plugin-host.cc | 27++++++++++-----------------
Mexamples/host/plugin-host.hh | 6+++---
2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/examples/host/plugin-host.cc b/examples/host/plugin-host.cc @@ -137,8 +137,7 @@ bool PluginHost::load(const QString &path, int pluginIndex) { if (!clap_version_is_compatible(desc->clap_version)) { qWarning() << "incompatible clap version: " << desc->clap_version.major << "." - << desc->clap_version.minor << "." - << desc->clap_version.revision; + << desc->clap_version.minor << "." << desc->clap_version.revision; return false; } @@ -205,7 +204,7 @@ bool PluginHost::canActivate() const { return false; if (isPluginActive()) return false; - if (scheduleDeactivateForParameterScan_) + if (scheduleRestart_) return false; return true; } @@ -496,7 +495,7 @@ void PluginHost::eventLoopSetFdNotifierFlags(clap_fd fd, uint32_t flags) { it->second->err->setEnabled(false); } -bool PluginHost::clapGuiResize(const clap_host *host, int32_t width, int32_t height) { +bool PluginHost::clapGuiResize(const clap_host *host, uint32_t width, uint32_t height) { checkForMainThread(); PluginHost *h = static_cast<PluginHost *>(host->host_data); @@ -629,14 +628,15 @@ void PluginHost::process() { for (auto &ev : evOut_) { switch (ev.type) { case CLAP_EVENT_PARAM_VALUE: - engineToAppQueue_.set(ev.param_value.param_id, ev.param_value.cookie, ev.param_value.value); + engineToAppQueue_.set( + ev.param_value.param_id, ev.param_value.cookie, ev.param_value.value); break; } } evOut_.clear(); evIn_.clear(); - if (scheduleDeactivateForParameterScan_) { + if (scheduleRestart_) { plugin_->stop_processing(plugin_); setPluginState(ActiveAndReadyToDeactivate); } @@ -713,10 +713,10 @@ void PluginHost::clapParamsRescan(const clap_host *host, uint32_t flags) { checkForMainThread(); auto h = fromHost(host); - // 1. if the plugin is activated, check if we need to deactivate it + // 1. it is forbidden to use CLAP_PARAM_RESCAN_ALL if the plugin is active if (h->isPluginActive() && (flags & CLAP_PARAM_RESCAN_ALL)) { - h->scheduleDeactivateForParameterScan_ = true; - h->scheduleParamsRescanFlags_ |= flags; + throw std::logic_error( + "clap_host_params.recan(CLAP_PARAM_RESCAN_ALL) was called while the plugin is active!"); return; } @@ -826,15 +826,8 @@ void PluginHost::clapParamsRescan(const clap_host *host, uint32_t flags) { } } - if (flags & CLAP_PARAM_RESCAN_ALL) { - h->scheduleDeactivateForParameterScan_ = false; - h->scheduleParamsRescanFlags_ = 0; - - if (h->canActivate()) - h->plugin_->activate(h->plugin_, h->engine_.sampleRate()); - + if (flags & CLAP_PARAM_RESCAN_ALL) h->paramsChanged(); - } } double PluginHost::getParamValue(const clap_param_info &info) { diff --git a/examples/host/plugin-host.hh b/examples/host/plugin-host.hh @@ -115,7 +115,7 @@ private: static const void *clapExtension(const clap_host *host, const char *extension); /* clap host gui callbacks */ - static bool clapGuiResize(const clap_host *host, int32_t width, int32_t height); + static bool clapGuiResize(const clap_host *host, uint32_t width, uint32_t height); static void clapStateMarkDirty(const clap_host *host); @@ -214,6 +214,6 @@ private: PluginState state_ = Inactive; bool stateIsDirty_ = false; - bool scheduleDeactivateForParameterScan_ = false; - uint32_t scheduleParamsRescanFlags_ = 0; + + bool scheduleRestart_ = false; };