PipeWire: A year in review and a look ahead
collabora.com
collabora.com
It's impressive how it manages to support connections that require reclocking and do the needed large ratio resampling needed behind the scenes, something that PulseAudio was never really able to do. It's also nice for monitoring while streaming and seems to have much lower latency than OBS's monitoring.
Sound has been an absolute disaster area on Linux for decades and it seems like the Pipewire guys just flat out solved it. (I would say "suddenly", but Wim Taymans has been working on this directly for almost 7 years and worked on Gstreamer before it)
What did they do so much better and differently?
Another thing that helps is that in some ways PipeWire is less featureful than PA. For example, it limits the max audio buffer size to ~180ms which means it doesn't have to implement rewinds, one of the buggier features of PA (with the downside that power consumption can't ever be quite as low as PA).
I want to visualize all of these dependencies as a graph, instead of trying to hamstring things together with CLI invocations. Editing the graph would invoke the package manager.
[1]: https://guix.gnu.org/manual/en/html_node/Invoking-guix-graph...
You will also need to use your package manager's method of marking all packages as "automatically installed" except for your system package. How easy this is depends on the package manager. Eg for Alpine's apk this is trivial, because all packages are "automatically installed" unless they're listed in /etc/apk/world, but for OpenSUSE's zypper you need to update /var/lib/zypp/AutoInstalled to include every installed package and periodically refresh it when zypper decided to switch an automatically-installed package to manually-installed for some reason.
There is a lot of REALLY good software coming out for Desktop Linux recently. Wayland, Pipewire, Wireguard, etc!
etc indeed:
OBS Studio VLC Ardour, LMMS, MuseScore
LibreOffice (Writer, Calc, Impress, Draw, Base) GnuCash, Scribus, Dark Table, Inkscape, Krita, Blender, Synfig Studio, Gimp KiCAD, LibreCAD, FreeCAD, OpenScad, Solvespace, Slic3er
And untold others that are incredibly useful.
Not to mention the drastically lower CPU usage compared to its predecessor [1] and general lack of bugs.
> There is a lot of REALLY good software coming out
Agreed, but I would still single out PipeWire as being particularly outstanding. None of the other examples are as new, or as uncontroversial. Anecdotically, when I look at the comment section of any PipeWire article here, I see basically universal (and enthusiastic) praise.
In my case, it comes from the fact that so many sound servers have existed before, and none were even close to satisfactory, until now. It seems genuinely like a hard problem.
One is the audio sometimes randomly jitters while simply playing music. It seems this only happens when I use my bluetooth headset, but is fine with built-in audio.
The other is, when the automatic switching to bluetooth headset is hit and miss. Sometimes it switches, sometimes it doesn't, and sometimes one applications switch, but others don't. So I'm left to use pavucontrol to switch things over correctly.
My searches haven't returned any fruitful results so I'm not if I'm just searching for the wrong things or I'm the only person who has these issues.
https://wiki.archlinux.org/title/PipeWire#Sound_does_not_aut...
It's one of the best resources out there, though obviously if you're not running arch you'll need to tweak things from the suggestions.
I encounter the same issue from time to time. Almost consistently reproducible when I update the kernel and the VirtualBox driver needs to be recompiled (and there's no cap for that process that it should use max X% of CPU).
As pipewire is within the user session I would assume higher system load would induce some latency and cause the jitterness.
But in the end I'm just making assumptions, and correlating.
https://gist.github.com/abdullahkhalids/21a51240c13e19bfbb63...
I have bound Win+Home to the "general" option that connects to my earphones and correctly lets all applications use them as their sink.
I never really got good with pactl or the various other interfaces, so while it's great that Pipewire is compatible with them, I was also hoping that Pipewire would mean I never needed to get comfortable with them.
If I have any criticism of Pipewire, it's that as someone who is not really interested in learning all of the quirks and weirdness of the old systems and would happily never really learn those systems except for older compatibility reasons, it's slightly weird to be running Pipewire and have all the tutorials that I've run into around it still start with, "let's learn some Pulseaudio commands".
pw-dump | jq '
(
.[] |
select(.type == "PipeWire:Interface:Metadata") |
(.metadata // [])[] |
select(.key == "default.audio.sink") |
.value.name
) as $default_sink_node_name |
.[] |
select(.info.props["node.name"] == $default_sink_node_name) as $default_sink_node |
.
'BTW, you may consider using `Cow<'a, str>` instead of `&'a str` for the deserialized fields. For JSON strings that have escapes, serde can't deserialize them into a `&'a str`, so the whole deserialization will fail. `Cow<'a, str>` still works with `#[serde(borrow)]` in that strings that can be deserialized in-place will be the `Borrowed(&'a str)` variant, and only strings that can't will be `Owned(String)` (there's a special borrow-specific deserializer of Cow inside serde to achieve this).
There doesn't seem to be ANY public documentation on the pipewire API protocol. There's just docs for the C bindings, but lack of protocol documentation is a bit worrying, since none of us can write tools that talk to the server. A LOT of documentation pages are literally empty (just a title an nothing else). This includes the documentation for the native protocol, in case you wanted to write your own client: https://docs.pipewire.org/page_module_protocol_native.html
Apparently, reverse engineering the client/server implementations is the way to go right now.
I'm certain this has something to do with me doing a bad install and not cleaning up old config files or something, possibly with either me either using PulseWire or not using PulseWire to manage the session, but it's pretty annoying (although apparently not annoying enough to get me to debug the issue).
Otherwise, it seems to basically just work. I'd love to do more with it, but truthfully I didn't really dig into Pulse/Alsa/Jack enough initially to really notice what the benefits are, so I can't tell a difference.
One thing I'd love is for a cleaner command-line interface to handle sinks, particularly when scripting. I'm sure if I took the time I'd understand them, but I find PulseAudio's sinks really annoying to work with and to manipulate. Again, I think this is mostly just the fact that I never really dug into Linux audio too deeply before so I'm not always completely sure what's going on with it, and I'm not doing anything complicated enough for me to immediately tell a difference. In some ways I guess that's a recommendation; if I managed to get the hibernation bug fixed then this would be a totally transparent switch from my perspective. That seems kind of impressive.
I currently use Pulseaudio to send audio from my laptop to a raspberry (with a DAC hat) connected to my hifi, but it turns out it's a pretty niche use case. So I'm looking for anybody with a similar use case who has upgraded from PA to PW and can talk about the experience.
The most realistic option I have found would be to use NetJack, but while its been noted in a roadmap as a relatively straightforward protocol, it is not yet implemented (at least, it wasn't last time i looked).
It may be possible to hack a pipewire-jack client to do it now... but that seems like more effort than its worth.
An alternative would be Scream, if all you want is one-way streaming.
If anyone has any other ideas, i would be very much interested too!
Got it running on a Pi+DAC & use spotify connect mostly, but occasionally throw stuff from my NAS on to it.
I've done quite a bit of streaming in the past with pulseaudio-dlna and the extreme lag isn't fantastic.
https://gavv.github.io/articles/roc-tutorial/
I'm also curious about using PW, I upgraded, but I haven't setup any streaming yet.
The only problem I had with my setup was when I changed my router to a Mikrotik hap ac2 - there was a lot of stuttering and dropouts. After switching to OpenWRT on the Mikrotik, everything became usable again :)
ssh -R /run/user/1000/pulse/native:/run/user/1000/pulse/native remote_host ...
assuming the SSH client is the one with the audio device and remote_host is the one that wants to play audio. If it's the other way around then replace -R with -L.I do this "into" a RDP session in a VM on the same machine (because RDP audio is really really bad) and both of the above tools worked really well for me.
This is my pipewire config, does the job perfectly for me, tracking unstable.
You can detect when they're h264 and use - c:v copy for speediness.
[0] https://wiki.archlinux.org/title/PipeWire#Automatic_profile_...
(Kinda goes to show that enabling this feature by default is a good idea.)
Thanks, you just made my day!
# mic on, worse audio quality
pactl set-card-profile bluez_card.DE_AD_BE_EF_FA_CE headset-head-unit
# mic off, better audio quality
pactl set-card-profile bluez_card.DE_AD_BE_EF_FA_CE a2dp-sinkSince pulseaudio's architecture isn't well-suited to incorporate sandboxing, that project continued and it turned out that it could handle compatibility with both pulseaudio (the sound server for "consumerist" needs) and jack (the one for "pro audio" people where low latency is paramount).
You can even use programs like QJackCtl, which was written for Jack, to perform audio routing and stuff with pipewire!
So now, we have a sound server that
1. is much nicer to configure than pulseaudio
2. is compatible with sandboxing
3. is compatible with pulseaudio, jack and the older alsa APIs and features
4. is developed much more quickly than either of the others
See also https://fedoraproject.org/wiki/Changes/DefaultPipeWire
How does Pipewire deal with this?
Also-- links to the audio driver bug reports, please!
Also-- links to info on the hardware bugs, please!
I believe you, I just want to read about them.
It doesn't, it sets a much shorter max buffer length so that the latency is always acceptable. This does mean that in theory, with an otherwise totally idle system, PipeWire can't be quite as low power as PA.
"DOC,ENH: How to connect container pipewire, alsa, jack to host pipewire (#1612)" https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/16...
It is neither. Gstreamer deals with codecs and such. It's a set of libraries that an application uses to handle multimedia needs.
Pipewire is a service that handles streams and passes them off to hardware.
If you wrote e.g. a music player, you could tell gstreamer to play a .mp3 file, and it would decode it (by using its mp3 codec) and send the audio off to the pipewire socket, and pipewire would send it to the hardware to actually, you know, play. Pipewire would handle buffering and resampling and mixing and all that fun stuff.
Pipewire sits at the same level in the stack where pulseaudio sat before, and gstreamer also talked to that (and in fact you can speak to pipewire as if it was pulseaudio).
It's simply that it was written by a person also involved with gstreamer.
(Gstreamer is fantastic as a swiss army knife, but something a bit more focused is needed).
I believe this will interface with gstreamer just fine though.
Actual advantages of pipewire vs pulseaudio are not that obvious, but it should mostly be lower-latency, hopefully more stable, and more flexible (provide something like the old `jack` API where any stream can be plugged anywhere). Also, support for sandboxing (flatpak portals) is first-class, as one of the early design goals was to provide this for video.
Pipewire is also used in most places where wayland is, to provide screen sharing capabilities (now, if proprietary software could catch up... looking at zoom).
And lastly, pipewire should hopefully become one of the best APIs for accessing webcams and other video streaming devices in the future (allowing stuff like sharing a camera between multiple apps, simple sandboxing, middleware for compositing or video effects -- think background removal tools). Support is a bit sparse for now, but there's a LD_PRELOAD workaround for v4l2 interfaces.
Edit: also, pipewire gained support for nicer bluetooth codecs faster than pulseaudio did.
Yep, I have a pair of Sony WH-1000XM3 which supports better codecs like LDAC and you had to resort to a 3rd party, home-made repository in Ubuntu for pulseaudio (initially there were licensing reasons but then Sony opensourced it IIRC). With PipeWire (on Ubuntu 21.10) I just have to install a package from the standard repo.
For example, I have an electric piano that I can connect to my computer and play. I had to install a special software called "jack", because PulseAudio would have me wait before I could hear a note I played.
Jack was not simple to use, but even if you were good at it, there were problems. Imagine you wanted to play along with some music. Well, bad luck, some software do not support jack, and you can't use it together with PulseAudio.
Now lets say I want to stream my playing on Twitch. Again I will have trouble, because the many moving parts in streaming, including video, make it very difficult to output a high quality stream.
Last, when I use DaVinci Resolve to edit and upload my stream to Youtube, I want to record some voice over. Resolve has this function called "ADR", or "Automated dialogue replacement" -- it's a feature they use in film to record the actors on the computer. I could use that to record my voice over, but ADR on Resolve doesn't bother with either Pulse or Jack, and uses something called "ALSA". That means that until Resolve finishes using it, I can't use my microphone!
With Pipewire I just click and it works.
You absolutely can, PA is then present in JACK (and JACK in PA) as a single sink/source that you can route like any other app - so not as flexible as PipeWire, but not as problematic as you paint it either.
With pipewire, this works quite nicely, including for applications that are sandboxed (e.g. Jitsi in a Flatpak). In my bubble, when people talked about using Pipewire, it was almost exclusively related to screensharing on Wayland.
I've switched from Pulseaudio to Pulseaudio-on-Pipewire last year and haven't looked back. Next step would be trying to set an audio processing pipeline with audio effects (like a multiband equalizer tuned to my headphones), something that I managed to set up with Jack before using Pipewire, but that was always a pain.
It's one of the only times in recent memory that moving over to 'the new thing' actually worked without significant pain.
That sounds great and all, but can someone enlighten me exactly what a session-manager is, in the context of Pipewire?
I’m using Pipewire and it works fine. But is this something I should know about? Something I can or should tweak? Or is it mainly for the distro-maintainers?
But how does PW work for, say, Debian/Ubuntu users?
I haven't tested Jack compatibility yet.
Read the debian wiki for the setup.
For the laptops I also use BT headphones, and with the ThinkPad I use a headset that with the latest wireplumber switching profiles just work whenever I join a meeting with Slack or Teams (both in Google Chrome).
For the desktop PC I had a use case I never got working properly, or at least easily, with PA. That is to expose all the HDMI outputs of the graphics card as separate sinks. With PW, just switch over to the Pro profile and they all appear. Then I can route what ever stream/application I want to a specific HDMI output.
Additionally, I use USB MIDI devices and a software synth, qsynth, using JACK. Setting up both MIDI and audio routing via qjackctl is so convenient.
Oh, and USB audio devices also work without a problem. Can't say if that is different from PA as I never used them much before.
Source: https://fedoraproject.org/wiki/Changes/DefaultPipeWire
I didn't have to investigate further, but there is one open bug from another user: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/13...
https://bugzilla.kernel.org/show_bug.cgi?id=214019
Otherwise pipewire has had some bugs with audio switching and firefox at the beginning, but the last month or so has been great.
Experience has been flawless until now. Its truly an outstanding piece of software that "just works" and gets out of your way. I am really, really happy to use it, it has simplified so many things in my day to day life.
Before, using pulseaudio, connecting my bluetooth headset and getting any application to work with it was a serious pain, now it is a matter of turning the headset on and boom, connected, all audio switches automagically over to the headset.
For me, BT works perfectly with PulseAudio. PipeWire is very satisfying for absolutely everything else, but BT devices just refuse to connect (and I'm inept at debugging BT issues).
As it stands, between my desktop (Manjaro), laptop (NixOS/Ubuntu) and work laptop (Ubuntu 20.04), I have one single issue with Pipewire; on my work laptop if I have audio output set to HDMI (monitor speakers), when I plug in a wired headset to join a conference call it doesn't switch to the headset. If it's set to internal speakers first, it _does_ switch. So, if I have a conference call and I was using the monitor speakers, I have to jump into the Gnome sound control and switch to headset manually.
One thing I still fight with is pw-loopback. I like to create a default sink that I can remap to my sound card. Playing a simple sine over that will give me hickups and dropouts. There is nothing in the documentation of pw-loopback that tells you any about this and as of now I could not resolve it.
When I plug the same output directly into the soundcard in Catia, the sound issues are gone.
Linux is a real trip, man. Bluetooth was introduced 24 years ago and we can still barely make it work. Seems to work on Windows, Android, Mac.