Factory. cava_frontend
This commit is contained in:
parent
3773021546
commit
e03119fe94
|
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef HAVE_LIBCAVA
|
||||
#include "cavaRaw.hpp"
|
||||
#include "cava_backend.hpp"
|
||||
#ifdef HAVE_LIBCAVAGLSL
|
||||
#include "cavaGLSL.hpp"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace waybar::modules::cava {
|
||||
AModule* getModule(const std::string& id, const Json::Value& config) {
|
||||
#ifdef HAVE_LIBCAVA
|
||||
const std::shared_ptr<CavaBackend> backend_{waybar::modules::cava::CavaBackend::inst(config)};
|
||||
switch (backend_->getPrm()->output) {
|
||||
case ::cava::output_method::OUTPUT_RAW:
|
||||
return new waybar::modules::cava::Cava(id, config);
|
||||
break;
|
||||
#ifdef HAVE_LIBCAVAGLSL
|
||||
case ::cava::output_method::OUTPUT_SDL_GLSL:
|
||||
return new waybar::modules::cava::CavaGLSL(id, config);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
throw std::runtime_error("Unknown module");
|
||||
};
|
||||
} // namespace waybar::modules::cava
|
||||
|
|
@ -507,7 +507,7 @@ eproxy = dependency('epoxy', required: false)
|
|||
|
||||
if cava.found()
|
||||
add_project_arguments('-DHAVE_LIBCAVA', language: 'cpp')
|
||||
src_files += files('src/modules/cava/cava.cpp',
|
||||
src_files += files('src/modules/cava/cavaRaw.cpp',
|
||||
'src/modules/cava/cava_backend.cpp')
|
||||
man_files += files('man/waybar-cava.5.scd')
|
||||
|
||||
|
|
|
|||
|
|
@ -108,18 +108,13 @@
|
|||
#ifdef HAVE_LIBWIREPLUMBER
|
||||
#include "modules/wireplumber.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_LIBCAVA
|
||||
#include "modules/cava/cava.hpp"
|
||||
#ifdef HAVE_LIBCAVAGLSL
|
||||
#include "modules/cava/cavaGLSL.hpp"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_SYSTEMD_MONITOR
|
||||
#include "modules/systemd_failed_units.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_LIBGPS
|
||||
#include "modules/gps.hpp"
|
||||
#endif
|
||||
#include "modules/cava/cava_frontend.hpp"
|
||||
#include "modules/cffi.hpp"
|
||||
#include "modules/custom.hpp"
|
||||
#include "modules/image.hpp"
|
||||
|
|
@ -344,15 +339,9 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
|||
return new waybar::modules::Wireplumber(id, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_LIBCAVA
|
||||
if (ref == "cava") {
|
||||
return new waybar::modules::cava::Cava(id, config_[name]);
|
||||
#ifdef HAVE_LIBCAVAGLSL
|
||||
} else if (ref == "cavaGLSL") {
|
||||
return new waybar::modules::cava::CavaGLSL(id, config_[name]);
|
||||
#endif
|
||||
return waybar::modules::cava::getModule(id, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_SYSTEMD_MONITOR
|
||||
if (ref == "systemd-failed-units") {
|
||||
return new waybar::modules::SystemdFailedUnits(id, config_[name]);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "modules/cava/cava.hpp"
|
||||
#include "modules/cava/cavaRaw.hpp"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
|
|
@ -181,11 +181,16 @@ void waybar::modules::cava::CavaBackend::loadConfig() {
|
|||
|
||||
// Override cava parameters by the user config
|
||||
prm_.inAtty = 0;
|
||||
prm_.output = ::cava::output_method::OUTPUT_RAW;
|
||||
auto const output{prm_.output};
|
||||
// prm_.output = ::cava::output_method::OUTPUT_RAW;
|
||||
if (config_["data_format"].isString()) {
|
||||
if (prm_.data_format) free(prm_.data_format);
|
||||
prm_.data_format = strdup("ascii");
|
||||
prm_.data_format = strdup(config_["data_format"].asString().c_str());
|
||||
}
|
||||
if (config_["raw_target"].isString()) {
|
||||
if (prm_.raw_target) free(prm_.raw_target);
|
||||
prm_.raw_target = strdup("/dev/stdout");
|
||||
prm_.raw_target = strdup(config_["raw_target"].asString().c_str());
|
||||
}
|
||||
prm_.ascii_range = config_["format-icons"].size() - 1;
|
||||
|
||||
if (config_["bar_spacing"].isInt()) prm_.bar_spacing = config_["bar_spacing"].asInt();
|
||||
|
|
@ -251,11 +256,15 @@ void waybar::modules::cava::CavaBackend::loadConfig() {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
prm_.output = ::cava::output_method::OUTPUT_RAW;
|
||||
|
||||
// Make cava parameters configuration
|
||||
// Init cava plan, audio_raw structure
|
||||
audio_raw_init(&audio_data_, &audio_raw_, &prm_, &plan_);
|
||||
if (!plan_) spdlog::error("cava backend plan is not provided");
|
||||
audio_raw_.previous_frame[0] = -1; // For first Update() call need to rePaint text message
|
||||
|
||||
prm_.output = output;
|
||||
}
|
||||
|
||||
const struct ::cava::config_params* waybar::modules::cava::CavaBackend::getPrm() { return &prm_; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue