mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix callbacks
This commit is contained in:
parent
f6ee90e5ba
commit
c1cda1553a
@ -3,6 +3,7 @@
|
||||
#include <fmt/format.h>
|
||||
#include <fstream>
|
||||
#include <jack/jack.h>
|
||||
#include <jack/thread.h>
|
||||
#include <proc/readproc.h>
|
||||
#include "ALabel.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
@ -18,6 +19,7 @@ class JACK : public ALabel {
|
||||
jack_client_t* client_;
|
||||
unsigned int xruns_;
|
||||
std::string state_;
|
||||
pthread_t jack_thread_;
|
||||
|
||||
private:
|
||||
std::string JACKState();
|
||||
@ -27,3 +29,7 @@ class JACK : public ALabel {
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
int bufSizeCallback(unsigned int size, void *obj);
|
||||
int xrunCallback(void *obj);
|
||||
void shutdownCallback(void *obj);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "modules/jack.hpp"
|
||||
|
||||
extern "C" {
|
||||
//extern "C" {
|
||||
|
||||
int bufSizeCallback(unsigned int size, void *obj) {
|
||||
waybar::modules::JACK* x = (waybar::modules::JACK*)obj;
|
||||
@ -17,12 +17,13 @@ extern "C" {
|
||||
|
||||
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) {
|
||||
@ -57,8 +58,11 @@ std::string waybar::modules::JACK::JACKState() {
|
||||
return "disconnected";
|
||||
|
||||
client_ = jack_client_open("waybar", JackNoStartServer, NULL);
|
||||
|
||||
if (client_) {
|
||||
jack_thread_ = jack_client_thread_id(client_);
|
||||
if(config_["realtime"].isBool() && !config_["realtime"].asBool())
|
||||
jack_drop_real_time_scheduling(jack_thread_);
|
||||
|
||||
bufsize_ = jack_get_buffer_size(client_);
|
||||
samplerate_ = jack_get_sample_rate(client_);
|
||||
jack_set_buffer_size_callback(client_, bufSizeCallback, this);
|
||||
|
Loading…
Reference in New Issue
Block a user