https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Asternova&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T08:32:47ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=PipeWire&diff=18834PipeWire2021-04-10T21:15:03Z<p>Asternova: Outline XDG_RUNTIME_DIR that's required by pipewire</p>
<hr />
<div>{{Draft|The instructions below have not been thoroughly tested and may break things.}}<br />
<br />
[https://pipewire.org/ PipeWire] is a multimedia processing engine that aims to improve audio and video handling on Linux.<br />
<br />
== Prerequisites ==<br />
<br />
=== Audio Group ===<br />
<br />
Add your normal user to the <code>audio</code> group. The user must log in for this to take effect.<br />
<br />
<pre><br />
# addgroup audio <user><br />
</pre><br />
<br />
=== D-Bus ===<br />
<br />
PipeWire requires a running [https://www.freedesktop.org/wiki/Software/dbus/ D-Bus] session. If you use a full desktop environment this will probably be started automatically, but with minimal window managers it must be done manually.<br />
<br />
<pre><br />
# apk add dbus dbus-openrc dbus-x11<br />
# rc-service dbus start<br />
# rc-update add dbus default<br />
</pre><br />
<br />
Then use <code>dbus-launch</code> whenever you start an X or Wayland session. For example:<br />
<pre><br />
$ dbus-launch --exit-with-session sway<br />
</pre><br />
<br />
=== XDG_RUNTIME_DIR ===<br />
<br />
If you are not using a Desktop Manager, ensure that your <code>XDG_RUNTIME_DIR</code> is set to a user-writable location. By default for pulseaudio this is <code>/run/user/1000/</code> or <code>/tmp</code>. If this is not set, pipewire will create a directory in your home folder instead, called <code>~/pulse</code>, and on attempting to run Pavucontrol or pactl, you will get the following error:<br />
<br />
<pre><br />
$ pactl list<br />
Connection failure: Connection refused<br />
pa_context_connect() failed: Connection refused<br />
</pre><br />
<br />
== Installation and configuration ==<br />
<br />
<pre><br />
# apk add pipewire<br />
</pre><br />
<br />
Uncomment the following line in <code>/etc/pipewire/pipewire.conf</code>:<br />
<br />
<pre><br />
{ path = "/usr/bin/pipewire-media-session" args = "" }<br />
</pre><br />
<br />
Enable the <code>snd_seq</code> kernel module for ALSA support.<br />
<br />
<pre><br />
# modprobe snd_seq<br />
# echo snd_seq >> /etc/modules<br />
</pre><br />
<br />
=== PulseAudio ===<br />
<br />
PipeWire can run a [https://www.freedesktop.org/wiki/Software/PulseAudio/ PulseAudio] daemon which should allow all existing PulseAudio applications to be used with the PipeWire backend.<br />
<br />
<pre><br />
# apk add pipewire-pulse<br />
</pre><br />
<br />
To enable the PulseAudio daemon edit <code>/etc/pipewire/pipewire.conf</code> and uncomment the following line:<br />
<br />
<pre><br />
{ path = "/usr/bin/pipewire" args = "-c pipewire-pulse.conf" }<br />
</pre><br />
<br />
=== JACK ===<br />
<br />
If you will be using PipeWire for [https://jackaudio.org/ JACK] applications install the required package and make system wide links to the PipeWire replacement JACK libraries (I have not had success using <code>pw-jack</code>). You will not need to start a JACK server.<br />
<br />
<pre><br />
# apk add pipewire-jack<br />
# ln -sf /usr/lib/pipewire-0.3/jack/libjackserver.so.0 /usr/lib/libjackserver.so.0<br />
# ln -sf /usr/lib/pipewire-0.3/jack/libjacknet.so.0 /usr/lib/libjacknet.so.0<br />
# ln -sf /usr/lib/pipewire-0.3/jack/libjack.so.0 /usr/lib/libjack.so.0<br />
</pre><br />
<br />
{{Note|These symlinks might be overwritten during updates.}}<br />
<br />
=== Video ===<br />
<br />
Video should work out-of-the-box with v4l2 devices (e.g. a lot of webcams) and [https://gstreamer.freedesktop.org/ GStreamer] applications.<br />
<br />
=== Screen sharing on Wayland ===<br />
<br />
You will need the right [https://github.com/flatpak/xdg-desktop-portal xdg-desktop-portal] backend for your desktop environment. Screen sharing is known to work on GNOME with <code>xdg-desktop-portal-gtk</code> and on KDE Plasma with <code>xdg-desktop-portal-kde</code> and Firefox.<br />
<br />
== Usage ==<br />
<br />
Start the PipeWire media server. You'll probably get quite a few errors but just ignore them for now.<br />
<br />
<pre><br />
$ pipewire<br />
</pre><br />
<br />
In a different terminal window check the default output device. I don't yet know how this default can be changed for all applications, so you'd better hope it's right!<br />
<br />
<pre><br />
$ pw-cat -p --list-targets<br />
</pre><br />
<br />
Test sound is working using an audio file in a format supported by [http://www.mega-nerd.com/libsndfile/ libsndfile] (e.g. flac, opus, ogg, wav).<br />
<br />
<pre><br />
$ pw-cat -p test.flac<br />
</pre><br />
<br />
If you have a microphone test recording audio is working.<br />
<br />
<pre><br />
$ pw-cat -r --list-targets<br />
$ pw-cat -r recording.flac<br />
(Speak for a while then stop it with Ctrl+c)<br />
$ pw-cat -p recording.flac<br />
</pre><br />
<br />
Test PulseAudio clients using a media player (most use PulseAudio) and if you use JACK test that too:<br />
<br />
<pre><br />
# apk add jack-example-clients<br />
$ jack_simple_client<br />
</pre><br />
<br />
You should hear a sustained beep.<br />
<br />
If you are happy everything is working, make PipeWire start automatically when your X or Wayland session starts. For example, you could add the <code>pipewire</code> command to <code>~/.xinitrc</code> or your window manager's config file.<br />
<br />
== See Also ==<br />
<br />
* [https://gitlab.freedesktop.org/pipewire/pipewire PipeWire source repository]<br />
* [https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/home PipeWire Wiki]<br />
* [https://wiki.archlinux.org/index.php/PipeWire PipeWire on the ArchWiki]<br />
* [https://wiki.gentoo.org/wiki/Pipewire PipeWire on the Gentoo Wiki]<br />
<br />
[[Category:Multimedia]]</div>Asternova