Comprehensive refactor of the cava module backend and frontends. Style & naming - Rename Cava -> CavaRaw; snake_case methods -> lowerCamelCase - Replace NULL with nullptr; replace C-style casts with static_cast - Add explicit standard-library includes (<memory>, <string>, <chrono>) - Fix missing trailing underscores on member variables Architecture - Remove Gtk::GLArea multiple inheritance in CavaGLSL (composition) - Return std::unique_ptr from factory; add doAction() to GLSL variant - Encapsulate thread timing arithmetic in AdaptiveDelay struct Thread safety & correctness - Replace raw sigc::signal with SafeSignal for cross-thread marshalling - Fix data race between loadConfig() and out_thread_ (recursive_mutex) - Fix audio_raw shallow-copy use-after-free via deep-copy AudioRaw payload - Make loadConfig() exception-safe with CavaConfigGuard RAII - Fix blocking read_thread_ race on shutdown (condition_variable + timeout join) - Fix isSilent() data race (acquire pthread mutex) - Eliminate doUpdate() recursion (iteration instead) - Guard audio_raw_clean() against uninitialized state - Fix format-icons underflow and cava_config buffer overflow - Store config by value to prevent dangling references on reload - Cache frontend config and refresh on runtime changes - Fix signed-char icon lookup bug on x86 - Prevent Json::Value mutation bloat via const-ref lookups - Broaden exception catches in worker threads (std::exception) Resource management & GL robustness - Fix OpenGL resource leaks (persist VBO/IBO/VAO; explicit destructor cleanup) - Fix shader error handling crashes (valid infoLog allocation) - Cache uniform locations instead of querying per frame - Fix gradient color uninitialized stack memory (zero-init + clamped count) - Fix shader time uniform integer division bug (float arithmetic) - Add explicit VAO bind in onRender() - Handle runtime surface config changes independently of shader changes - Clamp negative gradient_count before GL upload Follow-up - Singleton API split (inst() + configure()) intentionally deferred to a dedicated PR because it changes the public constructor contract.
39 lines
869 B
C++
39 lines
869 B
C++
#pragma once
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
#include <sigc++/connection.h>
|
|
|
|
#include "ALabel.hpp"
|
|
#include "cava_backend.hpp"
|
|
|
|
namespace waybar::modules::cava {
|
|
|
|
class CavaRaw final : public ALabel {
|
|
public:
|
|
CavaRaw(const std::string&, const Json::Value&);
|
|
~CavaRaw();
|
|
auto doAction(const std::string& name) -> void override;
|
|
|
|
private:
|
|
using Action = void (CavaRaw::*)();
|
|
|
|
std::shared_ptr<CavaBackend> backend_;
|
|
// Text to display
|
|
Glib::ustring label_text_;
|
|
bool silence_{false};
|
|
bool hide_on_silence_{false};
|
|
std::string format_silent_;
|
|
// Cava method
|
|
void pauseResume();
|
|
auto onUpdate(const std::string& input) -> void;
|
|
auto onSilence() -> void;
|
|
// ModuleActionMap
|
|
static const std::map<std::string, Action> actionMap_;
|
|
|
|
sigc::connection update_conn_;
|
|
sigc::connection silence_conn_;
|
|
};
|
|
} // namespace waybar::modules::cava
|