Native PipeWire mixer (sinks / sources / per-app streams, default-node switching, volume + mute) for Phosphor-based desktop shells.
Owns the PipeWire main loop on a dedicated QThread, walks the pw_registry, and surfaces sinks / sources / streams as Qt + QML types. There is no UI. The shell decides how a volume mixer, OSD, or sound preferences page is rendered.
The library is non-visual (no Qt::Gui link) and single-process by design (the loop runs inside the same QGuiApplication that hosts the shell). All cross-thread plumbing is hidden, so consumers see a pure GUI-thread API backed by queued signals from the loop thread.
| Type | Role |
|---|---|
| PipeWireConnection | Lifecycle owner. Holds the pw_main_loop thread, pw_context, pw_core. Exposes connected, daemonAvailable, defaultSinkName, defaultSourceName properties + error(QString), nodeAdded(PwNode*), nodeRemoved(PwNode*) signals. Routes per-node writes (writeVolumes, writeMuted) and WirePlumber metadata writes (setDefaultSink, setDefaultSource) onto the loop thread. |
| PwNode | One audio node (sink, source, output stream, or input stream). Exposes id, name, nick, description, mediaClass, channelCount, volumes[] (linear amplitudes), muted, plus the async setters setVolume(qreal), setVolumes(QList<qreal>), setMuted(bool). Vended by PipeWireConnection; QML-uncreatable. |
| PwNodeModel | Abstract QAbstractListModel filtering a connection's nodes by mediaClasses. 10 pinned role names (9 user roles + Qt::DisplayRole): node, id, name, nick, description, mediaClass, channelCount, volumes, muted, plus Qt::DisplayRole (display) that falls back through nick → description → name. |
| PwSinkModel / PwSourceModel / PwStreamModel | Convenience subclasses with the common filters pre-applied. PwStreamModel lumps Stream/Output/Audio and Stream/Input/Audio together. |
| PipeWireHost | QML singleton (Phosphor.Service.PipeWire 1.0) that owns the process-wide PipeWireConnection and forwards every observable signal. Auto-connects on construction, and exposes connectToDaemon(), disconnectFromDaemon(), and reconnect() for explicit lifecycle control. |
C++ shell composition root:
#include <PhosphorServicePipeWire/QmlRegistration.h>
int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
PhosphorServicePipeWire::registerQmlTypes();
// ... QQmlApplicationEngine engine; engine.load(shellUrl); etc.
return app.exec();
}QML consumer (volume slider per sink):
import Phosphor.Service.PipeWire 1.0
ColumnLayout {
Repeater {
model: PwSinkModel { connection: PipeWireHost.connection }
delegate: RowLayout {
required property var model
Label { text: model.display + (model.name === PipeWireHost.defaultSinkName ? " (default)" : "") }
Slider {
from: 0; to: 1
value: model.volumes.length > 0 ? model.volumes[0] : 0
onMoved: model.node.setVolume(value)
}
CheckBox {
checked: model.muted
text: "mute"
onToggled: model.node.setMuted(checked)
}
}
}
}The CLI in examples/phosphor-service-pipewire-cli/ is the canonical C++ usage example: see phosphor-service-pipewire-cli list sinks, set-volume <target> <pct>, set-default-sink <name>, mute <target>, default, and the rest of the subcommand surface.
Shipped. The PipeWireConnection lifecycle, the registry observer and PwNode, the sink / source / stream models, the volume + mute write path, default-sink / -source switching via WirePlumber metadata, QML registration with the PipeWireHost singleton, the CLI acceptance harness, and the smoke + role-pinning tests are all in place.