PipeWire: A server for Linux audio and video streams
pipewire.org
pipewire.org
The Arch Wiki page describes some of the use cases for PipeWire: https://wiki.archlinux.org/title/PipeWire
I've been watching linux since the OSS days. I used oss, alsa, arts, esd, jack, pulseaudio... never it has been looking as well aimed as it is this time. Finally!
It also replaces part of ALSA, which is two things: the kernel interface to talk to audio devices, and a set of user libraries on top of that interface. PipeWire still uses the former, but has its own, better API for the latter (in addition to supporting ALSA, PulseAudio, and Jack APIs).
And getting it to just stick to unidirectional audio (relying on the internal mic for input, which seems like the only practical option) took some serious trial and error. It still occasionally sends a stream to my headphones when nothing is playing, which prevents other devices from using them (my headphones let you connect two devices but only play audio from one of them).
If it does address these issues, I hope Ubuntu will soon officially support it (I've learned better than to use non-defaults, it just invites pain).
https://wiki.archlinux.org/title/PipeWire > 4 Troubleshooting > 4.8 Low audio quality on Bluetooth
> I've learned better than to use non-defaults, it just invites pain
Funny, after using Ubuntu for many years I switched to Arch, just because I got hit by so many upgrade issues when "things should just work". With Arch I can only blame myself, which is refreshing.
Yes, one of the biggest features of Pipewire is proper Bluetooth headset support. It's the reason I switched to it.
I think linux + bluez + pipewire is the first ever software-only stack that can achieve this, as a USB dongle would be required on other platforms. We shall declare 2021 as the year of linux on the desktop!
I am glad to have been proven wrong. I was extremely surprised at the progress PipeWire made in a couple short years. I have been barely able to find any issues even after a couple of months of using it. In comparison, I filed a dozen PulseAudio bugs (some of them with patches, never applied) before I just gave up...
I was describing what macOS does not not allow, and that's routing audio between applications. When I say that, I don't mean that it is impossible - there are numerous tools (including JACK) that will allow it - but it doesn't come with just CoreAudio itself.
Linux is already deployed in some commercial daws and it will soon be an RTOS. Hope music production will have more and better options because of this.
I'm also a low level audio/midi dev (tho far less prolific, and less public) and having seen how you architect things, and your code, I'd value your opinion.
MacOS is a little confusing with it because you have to configure it in the MIDI setup utility, but it works very well.
Not to mention commercial product from Rogue Amoeba which is fantastic.
That's quite different from JACK, SoundFlower, Hijack and the innumerable other inter-application audio routing systems for macOS, which can be used without the applications knowing anything about them.
However, it did not and does not provide for inter-application audio/MIDI routing, which is what tools like JACK, Rewire, SoundFlower, Audio Hijack and others are all about.
Wouldn't it be better if daemons like PulseAudio or PipeWire gave control of an audio card to an application that wants exclusive access?
For example, Windows API can provide exclusive access to an audio card.
This is not necessarily true. Using JACK adds no latency, for example.
edit: https://github.com/jackaudio/jackaudio.github.com/issues/138
I'll definitely retry every 6 months or so, but for now, I have to spend my time getting actual work done, not experimenting with yet another shiny and new, but unfinished and unstable toy (Wayland flashbacks intensify).
I'm doing this with PulseAudio. It adds a little latency but it works. I initially used pagraphcontrol [1] and later made my own little Python script that creates the virtual devices ("null outputs") and virtual wires ("loopbacks") and wires conference applications automatically when they show up.
Can I do this with PipeWire? Are the tools there? This post claims that PipeWire is now ready, but it seems to have reached version 0.3.35 which seems a very arbitrary point to call a milestone.
It's responsible for things like choosing audio inputs and outputs and volume mixing etc.
Pretty much your whole Linux audio stack.
Requirements were driven by complications found managing streams in automotive uses. E.g. routing back-up cam video, soft instrument cluster video, bluetooth phone audio, dash mic, car stereo player, sirius receiver, voice navigation, dash cam.
The mind boggles.
Weirdly, I found very few people complaining about PulseAudio's CPU usage. Maybe nobody cares about 10-15% of one core.
However, I am happy to report that PipeWire seems to not have this problem at all. Since it became default on Fedora, it has barely shown on top's first page. Given that it is even more ambitious than PulseAudio in terms of latency, this is incredibly impressive!
Even stranger, sometimes it keeps taking 5-10% CPU with no audio playing. (I think it is related to running out of memory for a moment and using swap, but no matter how much memory I free up, the computer never returns to normal and must be restarted).
I'm getting to the point of installing debug symbols and pointing perf at it, but dropping pulseaudio would be an even better solution.
Run the same audio without pulse and the CPU usage will be higher.
Pulseaudio burning CPU during silence is usually due to an application holding open a channel that is either really playing silence or is keeping the Pulseaudio machinery awake. You could blame the apps, but IMHO that is definitely a Pulseaudio problem
I'll probably get downvoted again but what hardware?
This sort of thing does not come for free, and any other solution that is using less CPU may be cutting corners in areas like this.
For me Pulseaudio is still my weapon of choice for running a dedicated realtime DSP where the input and output are on separate cards/clocks, but I can see how it has grown beyond sane scope for ordinary desktop usage
This has to be done though. Otherwise, you would have periodic underruns or overflows.
Unfortunately, using my media player without PA actually used more CPU overall -- the audio player's CPU use went up by more than PA had been using. So I went back to using PA.
I think it must depend on the relative performance of the software resamplers involved (ALSA's in-kernel plughw vs. PulseAudio's vs. your media player's).
Do you remember which media player triggered this?
Pulseaudio lowers CPU usage by 5 to 25 percent depending on CPU architecture.
Also, I'm curious why this happens on your system. PulseAudio itself uses ALSA (the standard kernel API for audio) behind the scenes, like any application would, directly, in its absence. In addition, it must carry audio samples across process boundaries and perform software mixing/routing, all with low-ish latency (hence small buffer sizes). All this with negative (up 25%!) CPU usage?
One possible explanation: I did read many times that PulseAudio "fixes ALSA bugs" or "fixes buggy applications". However, I can't remember encountering any such bug in the last few years (or any PulseAudio bugs either, to be honest). Nowadays, most applications that can use ALSA directly do so through alsalib, which could just as well iron out such issues if any remain.
Which application triggers this behavior?
i7-3517U with realtek ALC269VB audio chip
i7-6500U (I don't have access to this one right now, but it was a Asus ZenBook flip -- on this one I've definitely seen 15%+ usage by PulseAudio during video calls.)
i5-7200U with conexant CX8200
The latest desktop is:
Ryzen 5 2600 with realtek ALC887-VD (on this one the CPU load was lower than on the others, but still there)
Tried a "ps|aux" and discovered it is already running wayland and pipewire. Works so well it is boring. Nice!
I've been blown away by how good things like touchpad/gesture/multi-monitor support are in Wayland as well.
I tried really, really hard to run linux on a laptop in 2010, and eventually just settled on virtualizing it for acceptable device compatibility.
In 2020, my linux laptop genuinely feels much better than the macbook my office issued me. Like - actually better. Not "Better because I control it and it's free/opensource", just "Better".
Yes! This is the point of Linux and other open source. We don't use open source because it's "morally better", we use it because it consistently produces superior solutions.
Why not both?
https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/FAQ
The only issue I've run into is that for some apps (Zoom, Firefox, Chrome) which are set to use my "default audio device" for input or output, it selects the correct device initially, but if I change the default/system device (via gnome sound settings) later while it's in use, most (all?) of the time, the application continues using whatever device was selected initially.
I haven't bothered to debug or see if this is a known issue as it hasn't bothered me much since most apps allow switching to explicit input/output devices which works fine. I believe (but haven't definitively confirmed) that changes via pavucontrol also work, so perhaps it's something with the gnome sound settings?
Anyway, huge thanks to the devs who put their time, effort, experience, and talent into making PipeWire happen. It's a huge step forward on multiple fronts
For Pipewire, there is no end-user documentation that I've found so far.
On one my setups, and all media stops playing, including videos if I forget to plug in my headphone. Restarting pipewire or plugging in devices after that doesn't seem to help, and I have no idea about the pipewire configuration files to even attempt any changes. I would really appreciate some end user debugging and configuration related documents.
>I had thousands of forum posts to go through.
That points to what sounds like two disadvantages, if anything.
journalctl --user -b -u pipewire
journalctl --user -b -u pipewire-pulse
journalctl --user -b -u pipewire-media-session
I also have this from earlier when I had errors; now I use it only right after startup because I'm doing output to multiple audio cards simultaneously.systemctl --user restart pipewire.service pipewire-pulse.service pipewire-media-session.service ; systemctl --user restart pipewire-multi.service
(The -multi one is a local service based on the guide for multi-output audio.)
If you see log entries similar to: pipewire-pulse[1173]: client 0x55f2d47effa0 [Firefox]: stream 0x55f2d484f7d0 UNDERFLOW channel:0 offset:221184 underrun:16384
I fixed this for multi-output audio by 'increasing the headroom'
cp /usr/share/pipewire/media-session.d/alsa-monitor.conf ~/.config/pipewire/media-session.d/ vi ~/.config/pipewire/media-session.d/alsa-monitor.conf
There's a section near the end for alsa_input and alsa_outputs, WITHIN actions update-props, I un-commented and set:
node.pause-on-idle = false
audio.rate = 48000
api.alsa.headroom = 1536
However I believe that's specific to my multi-audio output setup and a mixture of different soundcards; I could probably hunt for a lower headroom value.Who do I thank for making this Just Work?
I believe 21H2 is slated to bring AAC over to Windows, along with some other Bluetooth related enhancements. (They now merge the Headphone/Headset devices so you don't get the "I have no audio whenever I start a call" confusion with playback switching)
The $350 WH-1000XM4 has invariably higher-bandwith, higher-resolution audio than the $500+ Airpods Max. Whoever set that price at Apple is squirming in their seat, I can't seem to find it being sold new for more than $550.
I'm keeping a close eye on what Sony does next, because most of what they're doing now is really good.
I bought Audio Technica phones sometime back. The pads have burst twice. Now all the active features are dead.
I had sworn off Sony products because they always quit working after a year. Do they still do this? I felt like I was just renting.
But I found out about pulsewire and after switching, it just works, so... Plan on keeping using it.
Bluetooth support seems more robust (no more weird 'have to reboot my computer to connect to these headphones for some reason') but the real headline feature is I no longer have to screw around to get pulseaudio and jack to coexist peacefully (nigh on impossible in my experience)
The array of supported and configurable Bluetooth codecs are the reason I switched. Now I can use AAC for music, SBC-XQ for video and interactive content and switch to mSBC when I need to make a call, all from the user interface.
It sounds like some distros are using as the starting point for new installs, like Arch.
Is this the best way, to just install a new distro from scratch. I just don't want to try to hack a bunch of configuration files from pulse.
If so, what's the best distro offering pipewire. It seems like a revolutionary change and I'm excited to use it.
When I migrated from PulseAudio to PipeWire, I started by deleting all PulseAudio packages and installing the PipeWire packages. Then I rebooted and as it turns out, I was done. No fiddling with config files required here. Everything worked immediately.
It looks as though there is support for similar with PipeWire, with the ROC sink and ROC source modules[0][1]. I'm going to have to set aside some time to have a poke around with this and see how it performs.
1: https://radusuciu.com/posts/wireless-vinyl/ 2: https://github.com/badaix/snapweb 3: https://github.com/badaix/snapcast#contributions
But while it's mentioned here.. anyone else have that, or know what it might be?
Edit: Other comments are mentioning codec selection for Bluetooth in relation to lag/sync issues. I'm using whatever is default on Fedora 34. I've never looked and am not at my computer to check right now unfortunately.
With pulseaudio, it was rabbit hole after rabbit hole only to find a solution that ended up not working.
I switched a few weeks ago and haven’t looked back.
I've got my broken mess of a configuration for alsa, mpd, mpv, Firefox and pulseaudio all working again after a long, broken spell.
The only thing I haven't gotten working is the upmixing of channels for 5.1/7.1 audio channel movies on mpv. Currently I rely on my alsa upmixing setup in ~/.asoundrc but am looking forward to having that work with Pipewire alone, hopefully soon.
Yes, documentation for pipewire is sparse, and I'm surprised all/most links I see go to pipewire.org, which is where it is sparse. The useful one is here: https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/hom...
At one time I relied on a graphic equalizer module inserted into PA. Then, it went unsupported. Soon after it seemed to have vanished entirely.
Is there a supported graphic equalizer I can insert between PW and my poor, damaged ears? If so, what does setting it up involve?
Maybe it makes it to next LTS as an apt-gettable option? I’ll keep my hopes up :)
This PPA [0] works fine for me in 21.04 to get the latest version. Support for the PPA seems to go back to Bionic, so you should be able to use it on recent LTS versions of Ubuntu as well.
The only annoying part of the whole process is that the migration requires running a bunch of commands to stop and mask PulseAudio and to enable pipewire. This guide [1] worked great for me.
[0]: https://launchpad.net/~pipewire-debian/+archive/ubuntu/pipew...
[1]: https://ubuntuhandbook.org/index.php/2021/05/enable-pipewire...
What's the situation with RDP on wayland?
The only thing that seems pertinent to the discussion is perhaps the "pianotec" which I'm not familiar with. Is that improving on stock Ubuntu somehow?
Lowering latency consists of balancing two opposing "forces".
To lower it, you "simply" need to tell the software that you're using to use a small buffer size. This reduces the time between the MIDI event arriving in the software and the software producing some sound corresponding to that event.
However, there are limits on how low you can go, some caused by hardware and some caused by software. The kernel configuration itself can play a role, along with a variety of different devices and device drivers. This document tries to help you understand the sorts of system (hardware-ish) issues that can prevent you from reducing the buffer size:
https://manual.ardour.org/setting-up-your-system/the-right-c...
Ensuring that your software runs with realtime scheduling (SCHED_FIFO) is where it can be necessary to adjust stock Ubuntu systems to give you permission to do this (you are not allowed to do so by default). In addition, the software you're using (Timidity) will not necessarily do this by itself.
If you want to know more, I'd suggest visiting linuxmusicians.com and using their forums.
I'll stick with Jack2 + Netjack2 in the studio until that gets sorted.
It has already shipped by default in Fedora and is available in Arch and NixOS. It does look like it will quickly wipe out PulseAudio by default. I'm sure Jack and ALSA will hang in there longer but they are already used much more rarely (by users, the ALSA API will stick around for decades more I'm sure).
The big selling-point of ALSA, from what I remember, was that OSS couldn't provide mixing to support multiple applications - but FreeBSD's OSS does that. Some of the main selling-points of PulseAudio are per-application volume, low latency and high-quality resampling, all of which FreeBSD's OSS claims to do as well.
I run sway on FreeBSD and haven’t observed problems.
This is perhaps one of the best examples of not just making a new standard, but making one implementation to rule them all and implementing all the competing standards.
> Patiently waiting for Linux to have one audio server that will offer compatibility to all previous ones
That's PipeWire!
> then slowly phasing them out until we have a consistent, possibly layered, low latency audio stack that scales from small single board computers to full sized audio workstations.
Does PipeWire have its own interface for applications yet? I haven't heard of it if so. That's good; let everything maranate for a while before trying to design the "one, true interface".
End-user applications talking directly to ALSA will probably become more uncommon, though.
Edit: Yeah, the PipeWire FAQ confirms this https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/FAQ...
Don't know if Pipewire has published something similar, but I would guess there are corner cases in the ALSA API that wouldn't work well on top of Pipewire. E.g. the buffer rewinding, considering that Pipewire is explicitly designed around never doing that.
You can still have pulseaudio installed, but you can disable its daemon or socket so it doesn't actually run.