fix callbacks

This commit is contained in:
kennypm 2022-02-12 01:52:51 -05:00
parent 9439e4183c
commit bc8517fd08
1 changed files with 21 additions and 25 deletions

View File

@ -1,30 +1,5 @@
#include "modules/jack.hpp" #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) waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config)
: ALabel(config, "jack", id, "{load}%", 1) { : ALabel(config, "jack", id, "{load}%", 1) {
xruns_ = 0; xruns_ = 0;
@ -129,3 +104,24 @@ auto waybar::modules::JACK::update() -> void {
// Call parent update // Call parent update
ALabel::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;
}