add samplerate callback since pipewire supports dynamic samplerate changes
parent
89a57f6722
commit
56d46e62c1
|
@ -15,7 +15,8 @@ class JACK : public ALabel {
|
|||
~JACK() = default;
|
||||
auto update() -> void;
|
||||
|
||||
int bufSize(unsigned int size);
|
||||
int bufSize(jack_nframes_t size);
|
||||
int sampleRate(jack_nframes_t rate);
|
||||
int xrun();
|
||||
void shutdown();
|
||||
|
||||
|
@ -35,6 +36,7 @@ class JACK : public ALabel {
|
|||
|
||||
} // namespace waybar::modules
|
||||
|
||||
int bufSizeCallback(unsigned int size, void *obj);
|
||||
int bufSizeCallback(jack_nframes_t size, void *obj);
|
||||
int sampleRateCallback(jack_nframes_t rate, void *obj);
|
||||
int xrunCallback(void *obj);
|
||||
void shutdownCallback(void *obj);
|
||||
|
|
|
@ -40,6 +40,7 @@ std::string JACK::JACKState() {
|
|||
|
||||
bufsize_ = jack_get_buffer_size(client_);
|
||||
samplerate_ = jack_get_sample_rate(client_);
|
||||
jack_set_sample_rate_callback(client_, sampleRateCallback, this);
|
||||
jack_set_buffer_size_callback(client_, bufSizeCallback, this);
|
||||
jack_set_xrun_callback(client_, xrunCallback, this);
|
||||
jack_on_shutdown(client_, shutdownCallback, this);
|
||||
|
@ -89,9 +90,14 @@ auto JACK::update() -> void {
|
|||
ALabel::update();
|
||||
}
|
||||
|
||||
int JACK::bufSize(unsigned int size) {
|
||||
int JACK::bufSize(jack_nframes_t size) {
|
||||
bufsize_ = size;
|
||||
return size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JACK::sampleRate(jack_nframes_t rate) {
|
||||
samplerate_ = rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JACK::xrun() {
|
||||
|
@ -107,10 +113,14 @@ void JACK::shutdown() {
|
|||
|
||||
} // namespace waybar::modules
|
||||
|
||||
int bufSizeCallback(unsigned int size, void *obj) {
|
||||
int bufSizeCallback(jack_nframes_t size, void *obj) {
|
||||
return static_cast<waybar::modules::JACK *>(obj)->bufSize(size);
|
||||
}
|
||||
|
||||
int sampleRateCallback(jack_nframes_t rate, void *obj) {
|
||||
return static_cast<waybar::modules::JACK *>(obj)->sampleRate(rate);
|
||||
}
|
||||
|
||||
int xrunCallback(void *obj) { return static_cast<waybar::modules::JACK *>(obj)->xrun(); }
|
||||
|
||||
void shutdownCallback(void *obj) { return static_cast<waybar::modules::JACK *>(obj)->shutdown(); }
|
||||
|
|
Loading…
Reference in New Issue