From 3bf815f6def5e4e3a75187b9e3dc391772006ef1 Mon Sep 17 00:00:00 2001 From: kennypm Date: Sat, 12 Feb 2022 01:52:51 -0500 Subject: [PATCH] fix callbacks --- src/modules/jack.cpp | 46 ++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index ab43c332..fd183c7e 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,30 +1,5 @@ #include "modules/jack.hpp" -//extern "C" { - - int bufSizeCallback(unsigned int size, void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->bufsize_ = size; - return size; - } - - int xrunCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->xruns_ += 1; - x->state_ = "xrun"; - return 0; - } - - void shutdownCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - pthread_cancel(x->jack_thread_); - x->client_ = NULL; - x->state_ = "disconnected"; - x->xruns_ = 0; - } - -//} - waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) : ALabel(config, "jack", id, "{load}%", 1) { xruns_ = 0; @@ -129,3 +104,24 @@ auto waybar::modules::JACK::update() -> void { // Call parent update ALabel::update(); } + +int bufSizeCallback(unsigned int size, void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->bufsize_ = size; + return size; +} + +int xrunCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->xruns_ += 1; + x->state_ = "xrun"; + return 0; +} + +void shutdownCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + pthread_cancel(x->jack_thread_); + x->client_ = NULL; + x->state_ = "disconnected"; + x->xruns_ = 0; +}