changed callbacks to use static_cast

This commit is contained in:
kennypm 2022-02-18 02:13:43 -05:00
parent bc8517fd08
commit c7b09eea11
2 changed files with 31 additions and 18 deletions

View File

@ -15,16 +15,20 @@ class JACK : public ALabel {
JACK(const std::string&, const Json::Value&);
~JACK() = default;
auto update() -> void;
jack_nframes_t bufsize_;
jack_client_t* client_;
unsigned int xruns_;
std::string state_;
pthread_t jack_thread_;
int bufSize(unsigned int size);
int xrun();
void shutdown();
private:
std::string JACKState();
jack_client_t* client_;
jack_nframes_t bufsize_;
jack_nframes_t samplerate_;
unsigned int xruns_;
std::string state_;
pthread_t jack_thread_;
util::SleeperThread thread_;
};

View File

@ -105,23 +105,32 @@ auto waybar::modules::JACK::update() -> void {
ALabel::update();
}
int bufSizeCallback(unsigned int size, void *obj) {
waybar::modules::JACK* x = (waybar::modules::JACK*)obj;
x->bufsize_ = size;
int waybar::modules::JACK::bufSize(unsigned int size) {
bufsize_ = size;
return size;
}
int xrunCallback(void *obj) {
waybar::modules::JACK* x = (waybar::modules::JACK*)obj;
x->xruns_ += 1;
x->state_ = "xrun";
int waybar::modules::JACK::xrun() {
xruns_ += 1;
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;
void waybar::modules::JACK::shutdown() {
pthread_cancel(jack_thread_);
client_ = NULL;
state_ = "disconnected";
xruns_ = 0;
}
int bufSizeCallback(unsigned int size, void *obj) {
return static_cast<waybar::modules::JACK*>(obj)->bufSize(size);
}
int xrunCallback(void *obj) {
return static_cast<waybar::modules::JACK*>(obj)->xrun();
}
void shutdownCallback(void *obj) {
return static_cast<waybar::modules::JACK*>(obj)->shutdown();
}