- Adds microphone support etc to the wireplumber module. The existing module hardcodes the selected node type to "Audio/Sink". This feature allows the user to override this via `"node-type": "Audio/Source"`. - Unlike the pulseaudio module, this change does not try to see the module manage both input and output. The same effect can be achieved by running two instances of the wireplumber module. This approach: - Works around some of the complexity overhead that seem to have caused similar PRs to stall. - Using separate module instances also allows both the microphone and speaker levels to be controlled with a scroll wheel. This is something a unified module like pulseaudio struggles with. - Similarly, separate instances allows the source volume level to be exposed as the state. Ie- the linear-gradient css patterns can be applied to both input and output.
51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <fmt/format.h>
|
|
#include <wp/wp.h>
|
|
|
|
#include <algorithm>
|
|
#include <array>
|
|
|
|
#include "ALabel.hpp"
|
|
|
|
namespace waybar::modules {
|
|
|
|
class Wireplumber : public ALabel {
|
|
public:
|
|
Wireplumber(const std::string&, const Json::Value&);
|
|
virtual ~Wireplumber();
|
|
auto update() -> void override;
|
|
|
|
private:
|
|
void asyncLoadRequiredApiModules();
|
|
void prepare(waybar::modules::Wireplumber* self);
|
|
void activatePlugins();
|
|
static void updateVolume(waybar::modules::Wireplumber* self, uint32_t id);
|
|
static void updateNodeName(waybar::modules::Wireplumber* self, uint32_t id);
|
|
static void onPluginActivated(WpObject* p, GAsyncResult* res, waybar::modules::Wireplumber* self);
|
|
static void onDefaultNodesApiLoaded(WpObject* p, GAsyncResult* res,
|
|
waybar::modules::Wireplumber* self);
|
|
static void onMixerApiLoaded(WpObject* p, GAsyncResult* res, waybar::modules::Wireplumber* self);
|
|
static void onObjectManagerInstalled(waybar::modules::Wireplumber* self);
|
|
static void onMixerChanged(waybar::modules::Wireplumber* self, uint32_t id);
|
|
static void onDefaultNodesApiChanged(waybar::modules::Wireplumber* self);
|
|
|
|
bool handleScroll(GdkEventScroll* e) override;
|
|
|
|
WpCore* wp_core_;
|
|
GPtrArray* apis_;
|
|
WpObjectManager* om_;
|
|
WpPlugin* mixer_api_;
|
|
WpPlugin* def_nodes_api_;
|
|
gchar* default_node_name_;
|
|
uint32_t pending_plugins_;
|
|
bool muted_;
|
|
double volume_;
|
|
double min_step_;
|
|
uint32_t node_id_{0};
|
|
std::string node_name_;
|
|
gchar* type_;
|
|
};
|
|
|
|
} // namespace waybar::modules
|