Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorServicePipeWire::PwNode Class Reference

One PipeWire audio node — a sink, source, output stream, or input stream. More...

#include <PhosphorServicePipeWire/PwNode.h>

Inheritance diagram for PhosphorServicePipeWire::PwNode:
[legend]

Public Slots

void setVolume (qreal value)
 Set every channel's linear amplitude to value.
void setVolumes (const QList< qreal > &values)
 Per-channel write.
void setMuted (bool muted)
 Asynchronous mute write.

Signals

void infoChanged ()
void propsChanged ()

Public Member Functions

 ~PwNode () override
quint32 id () const
QString name () const
QString nick () const
QString description () const
QString mediaClass () const
bool running () const
QString mediaName () const
void applyRunning (bool running)
QString applicationName () const
QString iconName () const
QString serial () const
QString targetName () const
bool canMove () const
void applyTarget (const QString &target, bool present)
 Internal metadata echo, on the GUI thread.
quint32 channelCount () const
QList< qreal > volumes () const
bool muted () const
QHash< QString, QString > properties () const
PipeWireConnection * connection () const
 Typed accessor for the owning connection.
void applyInfo (QHash< QString, QString > props)
void applyProps (int channelCount, QList< qreal > volumes, bool muted)

Detailed Description

One PipeWire audio node — a sink, source, output stream, or input stream.

Vended by PipeWireConnection via nodes() / nodeAdded() / nodeRemoved(); never directly constructed from QML (registered as uncreatable so the metatype is visible to bindings without inviting accidental QML-side new PwNode()).

All Q_PROPERTY values are populated from PipeWire pw_node info and the SPA_PARAM_Props parameter:

  • id, name, mediaClass come from the registry global event.
  • nick and description come from the node-info properties hash (PipeWire convention: node.nick, node.description).
  • channelCount, volumes, muted come from a SPA_PARAM_Props pod enumerated after construction and tracked via the node's param-changed event.

Volumes are linear amplitudes per channel (PipeWire's storage format). Consumers that want cubic / perceptual mapping for a UI slider should run them through a Mixer.Curve helper (added in a later milestone) — round-trips through the lib stay lossless.

Post-removal slot behavior: once the underlying daemon-side pw_node has been removed (between the daemon's global_remove event and the GUI's nodeRemoved firing, plus any tail where a QML binding still holds a stale pointer), setVolume / setVolumes / setMuted route the write through the owning PipeWireConnection to the loop thread. There, the registry lookup for the (now-gone) node id misses and the write is silently dropped — no error, no signal, no crash. Treat these slots as best-effort once the model has signalled removal.

Constructor & Destructor Documentation

◆ ~PwNode()

PhosphorServicePipeWire::PwNode::~PwNode ( )
override

Member Function Documentation

◆ applicationName()

QString PhosphorServicePipeWire::PwNode::applicationName ( ) const
nodiscard

◆ applyInfo()

void PhosphorServicePipeWire::PwNode::applyInfo ( QHash< QString, QString > props)

◆ applyProps()

void PhosphorServicePipeWire::PwNode::applyProps ( int channelCount,
QList< qreal > volumes,
bool muted )

◆ applyRunning()

void PhosphorServicePipeWire::PwNode::applyRunning ( bool running)

◆ applyTarget()

void PhosphorServicePipeWire::PwNode::applyTarget ( const QString & target,
bool present )

Internal metadata echo, on the GUI thread.

◆ canMove()

bool PhosphorServicePipeWire::PwNode::canMove ( ) const
nodiscard

◆ channelCount()

quint32 PhosphorServicePipeWire::PwNode::channelCount ( ) const
nodiscard

◆ connection()

PipeWireConnection * PhosphorServicePipeWire::PwNode::connection ( ) const
nodiscard

Typed accessor for the owning connection.

PwNode's write slots (setVolume, setVolumes, setMuted) route through it so the loop-thread dispatch is encapsulated.

◆ description()

QString PhosphorServicePipeWire::PwNode::description ( ) const
nodiscard

◆ iconName()

QString PhosphorServicePipeWire::PwNode::iconName ( ) const
nodiscard

◆ id()

quint32 PhosphorServicePipeWire::PwNode::id ( ) const
nodiscard

◆ infoChanged

void PhosphorServicePipeWire::PwNode::infoChanged ( )
signal

◆ mediaClass()

QString PhosphorServicePipeWire::PwNode::mediaClass ( ) const
nodiscard

◆ mediaName()

QString PhosphorServicePipeWire::PwNode::mediaName ( ) const
nodiscard

◆ muted()

bool PhosphorServicePipeWire::PwNode::muted ( ) const
nodiscard

◆ name()

QString PhosphorServicePipeWire::PwNode::name ( ) const
nodiscard

◆ nick()

QString PhosphorServicePipeWire::PwNode::nick ( ) const
nodiscard

◆ properties()

QHash< QString, QString > PhosphorServicePipeWire::PwNode::properties ( ) const
nodiscard

◆ propsChanged

void PhosphorServicePipeWire::PwNode::propsChanged ( )
signal

◆ running()

bool PhosphorServicePipeWire::PwNode::running ( ) const
nodiscard

◆ serial()

QString PhosphorServicePipeWire::PwNode::serial ( ) const
nodiscard

◆ setMuted

void PhosphorServicePipeWire::PwNode::setMuted ( bool muted)
slot

Asynchronous mute write.

propsChanged fires once the daemon confirms.

◆ setVolume

void PhosphorServicePipeWire::PwNode::setVolume ( qreal value)
slot

Set every channel's linear amplitude to value.

Convenience for QML sliders that drive a single bar across the whole node. The write is asynchronous: propsChanged fires after the daemon echoes the new SPA_PARAM_Props pod, not immediately.

Expected input range: linear amplitude, approximately [0.0, 1.0] for the normal mixer range, with values above 1.0 permitted for boost (PipeWire accepts them but most hardware sinks clip). Negative values are not part of the linear-amplitude contract: PipeWire may interpret them as phase-inverted (driver-dependent) or clamp them to zero, neither of which is a useful UI behaviour. Callers should clamp to [0.0, expected upper bound] at the UI layer before invoking; the slot forwards value to the daemon verbatim.

◆ setVolumes

void PhosphorServicePipeWire::PwNode::setVolumes ( const QList< qreal > & values)
slot

Per-channel write.

Forwards verbatim to PipeWireConnection::writeVolumes. PipeWire clamps the array to SPA_AUDIO_MAX_CHANNELS and ignores entries beyond channelCount(); callers should size values to match channelCount() to avoid silent truncation.

Each entry follows the same linear-amplitude contract as setVolume (approximately [0.0, 1.0]+, caller-clamped).

◆ targetName()

QString PhosphorServicePipeWire::PwNode::targetName ( ) const
nodiscard

◆ volumes()

QList< qreal > PhosphorServicePipeWire::PwNode::volumes ( ) const
nodiscard

The documentation for this class was generated from the following file:
  • phosphor-service-pipewire/include/PhosphorServicePipeWire/PwNode.h