clap

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

commit f01ef875c33aeff10bc23e86666c14f2638a742b
parent 60ab9397d04a22a4a42a40a1d4e099d3267908d6
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Fri, 27 Aug 2021 16:49:01 +0200

More work on the timer

Diffstat:
Mexamples/plugins/core-plugin.cc | 5+++++
Mexamples/plugins/core-plugin.hh | 1+
Mexamples/plugins/remote-gui.cc | 3+++
Mexamples/plugins/remote-gui.hh | 3+++
4 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/examples/plugins/core-plugin.cc b/examples/plugins/core-plugin.cc @@ -137,6 +137,11 @@ namespace clap { remoteGui_->onFd(flags); } + void CorePlugin::eventLoopOnTimer(clap_id timerId) noexcept { + if (remoteGui_ && timerId == remoteGui_->timerId()) + remoteGui_->onTimer(); + } + bool CorePlugin::guiX11Attach(const char *displayName, unsigned long window) noexcept { if (remoteGui_) return remoteGui_->attachX11(displayName, window); diff --git a/examples/plugins/core-plugin.hh b/examples/plugins/core-plugin.hh @@ -143,6 +143,7 @@ namespace clap { //------------------------// bool implementsEventLoop() const noexcept override { return true; } void eventLoopOnFd(clap_fd fd, uint32_t flags) noexcept override; + void eventLoopOnTimer(clap_id timerId) noexcept override; protected: friend class RemoteGui; diff --git a/examples/plugins/remote-gui.cc b/examples/plugins/remote-gui.cc @@ -63,6 +63,8 @@ namespace clap { ::close(sockets[1]); } + timerId_ = CLAP_INVALID_ID; + plugin_.hostEventLoop_->register_timer(plugin_.host_, 1000 / 60, &timerId_); plugin_.hostEventLoop_->register_fd(plugin_.host_, sockets[0], CLAP_FD_READ | CLAP_FD_ERROR); channel_.reset(new RemoteChannel( [this](const RemoteChannel::Message &msg) { onMessage(msg); }, *this, sockets[0], true)); @@ -79,6 +81,7 @@ namespace clap { void RemoteGui::removeFd() { plugin_.hostEventLoop_->unregister_fd(plugin_.host_, channel_->fd()); + plugin_.hostEventLoop_->unregister_timer(plugin_.host_, timerId_); } clap_fd RemoteGui::fd() const { return channel_ ? channel_->fd() : -1; } diff --git a/examples/plugins/remote-gui.hh b/examples/plugins/remote-gui.hh @@ -38,6 +38,7 @@ namespace clap { clap_fd fd() const; void onFd(clap_fd_flags flags); + clap_id timerId() const noexcept { return timerId_; } void onTimer(); private: @@ -46,6 +47,8 @@ namespace clap { std::unique_ptr<RemoteChannel> channel_; + clap_id timerId_ = CLAP_INVALID_ID; + #ifdef __unix__ pid_t child_ = -1; #else