Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/pipewire/pipewire.conf.d/10-sample-rates.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Follow the source's sample rate instead of resampling everything to 48 kHz.
## When a stream starts on an idle device, PipeWire switches the device to the
## stream's rate if the hardware supports it, so 44.1 kHz music and 88.2/96 kHz
## recordings play without resampling. Rates the device can't do still resample.

context.properties = {
default.clock.allowed-rates = [ 44100 48000 88200 96000 ]
}
21 changes: 21 additions & 0 deletions migrations/1793769095.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
echo "Let PipeWire follow the source's sample rate"

conf="pipewire/pipewire.conf.d/10-sample-rates.conf"
config_root="${XDG_CONFIG_HOME:-$HOME/.config}"

# Leave anyone who already chose their rates alone, in any PipeWire config.
# PIPEWIRE_CONFIG_DIR is PipeWire's own override for /etc/pipewire.
rates_configured() {
local system="${PIPEWIRE_CONFIG_DIR:-/etc/pipewire}"

grep -qsE '^[[:space:]]*default\.clock\.allowed-rates' \
"$config_root/pipewire/pipewire.conf" "$config_root"/pipewire/pipewire.conf.d/*.conf \
"$system/pipewire.conf" "$system"/pipewire.conf.d/*.conf
Comment on lines +11 to +13

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 One-line settings get overwritten

If a user writes context.properties = { default.clock.allowed-rates = [ 48000 ] } on one line, this check misses their valid setting. It only matches lines that start with default.clock.allowed-rates after whitespace. The migration then installs its own list and replaces the running setting through pw-metadata, despite promising to preserve chosen rates.

Read the merged properties instead of relying on where the key appears on a line.

Knowledge Base Used: Migration framework

}

if [[ ! -f $config_root/$conf ]] && ! rates_configured; then
install -Dm644 "$OMARCHY_PATH/config/$conf" "$config_root/$conf"
# PipeWire only reads conf.d at startup. Apply the rates to the running graph
# too, so the change takes effect now without interrupting playback.
pw-metadata -n settings 0 clock.allowed-rates "[ 44100 48000 88200 96000 ]" >/dev/null 2>&1 || true
fi