From e9a66d68b7fdbe605ecc98eef2840c624d1ab242 Mon Sep 17 00:00:00 2001 From: Viktar Lukashonak Date: Tue, 31 Oct 2023 20:27:00 +0300 Subject: [PATCH 1/2] Fix debug mode. cava issue Signed-off-by: Viktar Lukashonak --- include/modules/cava.hpp | 14 ++++++++------ meson.build | 2 +- src/modules/cava.cpp | 16 ++++++++-------- subprojects/cava.wrap | 8 ++++---- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/modules/cava.hpp b/include/modules/cava.hpp index d4da2b77..00c23123 100644 --- a/include/modules/cava.hpp +++ b/include/modules/cava.hpp @@ -3,9 +3,11 @@ #include "ALabel.hpp" #include "util/sleeper_thread.hpp" +namespace cava { extern "C" { #include } +} namespace waybar::modules { using namespace std::literals::chrono_literals; @@ -21,13 +23,13 @@ class Cava final : public ALabel { util::SleeperThread thread_; util::SleeperThread thread_fetch_input_; - struct error_s error_ {}; // cava errors - struct config_params prm_ {}; // cava parameters - struct audio_raw audio_raw_ {}; // cava handled raw audio data(is based on audio_data) - struct audio_data audio_data_ {}; // cava audio data - struct cava_plan* plan_; //{new cava_plan{}}; + struct cava::error_s error_ {}; // cava errors + struct cava::config_params prm_ {}; // cava parameters + struct cava::audio_raw audio_raw_ {}; // cava handled raw audio data(is based on audio_data) + struct cava::audio_data audio_data_ {}; // cava audio data + struct cava::cava_plan* plan_; //{new cava_plan{}}; // Cava API to read audio source - ptr input_source_; + cava::ptr input_source_; // Delay to handle audio source std::chrono::milliseconds frame_time_milsec_{1s}; // Text to display diff --git a/meson.build b/meson.build index e71807ec..d32ab1cc 100644 --- a/meson.build +++ b/meson.build @@ -346,7 +346,7 @@ if get_option('experimental') endif cava = dependency('cava', - version : '>=0.8.5', + version : '>=0.9.1', required: get_option('cava'), fallback : ['cava', 'cava_dep'], not_found_message: 'cava is not found. Building waybar without cava') diff --git a/src/modules/cava.cpp b/src/modules/cava.cpp index be9bef4e..6111258a 100644 --- a/src/modules/cava.cpp +++ b/src/modules/cava.cpp @@ -25,7 +25,7 @@ waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config) // Override cava parameters by the user config prm_.inAtty = 0; - prm_.output = output_method::OUTPUT_RAW; + prm_.output = cava::output_method::OUTPUT_RAW; strcpy(prm_.data_format, "ascii"); strcpy(prm_.raw_target, "/dev/stdout"); prm_.ascii_range = config_["format-icons"].size() - 1; @@ -34,9 +34,9 @@ waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config) prm_.bar_spacing = 0; prm_.bar_height = 32; prm_.bar_width = 1; - prm_.orientation = ORIENT_TOP; - prm_.xaxis = xaxis_scale::NONE; - prm_.mono_opt = AVERAGE; + prm_.orientation = cava::ORIENT_TOP; + prm_.xaxis = cava::xaxis_scale::NONE; + prm_.mono_opt = cava::AVERAGE; prm_.autobars = 0; prm_.gravity = 0; prm_.integral = 1; @@ -51,7 +51,7 @@ waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config) prm_.upper_cut_off = config_["higher_cutoff_freq"].asLargestInt(); if (config_["sleep_timer"].isInt()) prm_.sleep_timer = config_["sleep_timer"].asInt(); if (config_["method"].isString()) - prm_.input = input_method_by_name(config_["method"].asString().c_str()); + prm_.input = cava::input_method_by_name(config_["method"].asString().c_str()); if (config_["source"].isString()) prm_.audio_source = config_["source"].asString().data(); if (config_["sample_rate"].isNumeric()) prm_.fifoSample = config_["sample_rate"].asLargestInt(); if (config_["sample_bits"].isInt()) prm_.fifoSampleBits = config_["sample_bits"].asInt(); @@ -65,7 +65,7 @@ waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config) if (config_["input_delay"].isInt()) fetch_input_delay_ = std::chrono::seconds(config_["input_delay"].asInt()); // Make cava parameters configuration - plan_ = new cava_plan{}; + plan_ = new cava::cava_plan{}; audio_raw_.height = prm_.ascii_range; audio_data_.format = -1; @@ -155,12 +155,12 @@ auto waybar::modules::Cava::update() -> void { downThreadDelay(frame_time_milsec_, suspend_silence_delay_); // Process: execute cava pthread_mutex_lock(&audio_data_.lock); - cava_execute(audio_data_.cava_in, audio_data_.samples_counter, audio_raw_.cava_out, plan_); + cava::cava_execute(audio_data_.cava_in, audio_data_.samples_counter, audio_raw_.cava_out, plan_); if (audio_data_.samples_counter > 0) audio_data_.samples_counter = 0; pthread_mutex_unlock(&audio_data_.lock); // Do transformation under raw data - audio_raw_fetch(&audio_raw_, &prm_, &rePaint_); + audio_raw_fetch(&audio_raw_, &prm_, &rePaint_, plan_); if (rePaint_ == 1) { text_.clear(); diff --git a/subprojects/cava.wrap b/subprojects/cava.wrap index f6973c83..73fc9512 100644 --- a/subprojects/cava.wrap +++ b/subprojects/cava.wrap @@ -1,7 +1,7 @@ [wrap-file] -directory = cava-0.8.5 -source_url = https://github.com/LukashonakV/cava/archive/0.8.5.tar.gz -source_filename = cava-0.8.5.tar.gz -source_hash = 9ce3df7d374dc83ed0704fe3caef5e00600ce061d85608aad4142d2c59aa4647 +directory = cava-0.9.1 +source_url = https://github.com/LukashonakV/cava/archive/0.9.1.tar.gz +source_filename = cava-0.9.1.tar.gz +source_hash = 4df540b7f4892f72e48772929a15bc9ad61e2bce7a084be2df01c72ca5c02333 [provide] cava = cava_dep From b9b89cce7efe18d4aa86b11d03e3d4f53a7f8618 Mon Sep 17 00:00:00 2001 From: Viktar Lukashonak Date: Tue, 31 Oct 2023 20:47:56 +0300 Subject: [PATCH 2/2] Happy linter Signed-off-by: Viktar Lukashonak --- src/modules/cava.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/cava.cpp b/src/modules/cava.cpp index 6111258a..4b2ca785 100644 --- a/src/modules/cava.cpp +++ b/src/modules/cava.cpp @@ -155,7 +155,8 @@ auto waybar::modules::Cava::update() -> void { downThreadDelay(frame_time_milsec_, suspend_silence_delay_); // Process: execute cava pthread_mutex_lock(&audio_data_.lock); - cava::cava_execute(audio_data_.cava_in, audio_data_.samples_counter, audio_raw_.cava_out, plan_); + cava::cava_execute(audio_data_.cava_in, audio_data_.samples_counter, audio_raw_.cava_out, + plan_); if (audio_data_.samples_counter > 0) audio_data_.samples_counter = 0; pthread_mutex_unlock(&audio_data_.lock);