2 title: PipeWire / WirePlumber
5 # PipeWire / WirePlumber
9 AGL uses the PipeWire daemon service to provide audio playback and capture capabilities.
10 PipeWire is accompanied by a secondary service, WirePlumber (also referred to as the
11 *session manager*), which provides policy management, device discovery, configuration and more.
13 Applications can connect to the PipeWire service through its UNIX socket, by using either the
14 *libpipewire* or *libwireplumber* libraries as a front-end to that socket.
16 Upstream documentation for these components can be found at the links below:
18 - [PipeWire documentation](https://docs.pipewire.org/)
20 - [WirePlumber documentation](https://pipewire.pages.freedesktop.org/wireplumber/)
22 - [PipeWire Wiki](https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/home)
28 The main entry point for applications to access the audio system is the API offered by
29 *libpipewire*. The functionality offered by *libpipewire* is vast and it is beyond the
30 scope of this document to describe it all.
32 For playback and capture, applications should use *struct pw_stream* and its associated methods.
33 See [PipeWire: Tutorial - Part 4: Playing a tone](https://docs.pipewire.org/page_tutorial4.html)
36 ### GStreamer (Recommended)
38 For convenience, applications that use GStreamer can use the PipeWire GStreamer elements to
39 plug the functionality offered by *struct pw_stream* directly in the GStreamer pipeline. These
40 elements are called *pipewiresrc* and *pipewiresink*
45 > gst-launch-1.0 audiotestsrc ! pipewiresink
48 Through these elements, it is possible to specify the application role by setting it in the
49 *stream-properties* property of the element, as shown below:
52 > gst-launch-1.0 audiotestsrc ! pipewiresink stream-properties="p,media.role=Multimedia""
58 gst_util_set_object_arg (sink, "stream-properties", "p,media.role=Multimedia");
61 Of course, it is also possible to use *alsasink* and *alsasrc* and route audio through the
62 virtual ALSA device that is mentioned below. This is also the default behavior of *playbin*
63 and similar auto-plugging elements, because the PipeWire GStreamer elements are not autoplugged
64 (this may change in a future version).
68 PipeWire offers a virtual ALSA device (called *pipewire*) that redirects audio to PipeWire
69 through an ALSA PCM plugin. This device is the default one, so unless you explicitly specify
70 a device in your ALSA client application, audio will go through PipeWire instead.
75 > aplay sound.wav # the default device is 'pipewire'
76 > aplay -D pipewire sound.wav
79 In order to specify the application role while using the ALSA compatibility device, pass the role
80 as a device parameter like this:
83 > aplay -D pipewire:ROLE=Navigation turnleft.wav
86 ### Audiomixer service
88 See the separate [agl-service-audiomixer](https://git.automotivelinux.org/apps/agl-service-audiomixer/about/) documentation.
92 The WirePlumber library provides API that wraps libpipewire and makes it easier to work with
93 when you are writing control applications, such as a volume mixer. The audiomixer service is in
94 fact implemented using *libwireplumber*.
96 WirePlumber also provides support for lua-based scripting. Standalone scripts, executed with the
97 *wpexec* tool, may be used as a means to rapidly make use of the API provided by *libwireplumber*
101 * **wpctl**: allows inspecting the devices, choosing which source & sink are the default ones
102 and allows volume/mute adjustments to be made on the command line. Try `wpctl status` and
103 `wpctl help` to get started with it
105 * **wpexec**: allows running wireplumber lua scripts standalone, which is useful to implement
106 custom scripts to interact with PipeWire
108 * **pw-cli**: this is the main tool for interacting with pipewire directly
110 * **pw-dump**: dumps all the objects in the pipewire graph to a big JSON. The output of this
111 tool is very useful to include in bug reports. It is also suitable for implementing scripts
112 that parse information with jq
114 * **pw-dot** is a useful debug tool that dumps the objects in a dot graph for easy visualization
116 * **pw-cat / pw-play / pw-record**: This is a set of tools similar to aplay/arecord, for simple
119 * **pw-top**: This is a performance measurement tool that shows realtime timing information
120 about the audio pipeline. Before running this tool, you will need to uncomment the loading
121 of "libpipewire-module-profiler" in /etc/pipewire/pipewire.conf and restart pipewire
123 ## Systemd Integration
125 The PipeWire service, `pipewire.service`, is activated on demand, via systemd socket activation,
126 by `pipewire.socket`. The WirePlumber service, `wireplumber.service`, is bound to the pipewire
127 service and therefore started and stopped together with the PipeWire service.
129 If you wish to manually stop or restart both services, you can do so by using *systemctl*,
130 operating on the *.socket* unit:
133 > systemctl restart pipewire.socket
134 > systemctl stop pipewire.socket
139 The PipeWire daemon can be configured to be more verbose by editing
140 **/etc/pipewire/pipewire.conf** and setting `log.level=n` (n=0-5) in section
141 `context.properties`.
143 Similarly, the WirePlumber daemon can be configured to be more verbose by editing
144 **/etc/wireplumber/wireplumber.conf** and setting `log.level=n` (n=0-5) in section
145 `context.properties`.
147 All messages will be available in the systemd journal, inspectable with journalctl.
149 For applications, at runtime, `PIPEWIRE_DEBUG` can be set to a value between 0 and 5,
150 with 5 being the most verbose and 0 the least verbose.
152 For applications that use *libwireplumber* the equivalent environment variable is
153 `WIREPLUMBER_DEBUG`, which also takes values between 0 and 5.
155 The default debug level for the daemons is 2, while for applications it's 0
156 (with few exceptions).
158 More information is also available on
159 [WirePlumber's documentation on debug logging](https://pipewire.pages.freedesktop.org/wireplumber/daemon-logging.html)