Waybar/include/modules/jack.hpp

43 lines
1.0 KiB
C++
Raw Normal View History

#pragma once
#include <fmt/format.h>
#include <fstream>
#include <jack/jack.h>
2022-02-12 06:51:11 +00:00
#include <jack/thread.h>
#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
class JACK : public ALabel {
public:
JACK(const std::string&, const Json::Value&);
~JACK() = default;
auto update() -> void;
2022-02-18 07:13:43 +00:00
int bufSize(jack_nframes_t size);
int sampleRate(jack_nframes_t rate);
2022-02-18 07:13:43 +00:00
int xrun();
void shutdown();
private:
std::string JACKState();
2022-02-18 07:13:43 +00:00
jack_client_t* client_;
jack_nframes_t bufsize_;
jack_nframes_t samplerate_;
2022-02-18 07:13:43 +00:00
unsigned int xruns_;
2022-08-07 19:29:42 +00:00
float load_;
bool running_;
std::mutex mutex_;
2022-02-18 07:13:43 +00:00
std::string state_;
util::SleeperThread thread_;
};
} // namespace waybar::modules
2022-02-12 06:51:11 +00:00
int bufSizeCallback(jack_nframes_t size, void *obj);
int sampleRateCallback(jack_nframes_t rate, void *obj);
2022-02-12 06:51:11 +00:00
int xrunCallback(void *obj);
void shutdownCallback(void *obj);