Waybar/include/util/pipewire/pipewire_backend.hpp

44 lines
1.3 KiB
C++
Raw Normal View History

2023-10-26 21:08:57 +00:00
#pragma once
#include <pipewire/pipewire.h>
#include "util/backend_common.hpp"
#include "util/pipewire/privacy_node_info.hpp"
namespace waybar::util::PipewireBackend {
class PipewireBackend {
private:
pw_thread_loop* mainloop_;
pw_context* context_;
pw_core* core_;
2024-03-25 18:40:23 +00:00
pw_registry* registry_;
spa_hook registryListener_;
2023-10-26 21:08:57 +00:00
/* Hack to keep constructor inaccessible but still public.
* This is required to be able to use std::make_shared.
* It is important to keep this class only accessible via a reference-counted
* pointer because the destructor will manually free memory, and this could be
* a problem with C++20's copy and move semantics.
*/
2024-03-25 18:40:23 +00:00
struct PrivateConstructorTag {};
2023-10-26 21:08:57 +00:00
public:
sigc::signal<void> privacy_nodes_changed_signal_event;
std::unordered_map<uint32_t, PrivacyNodeInfo*> privacy_nodes;
2024-03-25 18:40:23 +00:00
std::mutex mutex_;
2023-10-26 21:08:57 +00:00
static std::shared_ptr<PipewireBackend> getInstance();
2024-03-25 18:40:23 +00:00
// Handlers for PipeWire events
void handleRegistryEventGlobal(uint32_t id, uint32_t permissions, const char* type,
uint32_t version, const struct spa_dict* props);
void handleRegistryEventGlobalRemove(uint32_t id);
PipewireBackend(PrivateConstructorTag tag);
2023-10-26 21:08:57 +00:00
~PipewireBackend();
};
2023-10-26 22:01:40 +00:00
} // namespace waybar::util::PipewireBackend