Process-wide PipeWire host: owns the single PipeWireConnection instance the shell binds to and re-exposes its observable state as QML-friendly properties, including the error(QString) signal. More...
#include <PhosphorServicePipeWire/PipeWireHost.h>
Public Slots | |
| void | reconnect () |
| Trigger a re-connect on the underlying connection. | |
| void | connectToDaemon () |
| Asynchronously connect the underlying PipeWireConnection to the daemon. | |
| void | disconnectFromDaemon () |
| Asynchronously disconnect the underlying PipeWireConnection from the daemon. | |
Signals | |
| void | connectedChanged () |
| void | daemonAvailableChanged () |
| void | defaultSinkNameChanged () |
| void | defaultSourceNameChanged () |
| void | defaultSinkChanged () |
| void | defaultSourceChanged () |
| void | error (const QString &message) |
| Forwarded from PipeWireConnection::error. | |
| void | nodeAdded (PhosphorServicePipeWire::PwNode *node) |
| Forwarded from PipeWireConnection::nodeAdded. | |
| void | nodeRemoved (PhosphorServicePipeWire::PwNode *node) |
| Forwarded from PipeWireConnection::nodeRemoved. | |
Public Member Functions | |
| PipeWireHost (QObject *parent=nullptr) | |
| Mirror of the underlying connection's daemonAvailable. | |
| ~PipeWireHost () override | |
| PipeWireConnection * | connection () const |
| Constructed eagerly in PipeWireHost ctor; guaranteed non-null for the host's lifetime. | |
| bool | isConnected () const |
| bool | isDaemonAvailable () const |
| QString | defaultSinkName () const |
| QString | defaultSourceName () const |
| PwNode * | defaultSink () const |
| PwNode * | defaultSource () const |
Process-wide PipeWire host: owns the single PipeWireConnection instance the shell binds to and re-exposes its observable state as QML-friendly properties, including the error(QString) signal.
Registered as a QML singleton (see qmlregistration.cpp; the class deliberately omits QML_ELEMENT / QML_SINGLETON macros and is wired imperatively, matching every sibling phosphor-service-* lib) so QML reads PipeWireHost.defaultSinkName rather than maintaining its own PipeWireConnection instance.
Facade coverage: every observable signal of PipeWireConnection is forwarded one-for-one — connectedChanged, daemonAvailableChanged, defaultSinkNameChanged, defaultSourceNameChanged, error, nodeAdded, nodeRemoved. QML consumers can OBSERVE exclusively through PipeWireHost.* and never need to reach through .connection.* for state. The mutating slots (setDefaultSink / setDefaultSource / writeVolumes / writeMuted) live only on the connection, so writers still go through host.connection.* — which the connection property exposes (alongside its other use: handing the connection to a PwNodeModel).
defaultSink / defaultSource are the one exception to the pure-forwarding rule: they are DERIVED, joining the connection's default-name strings against its node set. The join lives here rather than in each consumer because its correctness depends on ordering details of the registry (a node's name arrives after its nodeAdded) that QML has no good way to observe.
The host is constructed lazily on first QML use (via qmlRegisterSingletonType's factory) and auto-connects to the daemon. Shells that want explicit lifecycle control can construct their own PipeWireConnection directly and skip the singleton, or drive the existing instance through connectToDaemon() / disconnectFromDaemon() / reconnect().
Why a separate host? The PipeWire loop thread is expensive enough (one extra thread per process) that we don't want to spin one up per QML scope. Forcing all QML consumers through this singleton guarantees they share the same loop + registry walk.
|
explicit |
Mirror of the underlying connection's daemonAvailable.
See PipeWireConnection::daemonAvailable for the full semantics (info-answered vs. fully connected, and the three reset paths). The Audio/Sink node named by defaultSinkName, or null while no default is published or the named node is not (yet) in the registry. Resolving the name against the node set is the one piece of state every consumer of the default sink needs and none can derive cheaply: the name arrives from the metadata module while the node arrives from the registry, in either order, and a node's name itself lands in an info batch AFTER its nodeAdded. Doing this in QML means a hidden delegate per row re-implementing the join, which is both duplicated per widget and easy to get wrong. The Audio/Source node named by defaultSourceName. Same resolution semantics as defaultSink.
|
override |
|
signal |
|
nodiscard |
Constructed eagerly in PipeWireHost ctor; guaranteed non-null for the host's lifetime.
CONSTANT semantics in the Q_PROPERTY above are safe because the pointer never changes after construction — reconnect / connectToDaemon / disconnectFromDaemon mutate the underlying connection's state, never its identity.
|
slot |
Asynchronously connect the underlying PipeWireConnection to the daemon.
Symmetric with disconnectFromDaemon(); exposed on the host (alongside the existing reconnect()) so QML has full lifecycle control without reaching through host.connection.connectToDaemon() — keeps the facade complete.
|
signal |
|
nodiscard |
|
signal |
|
nodiscard |
|
signal |
|
nodiscard |
|
signal |
|
nodiscard |
|
signal |
|
slot |
Asynchronously disconnect the underlying PipeWireConnection from the daemon.
Symmetric with connectToDaemon(); same rationale — QML shells that want to pause the daemon connection (battery saver, suspend) can do it through the host facade.
|
signal |
Forwarded from PipeWireConnection::error.
Fired from the GUI thread when PipeWire reports a core-level error (daemon restart, version mismatch, pre-handshake failure). The host re-emits without transformation so QML observers can bind to error on the host singleton rather than reaching through .connection.
|
nodiscard |
|
nodiscard |
|
signal |
Forwarded from PipeWireConnection::nodeAdded.
Same payload and semantics — fired from the GUI thread when the registry reports a new audio node. Exposed on the host so QML observers can wire PipeWireHost.onNodeAdded without reaching through .connection. FQN PhosphorServicePipeWire::PwNode* is intentional — moc's metatype registration matches the signature spelling, and the FQN dodges QML ambiguity in queued connections.
|
signal |
Forwarded from PipeWireConnection::nodeRemoved.
Fired BEFORE the PwNode is destroyed so observers can detach. Same FQN rationale as nodeAdded.
|
slot |
Trigger a re-connect on the underlying connection.
Useful after the daemon was offline at startup and the shell wants to retry without restarting the process.