Pipewire

From Gentoo Wiki
Jump to:navigation Jump to:search

Pipewire is a low-latency and graph-based processing engine and a server for interfacing with audio and video devices that can be used to support use cases currently handled by ALSA, OSS, PulseAudio and/or JACK.

Some key features include:

  • Minimal latency capture/playback of audio and video;
  • Real-time multimedia processing;
  • Multi-process architecture allowing multimedia content sharing between applications;
  • Seamless support for PulseAudio, JACK, ALSA, and GStreamer; and
  • "Sandboxed" applications support with Flatpak.

Installation

USE-Flags

USE flags for media-video/pipewire Multimedia processing graphs

X Add support for X11
bluetooth Enable Bluetooth Support
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
ffmpeg Enable ffmpeg/libav-based audio/video codec support
gstreamer Add support for media-libs/gstreamer (Streaming media)
jack Enable SPA JACK plugin and emulation to be able to run JACK applications on top of PipeWire
pulseaudio Enable emulation to be able to run PulseAudio applications on top of PipeWire
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
vulkan Enable vulkan spa plugin integration

Emerge

root #emerge --ask media-video/pipewire

Configuration

Pipewire configuration is managed via system-wide settings or user launch options. The following command edits the system-wide configuration file:

root #vim /etc/pipewire/pipewire.conf

Session Manager (pipewire-media-session)

TBD

Systemd

Pipewire provides a socket and a service file when built with the systemd USE flag. The following systemctl commands activate systemd's management of the Pipewire connections:

user $systemctl --user status pipewire.socket
user $systemctl --user status pipewire.service

OpenRC or other

The user must ensure there is a viable D-Bus session active:

FILE ~/.xinitrc
if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
       eval `dbus-launch --sh-syntax --exit-with-session`
fi

The user must ensure that XDG_RUNTIME_DIR is set. This is usually managed by a systemd-specific Pluggable Authentication Module and the logind service. Likewise elogind should manage the creation.

If not, the user must create the require directory and set the environmental variable

#-- ensure XDG_Runtime_dir is set 
if test -z "${XDG_RUNTIME_DIR}"; then
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  if ! test -d "${XDG_RUNTIME_DIR}"; then
    mkdir "${XDG_RUNTIME_DIR}"
    chmod 0700 "${XDG_RUNTIME_DIR}"
    export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  fi
fi



The Pipewire executable must also be called:

FILE ~/.xinitrc
/usr/bin/pipewire

Replacing PulseAudio

To have Pipewire to act as a PulseAudio service, un-comment the pipewire-pulse line in the main configuration file:

FILE /etc/pipewire/pipewire.conf
#
# You can optionally start the pulseaudio-server here as well
# but it better to start it as a systemd service.
# It can be interesting to start another daemon here that listens
# on another address with the -a option (eg. -a tcp:4713)
#
exec /usr/bin/pipewire-pulse

A reboot/logout is required for the change to take effect.

Testing

To check whether Pipewire is now acting as the PulseAudio service, use the pactl command:

user $pactl info
...

Server Name: PulseAudio (on PipeWire 0.3.17)

...

Fixes and workarounds

CSGO (other source-based games)

The default sound buffer length is 0.025. This can sometimes be too low causing cracking audio. Pulseaudio automatically increases the buffersize. It is undecided whether Pipewire will in future automatically increase the buffer length

for now, the workaround is to increase the size of the buffer from within CSGO[1][2]

snd_mixahead is the length of the sound buffer in seconds, so 0.05 is 50ms (0.10, edited: 25ms is the default). This is essentially the audio delay, so reducing it gives better synchronization. Not all hardware can handle this low of a buffer setting though, so if you hear any crackling or pops at 0.05, increase this setting by 0.01 until the crackling/pops disappear.


See also

  • Pulseaudio — a sound server that provides a number of features on top of the low-level audio interface ALSA on Linux
  • ALSA — describes the setup of a sound card with ALSA (Advanced Linux Sound Architecture).

References