出自 Arch Linux 中文维基

Tango-preferences-desktop-locale-modified.png這篇文章或章節的翻譯不反映原文。Tango-preferences-desktop-locale-modified.png

原因:該文章存在大量從英文wiki搬運過來且未及時翻譯的內容(在 Talk:PipeWire# 中討論)

PipeWire 是一個新的底層多媒體框架。 它旨在以最低的延遲為音頻和視頻提供錄製和播放功能,並支持基於 PulseAudioJACKALSAGStreamer 的應用程式。

基於該框架的守護進程可以配置為音頻伺服器(具有 PulseAudio 和 JACK 特性)和視頻錄製伺服器。

PipeWire 還支持像 Flatpak 這樣的容器,不依賴於 audiovideo 用戶組。 相反,它採用了類似於 Polkit的安全模式,向 Flatpak 或 Wayland 請求許可以錄製屏幕或音頻。

安裝

可以從官方軟體庫安裝 pipewire 程序。 也有lib32-pipewire 的32位庫對於 multilib 進行支持

Pipewire 使用 systemd/用戶 管理伺服器並自動激活socket。

可以選擇安裝 pipewire-docs 來查看文檔。

Pipewire 可以作為其他音頻伺服器的直接替代品。參見 #Audio 詳細信息。

Tango-view-fullscreen.png這篇文章的某些內容需要擴充。Tango-view-fullscreen.png

原因: Describe what gst-plugin-pipewire does exactly. (在 Talk:PipeWire 中討論)

Session(會話)管理

JACK一樣,PipeWire 內部沒有實現連接邏輯。 監視新 streams 並將其連接到適當的輸出設備或應用程式的負擔留給稱為會話管理器的外部組件。

目前有兩個可用的 session 管理:

  • PipeWire Media Session — 一個非常簡單的會話管理器,可以滿足一些基本的桌面用例。它主要是為了測試和作為構建新會話管理器的示例而實現的。
https://gitlab.freedesktop.org/pipewire/media-session || pipewire-media-session
  • WirePlumber — 一個當前比較推薦的更強大的管理器。它基於模塊化設計,使用 Lua 插件實現實際的管理功能。
https://pipewire.pages.freedesktop.org/wireplumber/ || wireplumber

在安裝 PipeWire 時,您將被要求在其中之一進行選擇。稍後可以通過安裝適當的包在它們之間切換,這將與另一個選項衝突並替換它們。

GUI圖形界面

  • Helvum — 基於GTK patchbay for PipeWire, 靈感來自JACK工具catia.
https://gitlab.freedesktop.org/pipewire/helvum || helvum
  • qpwgraph — 基於Qt的Graph/Patchbay for PipeWire,靈感來自JACK工具 QjackCtl.
https://gitlab.freedesktop.org/rncbc/qpwgraph || qpwgraph

配置

PipeWire 軟體包在 /usr/share/pipewire 中提供了一組初始配置文件。不應直接編輯這些文件,因為包更新將覆蓋所做的更改。要配置 PipeWire,可以將文件從 /usr/share/pipewire 複製到備用系統配置目錄位置 /etc/pipewire或用戶目錄 ~/.config/pipewire. [1]

Profiles

Pipewire 帶來了一個PulseAudio 配置以外的自定義的 "Pro Audio" 配置文件, 可通過 pavucontrol進行選擇。其效果如下所述:https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/FAQ#what-is-the-pro-audio-profile

用法

Audio

Tango-view-fullscreen.png這篇文章的某些內容需要擴充。Tango-view-fullscreen.png

原因: What happens when none of the following is configured/installed and an application sends audio directly to pipewire? The pipewire package contains many audio-related files, e.g. /etc/alsa/conf.d/50-pipewire.conf. (在 Talk:PipeWire 中討論)

PipeWire 可以用作音頻伺服器,類似於 PulseAudio 和 JACK,它旨在通過為JACK客戶端提供PulseAudio兼容的伺服器實現和ABI兼容庫來取代PulseAudio和JACK。有關詳細信息,請參閱博客文章PipeWire Late Summer Update 2020

ALSA 客戶端

安裝 pipewire-alsa (如果已安裝,則刪除 pulseaudio-alsa) 以使用 ALSA API 通過 PipeWire 路由所有應用程式。

PulseAudio 客戶端

安裝 pipewire-pulse. 它將代替 pulseaudiopulseaudio-bluetooth。重新啟動、重新登錄或 start pipewire-pulse.service user unit 以查看效果。

通常,不需要進一步的操作,應用應作為用戶服務自動啟用pipewire-pulse.socket。要檢查替換是否正常工作,請運行以下命令並查看輸出:

$ pactl info
...
Server Name: PulseAudio (on PipeWire 0.3.32)
...

JACK 客戶端

安裝 pipewire-jack 以獲取 JACK 支持。還有 lib32-pipewire-jack 用於 multilib 支持。

pw-jack(1) 可以用來啟動 JACK 客戶端, 但從技術上講它不是必需的, 因為它只用作 PIPEWIRE_REMOTEPIPEWIRE_DEBUGPIPEWIRE_LATENCY 環境變量的包裝器。

可以通過設置 緩衝區大小/採樣率 的商(等於以秒為單位的塊延遲)來請求自定義緩衝區大小:

PIPEWIRE_LATENCY="128/48000" application

Bluetooth 設備

如果安裝了 pipewire-pulse 軟體包,PipeWire 將處理藍牙音頻設備。 該軟體包包含 /etc/pipewire/media-session.d/with-pulseaudio 文件,該文件的存在會提示媒體會話守護程序啟用 bluez5 模塊

Automatic profile selection

pipewire-media-sessionWirePlumber 都可以在檢測到輸入流時自動在 HSP/HFP 和 A2DP 配置文件之間切換。

pipewire-media-session 默認禁用, 您可以設置 bluez5.autoswitch-profile 屬性為 true 以啟用他:

/etc/pipewire/media-session.d/bluez-monitor.conf (or ~/.config/pipewire/media-session.d/bluez-monitor.conf)
...
rules = [
    {
        ...
        actions = {
            update-props = {
                ...
                bluez5.autoswitch-profile = true
...

WirePlumber 默認啟用了配置文件自動切換。您可以使用以下命令禁用它:

/etc/wireplumber/policy.lua.d/11-bluetooth-policy.lua (or ~/.config/wireplumber/policy.lua.d/11-bluetooth-policy.lua)
bluetooth_policy.policy["media-role.use-headset-profile"] = false

PipeWire native patch sets

我們有用於圖形可視化和創建連接的 Helvum,但是其他的還沒有出現。下面是 bash 腳本,它保存wiresets、加載wiresets和取消連接。對於保存和加載,請為文件名使用命令行參數。

pw-savewires
#!/bin/bash

if [[ "$#" -ne 1 ]]; then
	echo
	echo 'usage: pw-savewires filename'
	echo
	exit 0
fi

rm $1 &> /dev/null
while IFS= read -r line; do
	link_on=`echo $line | cut -f 4 -d '"'`
	link_op=`echo $line | cut -f 6 -d '"'`
	link_in=`echo $line | cut -f 8 -d '"'`
	link_ip=`echo $line | cut -f 10 -d '"'`
	echo "Saving: " "'"$link_on:$link_op"','"$link_in:$link_ip"'"
	echo "'"$link_on:$link_op"','"$link_in:$link_ip"'" >> $1
done < <(pw-cli dump short link)
pw-loadwires
#!/bin/python

import sys
import csv
import os

if len(sys.argv) < 2:
	print('\n usage: pw-loadwires filename\n')
	quit()

with open(sys.argv[1], newline='') as csvfile:
	pwwreader = csv.reader(csvfile, delimiter=',', quotechar='"')
	for row in pwwreader:
		print('Loading:  ' + row[0] + ' --> ' + row[1])
		process = os.popen('pw-link ' + row[0] + ' ' + row[1])
pw-dewire
#!/bin/bash
while read -r line; do
	echo 'Dewiring: ' $line '...'
	pw-link -d $line
done < <(pw-cli dump short link {{!}} grep -Eo '^[0-9]+')

與網絡上的計算機共享音頻設備

While PipeWire itself is not network transparent, its pulse implementation supports network streaming. An easy way to share audio between computers on the network is to use the Avahi daemon for discovery. Make sure that the avahi-daemon.service is running on all computers that will be sharing audio.

To share the local audio devices load the appropriate modules on the host (make sure to use the local IP address):

$ pactl load-module module-native-protocol-tcp listen=192.168.1.10
$ pactl load-module module-zeroconf-publish

Then load the discovery module on the clients:

$ pactl load-module module-zeroconf-discover

在本地 JACK 上運行 PipeWire

PipeWire can also run as a JACK client on top of the native JACK daemon if desired. See JACK and PipeWire for more information.

WebRTC 屏幕共享

Most applications used to rely on X11 for capturing the desktop (or individual applications), for example when using WebRTC in web browsers (e.g. on Google Hangouts). On Wayland, the sharing mechanism is handled differently for security reasons. PipeWire enables sharing content under Wayland with fine-grained access controls.

This requires xdg-desktop-portal and one of its backends to be installed. The available backends are:

注意: xdg-desktop-portal 1.10.0 fixed a mismatch between specification and implementation of its D-Bus interface. [2] Hence, some clients may not work with xdg-desktop-portal 1.10.0 or newer.

Firefox (84+) supports this method by default, while on Chromium (73+) one needs to enable WebRTC PipeWire support by setting the corresponding (experimental) flag at the URL chrome://flags/#enable-webrtc-pipewire-capturer.

obs-studio (27+) supports this method by using the new PipeWire capture source.

Tango-inaccurate.png本文或本章節的事實準確性存在爭議。Tango-inaccurate.png

原因: Since this pull request was merged, the following note about specific app/window sharing may be not correct anymore for xdg-desktop-portal-gtk. Also see the ticket tracking the discussion at [3].(在 Talk:PipeWire 中討論)


Note that the only supported feature is sharing the entire desktop and not a specific app/window [4][5].

xdg-desktop-portal-wlr

For xdg-desktop-portal-wlr to work, the XDG_CURRENT_DESKTOP and WAYLAND_DISPLAY environment variables have to be set in the systemd用戶會話. XDG_CURRENT_DESKTOP has to be set to the name of your compositor, e.g. XDG_CURRENT_DESKTOP=sway. WAYLAND_DISPLAY is set automatically by the compositor. The recommended way to bring these environment variables over to the systemd user session is to run systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP after launching the compositor, e.g. with the compositors configuration file. See [6] and [7] for more details.

提示:To select shared monitor with xdg-desktop-portal-wlr if you have more than one, install slurp and add the following configuration (see xdg-desktop-portal-wlr(5) § SCREENCAST OPTIONS):
~/.config/xdg-desktop-portal-wlr/config
chooser_type = simple
chooser_cmd = slurp -f %o -ro

When sharing a screen is requested, slurp will present you with a crosshair cursor and you'll need to click the screen you want to share. After the selection, xdg-desktop-portal-wlr will allow sharing that screen.

Video

Tango-view-fullscreen.png這篇文章的某些內容需要擴充。Tango-view-fullscreen.png

原因: pipewire-v4l2 (在 Talk:PipeWire 中討論)

Although the software is not yet production-ready, it is safe to play around with. Most applications that rely on GStreamer to handle e.g. video streams should work out-of-the-box using the PipeWire GStreamer plugin, see GStreamer#PipeWire. Applications like e.g. cheese are therefore already able to share video input using it.

Using pipewire-v4l2, it should also be possible to use the pw-v4l2 script to preload a library (/lib/pipewire-0.3/v4l2/libpw-v4l2.so) that intercepts v4l2 calls and routes video through pipewire.

Audio後期處理

EasyEffects

EasyEffects (former PulseEffects) is a GTK utility which provides a large array of audio effects and filters to individual application output streams and microphone input streams. Notable effects include an input/output equalizer, output loudness equalization and bass enhancement, input de-esser and noise reduction plug-in. See the GitHub page for a full list of effects.

In order to use EasyEffects, install easyeffects. See Community Presets for a collection of preset configurations. See AutoEq for collection of AI generated EQ presets for headphones.

注意: For PulseEffects legacy version, see PulseAudio#PulseEffects.

NoiseTorch

NoiseTorch is an alternative way for noise suppression, packaged with noisetorchAUR. There also exists noisetorch-gitAUR.

After starting it the module can be loaded for the selected microphone. It is possible to adjust the voice activation threshold, which should be set to the highest level, not filtering out any actual voice.

You can start audio processing with systemd automatically, see [8]. Note that the noisetorch binary path is different if installed from AUR.

Noise suppression for voice

Install noise-suppression-for-voice and use one of the following options:

  • Add the following line in the context.exec section:
/etc/pipewire/pipewire.conf (or ~/.config/pipewire/pipewire.conf)
...
context.exec = [
    ...
    { path = "/usr/bin/pipewire" args = "-c /usr/share/pipewire/filter-chain/source-rnnoise.conf" }
    ...

Then, set the noise cancelled source as default in your audio settings. You might need to restart your application prior being able to use it.

JamesDSP

JamesDSP for Linux (available as jamesdspAUR) provides open-source sound effects for PipeWire and PulseAudio. It uses its own effects engine and without depending on LADSPA, Calf, etc. JamesDSP was initially published as an audio effects processor for Android devices.

LADSPA, LV2 and VST 插件

If you want to choose between the full list of available LADSPA, LV2 and VST plugins, you can apply them using a custom Pulseaudio null sink and Carla Jack host. Install pipewire-pulse, pipewire-jack and carla. At the begin, create a new PulseAudio null sink named default_null_sink.

pactl load-module module-null-sink object.linger=1 media.class=Audio/Sink sink_name=default_null_sink channel_map=FL,FR

Start Carla through Pipewire, pw-jack carla-rack. In Rack tab add whichever plugin you want. Make sure they are stereo type. You can change their order, the one on top of the list will be the first to receive the audio stream, just like in EasyEffects. Afterwards move to Patchbay tab and connect the default_null_sink L/R monitors to Carla inputs, then Carla outputs to the playbacks of your desired device (speakers, earphones, HDMI, etc). Save the configuration to a local folder, i.e. ~/Documents/carla_sink_effects.carxp.

You can test the effects while a multimedia application is reproducing audio, i.e. watching a video on a website through Firefox. There are two methods to do it. The first one, inside Carla Patchbay tab, disconnecting all Firefox connections and linking its L/R outputs to default_null_sink playbacks. The second through pavucontrol, locating Firefox audio stream and redirecting it to default_null_sink (this should remember the connection to automatically redirect the application to the same sink on the next instance).

To apply these settings at startup, create two systemd user service units:

~/.config/systemd/user/jack-carla-rack.service
[Unit]
Description=Load Carla Rack JACK host

[Service]
PassEnvironment="PIPEWIRE_LINK_PASSIVE=true"
Type=exec
ExecStart=/usr/bin/pw-jack carla-rack -n

[Install]
WantedBy=default.target
~/.config/systemd/user/pulseaudio-null-sink@.service
[Unit]
Description=Load %i Pulseaudio null sink
Before=jack-carla-rack.service
After=pipewire-pulse.service

[Service]
Type=oneshot
ExecStart=/usr/bin/pactl load-module module-null-sink object.linger=1 media.class=Audio/Sink sink_name=%i channel_map=FL,FR
ExecStop=/usr/bin/pactl unload-module module-null-sink
RemainAfterExit=yes

[Install]
WantedBy=default.target

Then override jack-carla-rack service specifying the full path of your Carla configuration at Environment directive:

~/.config/systemd/user/jack-carla-rack.service.d/override.conf
[Service]
Environment="CARLA_CONFIG_FILE=/home/username/Documents/carla_sink_effects.carxp"
ExecStart=
ExecStart=/usr/bin/pw-jack carla-rack -n $CARLA_CONFIG_FILE

At last, enable the pulseaudio-null-sink@default_null_sink.service and jack-carla-rack.service user units.

Note that if you set the default_null_sink as the default device in system settings, all applications will be redirected to it and the volume keys will change its level, not the one on the speakers. If you want to control volume speakers, leave them as the default in system settings and redirect your desired application to default_null_sink inside pavucontrol (Pipewire compatibility layer will remember the connection on the next instance of the same application).

故障排除

Audio

Microphone is not detected by PipeWire

PipeWire's alsa-monitor module uses alsa-card-profiles to detect devices by default. If this is not working for you, try to turn off api.alsa.use-acp, or optionally turn on api.alsa.use-ucm.

If using pipewire-media-session:

/etc/pipewire/media-session.d/alsa-monitor.conf (or ~/.config/pipewire/media-session.d/alsa-monitor.conf)
...
rules = [
    {
        ...
        actions = {
        update-props = {
            ...
            api.alsa.use-acp = false
...

Otherwise, if using wireplumber:

/etc/wireplumber/main.lua.d/50-alsa-config.lua (or ~/.config/wireplumber/main.lua.d/50-alsa-config.lua)
...
alsa_monitor.rules = {
    {
        ...
        apply_properties = {
            -- Use ALSA-Card-Profile devices. They use UCM or the profile
            -- configuration to configure the device and mixer settings.
            -- ["api.alsa.use-acp"] = true,
 
            -- Use UCM instead of profile when available. Can be
            -- disabled to skip trying to use the UCM profile.
            ["api.alsa.use-ucm"] = true,
...

Then, restart pipewire and check available devices:

$ pw-record --list-targets
Available targets ("*" denotes default): 62
	58: description="Built-in Audio" prio=1872
	60: description="Built-in Audio" prio=2000
*	62: description="Built-in Audio (Loopback PCM)" prio=1984

Sound does not automatically switch to Bluetooth headphones

Tango-inaccurate.png本文或本章節的事實準確性存在爭議。Tango-inaccurate.png

原因: The linked upstream issue is specific to the xfce pulseaudio panel plugin.(在 Talk:PipeWire 中討論)


Run pactl load-module module-switch-on-connect and configure your desktop environment to automatically run that command on login. You might need to execute wpctl set-default <id>. The <id> may be found using output of wpctl status. See wireplumber issue #89 for more details.

No sound after connecting to Bluetooth device

As of 2020-12-07, if there is no sound after connecting a Bluetooth device, you might need to switch the default sink and/or move a sink input to the correct sink. Use pactl list sinks to list the available sinks and pactl set-default-sink to switch the default sink to the Bluetooth device. This can be automated via udev using a script similar to this one.

See this Reddit thread for a discussion of the issue. According to author of the script, the headset profile (HSP) might still have problems.

Low volume

After replacing PulseAudio with Pipewire, sound may work fine, but after a reboot, the volume becomes intolerably low.

Open alsamixer, use F6 to select the proper soundcard, and make sure the ALSA volumes are at 100%. alsactl should maintain this setting after reboot.

Increasing RLIMIT_MEMLOCK

Dec 13 11:11:11 HOST pipewire-pulse[99999]: Failed to mlock memory 0x7f4f659d8000 32832: This is not a problem but for best performance, consider increasing RLIMIT_MEMLOCK

Install realtime-privileges and add your own user to the realtime group.

Alternatively, increasing memlock from 64kB to 128kB seems enough to fix this. If you are running pipewire-pulse under systemd/用戶, add:

username	soft	memlock	64
username	hard	memlock	128

to /etc/security/limits.d/username.conf

Changing the default sample rate

By default PipeWire sets a fixed global sample rate of 48kHz. If you need to change it (e.g. you own a DAC supporting a higher value), you can set a new default:

/etc/pipewire/pipewire.conf (or ~/.config/pipewire/pipewire.conf)
...
context.properties = {
    ...
    default.clock.rate          = sample_rate
    ...

Changing the allowed sample rate(s)

PipeWire can also change dynamically the output sample rates supported by your DAC. The sample rate follows the sample rate of the audio stream being played.

/etc/pipewire/pipewire.conf (or ~/.config/pipewire/pipewire.conf)
...
context.properties = {
    ...
    default.clock.allowed-rates = [ sample_rate_1 sample_rate_2 sample_rate_3 ... ]
    ...

for example, [ 44100 48000 88200 96000 ]. Consult your hardware manual for supported values of your DAC.

According to the developer here,PipeWire allows up to 16 different sample rate and switch when possible. That means, with configuration above, no resampling is done when supported.

To check out which output sample rate and sample format are the data sent to DAC (probably you need to change digits):

$ cat /proc/asound/card0/pcm0p/sub0/hw_params

To check out which input sample rate is used, change pcm0p to pcm0c (c is short for "capture", p is for "playback").

Sound quality (resampling quality)

If you used PulseAudio with resample-method = speex-float-10 or soxr-vhq, then you might consider uncommenting and changing resample.quality = 4 to 10 or the maximum 15 in stream.properties block in both /etc/pipewire/client.conf and /etc/pipewire/pipewire-pulse.conf (copy them from /usr/share/pipewire/ if they do not exist). Do not forget to restart the pipewire.service and pipewire-pulse.socket user units (never forget pipewire-pulse.socket if you want your configuration changes to be applied).

There is a very little quality difference between 10 and 15, but the CPU load difference is 2-3x. And the latency difference between 4, 10, 15 is yet to be investigated by anybody. resample.quality = 15 on 44100→48000 Hz on Ryzen 2600 causes pipewire or pipewire-pulse processes to cause 4.0% one CPU core load.

You can compare resamplers here: https://src.infinitewave.ca/ (do not pay attention to anything above 18 KHz and over 120 dB). speex is listed as "Xiph.org Speex".

PipeWire uses its own resampling algorithm called Spa. Like with SoX's sox, Speex's speexenc, PipeWire includes its standalone version: spa-resample. Usage:

$ spa-resample -q 15 -f s24 -r 48000 input16bit44100orAnythingElse.wav output24bit48000hz.wav

It is probably somehow possible to use other resamplers by creating your own sink. Or just use a plugin in your music player (e.g., Qmmp has SoX plugin).

External sound card not activated after reconnect

Check ~/.config/pipewire/media-session.d/default-profile if there is any entry with default profile "off" and remove it. If that does not help, remove all files from ~/.config/pipewire/media-session.d/ and restart the pipewire.service user unit.

No Sound or pactl info shows Failure: Connection refused

It means applications are unable to connect to the PipeWire-Pulse service, confirm that /etc/pipewire/pipewire-pulse.conf exists and is not empty and restart the pipewire-pulse.service user unit.

If that does not fix it, run strace -f -o /tmp/pipe.txt pactl info and pastebin /tmp/pipe.txt while seeking help on IRC (#pipewire on OFTC) or the mailing-lists.

Low audio quality on Bluetooth

In case Bluetooth playback stutters, check the unit status of the pipewire.service user unit for errors similar as below:

Feb 17 18:23:01 HOST pipewire[249297]: (bluez_input.18:54:CF:04:00:56.a2dp-sink-60) client too slow! rate:512/48000 pos:370688 status:triggered

If they appear, check the currently selected codec using pactl list sinks and try changing it by setting bluez5.codecs to one of sbc aac ldac aptx aptx_hd. You can also try mSBC support (fixes mic on Sony 1000XM3, i.e. Headphones WH-1000XM3 and Earbuds WF-1000XM3), and the SBC-XQ codec.

With pipewire-media-session:

/etc/pipewire/media-session.d/bluez-monitor.conf (or ~/.config/pipewire/media-session.d/bluez-monitor.conf)
...
properties = {
  ...
  bluez5.enable-msbc = true
  bluez5.enable-sbc-xq = true
  bluez5.codecs = [sbc sbc_xq]
...

With wireplumber:

/etc/wireplumber/bluetooth.lua.d/51-bluez-config.lua (or ~/.config/wireplumber/bluetooth.lua.d/51-bluez-config.lua)
bluez_monitor.properties = {
  ["bluez5.enable-sbc-xq"] = true,
  ["bluez5.enable-msbc"] = true,
  ["bluez5.codecs"] = "[sbc sbc_xq]",
}

Restart PipeWire by restarting the pipewire.service user unit for the changes to take effect.

Noticeable audio delay or audible pop/crack when starting playback

This is caused by node suspension when inactive. If you are using pipewire-media-session, you can disable this by editing /etc/pipewire/media-session.d/*-monitor.conf depending on where the delay occurs and changing property session.suspend-timeout-seconds to 0 to disable or to experiment with other values and see what works. Alternatively you can comment out the line suspend-node in /etc/pipewire/media-session.d/media-session.conf. Restart both the pipewire and pipewire-pulse systemd services to apply these changes, or alternatively reboot.

If you are using wireplumber instead of pipewire-media-session, then you can copy the example configuration file located at /usr/share/wireplumber/main.lua.d/50-alsa-config.lua to /etc/wireplumber/main.lua.d/50-alsa-config.lua or ~/.config/wireplumber/main.lua.d/50-alsa-config.lua and add the line ["session.suspend-timeout-seconds"] = 0 to section apply_properties at the end of the file. Instead of disabling suspension entirely, you can change the timeout value by copying the file /usr/share/wireplumber/scripts/suspend-node.lua to /etc/wireplumber/scripts/suspend-node.lua or ~/.config/wireplumber/scripts/suspend-node.lua and changing the 5 in tonumber(node.properties["session.suspend-timeout-seconds"]) or 5 to the desired number of seconds to delay before source suspension.

Audio cutting out when multiple streams start playing

This problem can typically be diagnosed by reading the journal of the pipewire-pulse.service user unit and finding lines similar to:

pipewire-pulse[21740]: pulse-server 0x56009b9d5de0: [Nightly] UNDERFLOW channel:0 offset:370676 underrun:940

According to the official PipeWire troubleshooting guide, to solve this problem edit /etc/pipewire/media-session.d/alsa-monitor.conf, uncomment the line saying api.alsa.headroom = 0 and change its value to 1024.

If you are using wireplumber instead of pipewire-media-session, then you can copy the example configuration file located at /usr/share/wireplumber/main.lua.d/50-alsa-config.lua to /etc/wireplumber/main.lua.d/50-alsa-config.lua and at the end of the file, under section apply_properties, change --["api.alsa.headroom"] = 0 to ["api.alsa.headroom"] = 1024

Audio is distorted

  • For microphones, try navigating to the card that is having issues after running alsamixer and use the arrow keys to reduce any "Mic Boost" or "Internal Mic Boost" options.
  • Follow #Changing the default sample rate, reducing the sample rate to to 44100 (44.1 kHz).

Audio problems after standby

If the sound is missing or otherwise garbled after waking the machine up from sleep, it might help to reinitialize ALSA:

# alsactl init

High latency with USB DACs (e.g. Schiit DACs)

Changing sample rates or formats might help reduce latency with some DACs such as Schiit Hel 2.[9] Using matching rules in pipewire-media-session we can set properties for devices.[10]

Copy the default configuration of alsa-monitor.conf for pipewire-media-session into either /etc/pipewire/media-session.d or ~/.config/pipewire/media-session.d. Then append a new rule-block similar to the following one:

/etc/pipewire/media-session.d/alsa-monitor.conf (or ~/.config/pipewire/media-session.d/alsa-monitor.conf)
...
rules = {
    ...
    {
        matches = [
            {
                node.name = "alsa_output.<name of node>"
            }
        ]
        actions = {
            update-props = {
                audio.format = "S24_3LE"
                audio.rate = 96000
                # Following value should be doubled until audio doesn't cut out or other issues stop occurring
                api.alsa.period-size = 128
...

alsa_output.<name of node> node can be obtained using pw-top.

Your DAC might support a different format or sample rate. You can check what your DAC supports by querying ALSA:

First get the card number of your DAC:

$ aplay -l
...
card 3: S2 [Schiit Hel 2], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
...

So in this example it would be card 3. Get all supported sample rates and formats:

$ cat /proc/asound/cardX/streamX
...
Playback:
  ...
  Interface 1
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 0x05 (5 OUT) (ASYNC)
    Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
    Data packet interval: 125 us
    Bits: 16
    ...
  Interface 1
    Altset 2
    Format: S24_3LE
    Channels: 2
    Endpoint: 0x05 (5 OUT) (ASYNC)
    Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
    Data packet interval: 125 us
    Bits: 24
    ...
  Interface 1
    Altset 3
    Format: S32_LE
    Channels: 2
    Endpoint: 0x05 (5 OUT) (ASYNC)
    Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000
    Data packet interval: 125 us
    Bits: 32
    ...
...

In this case S16_LE, S24_3LE, S32_LE are the supported formats and 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 are the supported sample rates across all formats.

Realtime audio does not work

If RTKit error: org.freedesktop.DBus.Error.AccessDenied shows up in the status of the pipewire.service user unit, then the priority of the pipewire daemon was not changed to realtime. See [11] for this issue.

Simultaneous output to multiple sinks on the same sound card

Create a copy of /usr/share/alsa-card-profile/mixer/profile-sets/default.conf so that changes persist across updates. Here we define a profile joining the two default mappings for Analog and HDMI.

/usr/share/alsa-card-profile/mixer/profile-sets/multiple.conf
[General]
auto-profiles = no

[Mapping analog-stereo]
device-strings = front:%f
channel-map = left,right
paths-output = analog-output analog-output-lineout analog-output-speaker analog-output-headphones analog-output-headphones-2
paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
priority = 15

[Mapping hdmi-stereo]
description = Digital Stereo (HDMI)
device-strings = hdmi:%f
paths-output = hdmi-output-0
channel-map = left,right
priority = 9
direction = output

[Profile multiple]
description = Analog Stereo Duplex + Digital Stereo (HDMI) Output
output-mappings = analog-stereo hdmi-stereo
input-mappings = analog-stereo

Now we configure PipeWire's media-session to use the new card-profile for matching devices. Identifying information can be found using $ pw-cli dump device.

/etc/pipewire/media-session.d/alsa-monitor.conf
rules = [
    {
        matches = [ { alsa.card_name = "HDA Intel PCH" } ]
        actions = {
            update-props = {
                api.alsa.use-acp = true
                device.profile-set = "multiple.conf"
                device.profile = "multiple"
                api.acp.auto-profile = false
                api.acp.auto-port = false
            }
        }
    }
]

No notification sounds from Discord

This might cause by having the min.quantum too low, try setting it to more than 700. You can make an override for Discord specifically by appending the following rule to the pulse.rules section of pipewire-pulse.conf.

/etc/pipewire/pipewire-pulse.conf (or ~/.config/pipewire/pipewire-pulse.conf)
...
pulse.rules = [
  ...
    {
        # Discord notification sounds fix
        matches = [ { application.process.binary = "Discord" } ]
        actions = {
            update-props = {
                pulse.min.quantum      = 1024/48000     # 21ms
            }
        }
    }
...

Video

OBS (etc.) display nothing, even if they ask for a window/screen

If you are sure that you have xdg-desktop-portal installed as well as either xdg-desktop-portal-gtk or xdg-desktop-portal-kde, check the running state of the daemons.

In OBS, if everything is working, you should see this in stdout:

...
info: [pipewire] desktop selected, setting up screencast
info: [pipewire] created stream 0x5632d7456850
info: [pipewire] playing stream…

For multi-monitor setups the slurp package will allow to capture of all the screens.

參閱