PipeWire: Difference between revisions
Describe how to turn off sound for X11 urgency hints as an example for extraConfig |
m removing excess braces around example |
||
| (8 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
[https://www.pipewire.org/ PipeWire] is a relatively new (first release in 2017) low-level multimedia framework. It aims to offer capture and playback for both audio and video with minimal latency | [https://www.pipewire.org/ PipeWire] is a relatively new (first release in 2017) low-level multimedia framework. It aims to offer capture and playback for both audio and video with minimal latency while retaining support for [[PulseAudio]]-, [[JACK]]-, [[ALSA]]-, and [[GStreamer]]-based applications. PipeWire has great [[Bluetooth]] support; due to Pulseaudio being [https://github.com/NixOS/nixpkgs/issues/123784 reported to have troubles with Bluetooth], PipeWire may be a good alternative. | ||
The daemon based on the framework can be configured to be both an audio server (with PulseAudio and JACK features) | The daemon based on the framework can be configured to be both an audio server (with PulseAudio and JACK features) as well as a video capture server. | ||
PipeWire also supports containers | PipeWire also supports containers such as [[Flatpak]] and does not rely on <code>audio</code> and <code>video</code> user groups, rather it uses a [[Polkit]]-like security model, asking Flatpak or [[Wayland]] for permission to record the screen or audio. | ||
As of [https://nixos.org/manual/nixos/stable/release-notes#sec-release-24.11 NixOS 24.11], PipeWire is the default sound server for most graphical sessions. | As of [https://nixos.org/manual/nixos/stable/release-notes#sec-release-24.11 NixOS 24.11], PipeWire is the default sound server for most graphical sessions. | ||
| Line 132: | Line 132: | ||
* {{nixos:package|carla}}: with JACK emulation, provides a patchbay (make sure to go to "Patchbay" tab and check "Canvas > Show External"). | * {{nixos:package|carla}}: with JACK emulation, provides a patchbay (make sure to go to "Patchbay" tab and check "Canvas > Show External"). | ||
* catia/{{nixos:package|patchage}}: similar to qjackctl and carla. | * catia/{{nixos:package|patchage}}: similar to qjackctl and carla. | ||
* {{nixos:package| | * {{nixos:package|pwvucontrol}}: Similar to pavucontrol but for pipewire | ||
==Advanced Configuration== | ==Advanced Configuration== | ||
| Line 281: | Line 281: | ||
Despite early activation, you may still experience a race condition that prevents audio from working if you play media immediately after a new login such as running an SSH command. If this occurs, try introducing a short delay (e.g. <code>sleep 5</code>) before invoking the media player application. | Despite early activation, you may still experience a race condition that prevents audio from working if you play media immediately after a new login such as running an SSH command. If this occurs, try introducing a short delay (e.g. <code>sleep 5</code>) before invoking the media player application. | ||
==== System-wide PipeWire ==== | |||
As an alternative to having lingering systemd user services, PipeWire can also run as a system-wide Systemd service. See {{nixos:option|services.pipewire.systemWide}} for more. | |||
{{file|/etc/nixos/configuration.nix|nix|3= | |||
services.pipewire.systemWide = true; | |||
services.pipewire.pulse.enable = true; # pipewire-pulse also supports running system-wide | |||
# PipeWire users must be in the `pipewire` group | |||
users.users.myservice1.extraGroups = [ "pipewire" ]; | |||
systemd.services.myservice2.serviceConfig.SupplementaryGroups = [ "pipewire" ]; | |||
}} | |||
=== Setting default sink volume via wireplumber === | |||
It's possible to declare your desired volume through {{nixos:option|services.pipewire.wireplumber.extraConfig}} by setting [https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/configuration_option_types.html wireplumber.settings]'s [https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/settings.html default-sink-volume]:<syntaxhighlight lang="nix"> | |||
services.pipewire.wireplumber = { | |||
extraConfig = { | |||
"10-default-volume" = { | |||
"wireplumber.settings"."device.routes.default-sink-volume" = 0.8; # default is 0.4 | |||
}; | |||
}; | |||
}; | |||
</syntaxhighlight> | |||
==Troubleshooting== | ==Troubleshooting== | ||
| Line 364: | Line 389: | ||
This configuration prevents audio popping and keeps the audio pipeline active, effectively reducing startup delay from ~5s to ~1s. Adding the dither settings further eliminates the remaining delay. | This configuration prevents audio popping and keeps the audio pipeline active, effectively reducing startup delay from ~5s to ~1s. Adding the dither settings further eliminates the remaining delay. | ||
</li> | </li> | ||
</ol> | |||
=== Audio Crackling Fix=== | |||
Increasing buffer size for the audio will reduce crackling but increase latency. | |||
More details can be found in [https://docs.pipewire.org/page_man_pipewire_conf_5.html pipewire docs] and [https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/alsa.html wireplumber docs] | |||
<syntaxhighlight lang="nix"> | |||
services.pipewire.enable = true; | |||
services.pipewire.extraConfig.pipewire = { | |||
"98-crackling-fix" = { | |||
"context.properties" = { | |||
"default.clock.quantum" = 1024; | |||
"default.clock.min-quantum" = 1024; | |||
"default.clock.max-quantum" = 8192; | |||
}; | |||
}; | |||
}; | |||
# additional fix for very bad devices or VM. | |||
services.pipewire.wireplumber.extraConfig = { | |||
"99-crackling-fix" = { | |||
"api.alsa.period-size" = 1024; | |||
"api.alsa.headroom" = 8192; | |||
}; | |||
}; | |||
</syntaxhighlight> | |||
==See also== | ==See also== | ||