Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PipeWireConnection.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorServicePipeWire/phosphorservicepipewire_export.h>
7// Full PwNode definition, not a forward declaration: the nodeAdded/
8// nodeRemoved signals carry PwNode*, and Qt6 moc auto-registers signal
9// parameter metatypes — QMetaType SFINAE-probes completeness, so a fwd decl
10// here makes the probe fail and GCC's -Wsfinae-incomplete fire when
11// moc_PwNode.cpp later defines the class in the same mocs_compilation TU.
13
14#include <QList>
15#include <QObject>
16#include <QString>
17
18#include <memory>
19
21
58class PHOSPHORSERVICEPIPEWIRE_EXPORT PipeWireConnection : public QObject
59{
60 Q_OBJECT
61 Q_DISABLE_COPY_MOVE(PipeWireConnection)
62 Q_PROPERTY(bool connected READ isConnected NOTIFY connectedChanged)
77 Q_PROPERTY(bool daemonAvailable READ isDaemonAvailable NOTIFY daemonAvailableChanged)
82 Q_PROPERTY(QString defaultSinkName READ defaultSinkName NOTIFY defaultSinkNameChanged)
85
86public:
87 explicit PipeWireConnection(QObject* parent = nullptr);
89
90 // `is`-prefixed getters follow the Qt convention for bool Q_PROPERTY
91 // READ accessors (matches QObject::isWidgetType, QWindow::isVisible,
92 // etc.); the property name stays unprefixed (`connected`,
93 // `daemonAvailable`) for the QML side.
94 [[nodiscard]] bool isConnected() const;
95 [[nodiscard]] bool isDaemonAvailable() const;
96 [[nodiscard]] QString defaultSinkName() const;
97 [[nodiscard]] QString defaultSourceName() const;
128 [[nodiscard]] QList<PwNode*> nodes() const;
129
130public Q_SLOTS:
146 void setDefaultSink(const QString& nodeName);
148 void setDefaultSource(const QString& nodeName);
151 void setStreamTarget(quint32 streamId, const QString& nodeName);
168 void writeVolumes(quint32 nodeId, const QList<qreal>& volumes);
173 void writeMuted(quint32 nodeId, bool muted);
174
175Q_SIGNALS:
176 void operationFailed(const QString& message);
186 void error(const QString& message);
210
211private:
212 class Private;
213 std::unique_ptr<Private> d;
214};
215
216} // namespace PhosphorServicePipeWire
void setStreamTarget(quint32 streamId, const QString &nodeName)
Set a playback stream's WirePlumber target.
QList< PwNode * > nodes() const
Snapshot of every node the registry has reported so far, for C++ callers only.
void nodeAdded(PhosphorServicePipeWire::PwNode *node)
Fired from the GUI thread when the registry reports a new audio node (Sink, Source,...
void writeVolumes(quint32 nodeId, const QList< qreal > &volumes)
Asynchronously write a per-channel volume array to the node with the given PipeWire global id.
void operationFailed(const QString &message)
void writeMuted(quint32 nodeId, bool muted)
Asynchronously write a mute state.
PipeWireConnection(QObject *parent=nullptr)
True once the PipeWire daemon has answered the pw_core info event for the current connection (i....
void error(const QString &message)
Fired from the GUI thread when PipeWire reports a core-level error.
void setDefaultSink(const QString &nodeName)
Write the WirePlumber default.configured.audio.sink metadata key.
void nodeRemoved(PhosphorServicePipeWire::PwNode *node)
Fired from the GUI thread BEFORE the PwNode is destroyed so observers (models) can detach.
void setDefaultSource(const QString &nodeName)
As above for the audio source.
void connectToDaemon()
Asynchronously establish a pw_context + pw_core and complete the initial sync.
void disconnectFromDaemon()
Asynchronously tear down pw_core + pw_context.
One PipeWire audio node — a sink, source, output stream, or input stream.
Definition PwNode.h:49
Definition PipeWireConnection.h:20