Skip to content

Commit a38de50

Browse files
committed
Fix: email typo.
2 parents 94fdb65 + 84ec25b commit a38de50

File tree

8 files changed

+57
-40
lines changed

8 files changed

+57
-40
lines changed

include/modules/cava/cava_backend.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ class CavaBackend final {
4343
util::SleeperThread thread_;
4444
util::SleeperThread read_thread_;
4545
// Cava API to read audio source
46-
::cava::ptr input_source_;
46+
::cava::ptr input_source_{NULL};
4747

4848
struct ::cava::error_s error_{}; // cava errors
4949
struct ::cava::config_params prm_{}; // cava parameters
5050
struct ::cava::audio_raw audio_raw_{}; // cava handled raw audio data(is based on audio_data)
5151
struct ::cava::audio_data audio_data_{}; // cava audio data
52-
struct ::cava::cava_plan* plan_; //{new cava_plan{}};
52+
struct ::cava::cava_plan* plan_{NULL}; //{new cava_plan{}};
5353

5454
std::chrono::seconds fetch_input_delay_{4};
5555
// Delay to handle audio source

man/waybar-pulseaudio-slider.5.scd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ The slider is a component with multiple CSS Nodes, of which the following are ex
7777
min-height: 80px;
7878
min-width: 10px;
7979
border-radius: 5px;
80-
background-color: black;
80+
background: black;
8181
}
8282
8383
#pulseaudio-slider highlight {
8484
min-width: 10px;
8585
border-radius: 5px;
86-
background-color: green;
86+
background: green;
8787
}
8888
```

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ else
498498
endif
499499

500500
cava = dependency('cava',
501-
version : '>=0.10.4',
501+
version : '>=0.10.6',
502502
required: get_option('cava'),
503503
fallback : ['cava', 'cava_dep'],
504504
not_found_message: 'cava is not found. Building waybar without cava')

src/client.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,24 @@ const std::string waybar::Client::getStyle(const std::string &style,
183183
};
184184

185185
auto waybar::Client::setupCss(const std::string &css_file) -> void {
186-
css_provider_ = Gtk::CssProvider::create();
187-
style_context_ = Gtk::StyleContext::create();
186+
auto screen = Gdk::Screen::get_default();
187+
if (!screen) {
188+
throw std::runtime_error("No default screen");
189+
}
190+
191+
if (css_provider_) {
192+
Gtk::StyleContext::remove_provider_for_screen(screen, css_provider_);
193+
css_provider_.reset();
194+
}
188195

189-
// Load our css file, wherever that may be hiding
196+
css_provider_ = Gtk::CssProvider::create();
190197
if (!css_provider_->load_from_path(css_file)) {
198+
css_provider_.reset();
191199
throw std::runtime_error("Can't open style file");
192200
}
193-
// there's always only one screen
194-
style_context_->add_provider_for_screen(Gdk::Screen::get_default(), css_provider_,
195-
GTK_STYLE_PROVIDER_PRIORITY_USER);
201+
202+
Gtk::StyleContext::add_provider_for_screen(screen, css_provider_,
203+
GTK_STYLE_PROVIDER_PRIORITY_USER);
196204
}
197205

198206
void waybar::Client::bindInterfaces() {

src/modules/cava/cava_backend.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ waybar::modules::cava::CavaBackend::CavaBackend(const Json::Value& config) {
1818
// Load cava config
1919
error_.length = 0;
2020

21-
if (!load_config(cfgPath, &prm_, false, &error_)) {
21+
if (!load_config(cfgPath, &prm_, false, &error_, 0)) {
2222
spdlog::error("cava backend. Error loading config. {0}", error_.message);
2323
exit(EXIT_FAILURE);
2424
}
2525

2626
// Override cava parameters by the user config
2727
prm_.inAtty = 0;
2828
prm_.output = ::cava::output_method::OUTPUT_RAW;
29-
strcpy(prm_.data_format, "ascii");
30-
strcpy(prm_.raw_target, "/dev/stdout");
29+
if (prm_.data_format) free(prm_.data_format);
30+
prm_.data_format = strdup("ascii");
31+
if (prm_.raw_target) free(prm_.raw_target);
32+
prm_.raw_target = strdup("/dev/stdout");
3133
prm_.ascii_range = config["format-icons"].size() - 1;
3234

3335
prm_.bar_width = 2;
@@ -54,7 +56,10 @@ waybar::modules::cava::CavaBackend::CavaBackend(const Json::Value& config) {
5456
if (config["sleep_timer"].isInt()) prm_.sleep_timer = config["sleep_timer"].asInt();
5557
if (config["method"].isString())
5658
prm_.input = ::cava::input_method_by_name(config["method"].asString().c_str());
57-
if (config["source"].isString()) prm_.audio_source = config["source"].asString().data();
59+
if (config["source"].isString()) {
60+
if (prm_.audio_source) free(prm_.audio_source);
61+
prm_.audio_source = config["source"].asString().data();
62+
}
5863
if (config["sample_rate"].isNumeric()) prm_.samplerate = config["sample_rate"].asLargestInt();
5964
if (config["sample_bits"].isInt()) prm_.samplebits = config["sample_bits"].asInt();
6065
if (config["stereo"].isBool()) prm_.stereo = config["stereo"].asBool();
@@ -67,25 +72,14 @@ waybar::modules::cava::CavaBackend::CavaBackend(const Json::Value& config) {
6772
if (config["input_delay"].isInt())
6873
fetch_input_delay_ = std::chrono::seconds(config["input_delay"].asInt());
6974

70-
// Make cava parameters configuration
71-
plan_ = new ::cava::cava_plan{};
72-
7375
audio_raw_.height = prm_.ascii_range;
7476
audio_data_.format = -1;
75-
audio_data_.source = new char[1 + strlen(prm_.audio_source)];
76-
audio_data_.source[0] = '\0';
77-
strcpy(audio_data_.source, prm_.audio_source);
78-
7977
audio_data_.rate = 0;
8078
audio_data_.samples_counter = 0;
8179
audio_data_.channels = 2;
8280
audio_data_.IEEE_FLOAT = 0;
83-
8481
audio_data_.input_buffer_size = BUFFER_SIZE * audio_data_.channels;
8582
audio_data_.cava_buffer_size = audio_data_.input_buffer_size * 8;
86-
87-
audio_data_.cava_in = new double[audio_data_.cava_buffer_size]{0.0};
88-
8983
audio_data_.terminate = 0;
9084
audio_data_.suspendFlag = false;
9185
input_source_ = get_input(&audio_data_, &prm_);
@@ -95,8 +89,9 @@ waybar::modules::cava::CavaBackend::CavaBackend(const Json::Value& config) {
9589
exit(EXIT_FAILURE);
9690
}
9791

92+
// Make cava parameters configuration
9893
// Init cava plan, audio_raw structure
99-
audio_raw_init(&audio_data_, &audio_raw_, &prm_, plan_);
94+
audio_raw_init(&audio_data_, &audio_raw_, &prm_, &plan_);
10095
if (!plan_) spdlog::error("cava backend plan is not provided");
10196
audio_raw_.previous_frame[0] = -1; // For first Update() call need to rePaint text message
10297
// Read audio source trough cava API. Cava orginizes this process via infinity loop
@@ -118,8 +113,16 @@ waybar::modules::cava::CavaBackend::CavaBackend(const Json::Value& config) {
118113
waybar::modules::cava::CavaBackend::~CavaBackend() {
119114
thread_.stop();
120115
read_thread_.stop();
116+
cava_destroy(plan_);
121117
delete plan_;
122118
plan_ = nullptr;
119+
audio_raw_clean(&audio_raw_);
120+
pthread_mutex_lock(&audio_data_.lock);
121+
audio_data_.terminate = 1;
122+
pthread_mutex_unlock(&audio_data_.lock);
123+
config_clean(&prm_);
124+
free(audio_data_.source);
125+
free(audio_data_.cava_in);
123126
}
124127

125128
static void upThreadDelay(std::chrono::milliseconds& delay, std::chrono::seconds& delta) {

src/util/backlight_backend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ BacklightBackend::BacklightBackend(std::chrono::milliseconds interval,
201201
const auto &event = events[i];
202202
check_eq(event.data.fd, udev_fd, "unexpected udev fd");
203203
std::unique_ptr<udev_device, UdevDeviceDeleter> dev{udev_monitor_receive_device(mon.get())};
204-
check_nn(dev.get(), "epoll dev was null");
204+
if (!dev) {
205+
continue;
206+
}
205207
upsert_device(devices, dev.get());
206208
}
207209

subprojects/cava.wrap

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
[wrap-file]
2-
directory = cava-0.10.4
3-
source_url = https://github.com/LukashonakV/cava/archive/0.10.4.tar.gz
4-
source_filename = cava-0.10.4.tar.gz
5-
source_hash =7bc1c1f9535f2bcc5cd2ae8a2434a2e3a05f5670b1c96316df304137ffc65756
1+
[wrap-git]
2+
url = https://github.com/LukashonakV/cava.git
3+
revision = 23efcced43b5a395747b18a2e5f2171fc0925d18
4+
depth = 1
5+
6+
#directory = cava-0.10.6
7+
#source_url = https://github.com/LukashonakV/cava/archive/0.10.6.tar.gz
8+
#source_filename = cava-0.10.6.tar.gz
9+
#source_hash = e715c4c6a625b8dc063e57e8e81c80e4d1015ec1b98db69a283b2c6770f839f4
610
[provide]
711
cava = cava_dep

subprojects/fmt.wrap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[wrap-file]
2-
directory = fmt-11.0.2
3-
source_url = https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz
4-
source_filename = fmt-11.0.2.tar.gz
2+
directory = fmt-12.0.0
3+
source_url = https://github.com/fmtlib/fmt/archive/12.0.0.tar.gz
4+
source_filename = fmt-12.0.0.tar.gz
55
source_hash = 6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f
6-
patch_filename = fmt_11.0.2-1_patch.zip
7-
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_11.0.2-1/get_patch
6+
patch_filename = fmt_12.0.0-1_patch.zip
7+
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_12.0.0-1/get_patch
88
patch_hash = 90c9e3b8e8f29713d40ca949f6f93ad115d78d7fb921064112bc6179e6427c5e
9-
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_11.0.2-1/fmt-11.0.2.tar.gz
10-
wrapdb_version = 11.0.2-1
9+
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_12.0.0-1/fmt-12.0.0.tar.gz
10+
wrapdb_version = 12.0.0-1
1111

1212
[provide]
1313
fmt = fmt_dep

0 commit comments

Comments
 (0)