Skip to content

media-session: use separate keys for configured default nodes

P V requested to merge pvir/pipewire:default-metadata-always-2 into master

Use separate metadata keys for the current effective default nodes (default.*), and user-configured ones (default.configured.*).

default-nodes saves and restores the configured ones, and policy-node keeps the effective ones up to date.

For pipewire users, the effective default values should be considered read-only, as changing them will not have an effect. To avoid confusion, policy-nodes will reset their values back immediately if they are changed.

Fixes #682 (closed)


This follows the Pulseaudio way. To manage correct automatic switching when devices disappear and appear, media-session needs to keep some state information about the defaults, beyond their current values. Explicitly configured default nodes seem to be an uncomplicated choice of what state to keep.

The main reason to have separate public metadata keys for the configured values is that the metadata API does not emit change events if a key is set to its current value. If there was a single default.audio.sink value, and an user app would want to set the configured value to the current automatic value, it would need to toggle/remove the old key first, which may be racy (and seems like an API wart).

policy-nodes sets the default metadata keys at the end of session rescan, so the default metadata changes should at least usually be ordered after nodes appearing.

Edited by P V

Merge request reports