PipeWire: Bluetooth Support Status Update
collabora.com
collabora.com
I’ll try to dig it up and edit it in here, as I think it was a great hack
[0] http://soundexpert.org/articles/-/blogs/audio-quality-of-sbc...
Via
[1] http://www.zenwalk.org/2019/09/audio-quality-of-sbc-xq-bluet...
Apple still is more sophisticated in the desktop scripting department. Applescript support in most applications and the ability to tie that into actions is seriously powerful stuff.
Gnome wins in the ability to use javascript to customize window handling, but it isn't really able to script application actions like you can in OS X.
It is improving though. If you can use keyboard to navigate the functions you want in applications you can automate it with software like keymapper.
https://github.com/houmain/keymapper
There are other similar software available. Probably a half a dozen serious projects in total.
Keymapper is software that intercepts input from your keyboard and allows you to 'remap' it. It operates on the libinput level of things, so it works regardless of environment or if you are in the console. It does require elevated privileges, though.
This, when combined with Gnome-shell extension and user keymapperd daemon can provide application-specific contexts for keyboard combos. The extension monitors for switching applications and gives keymapper the ability to be context-aware.
This is how I "solved" the copy past nightmare for myself in Linux. This way no matter if I am in a browser, terminal, or Emacs I have consistent copy-paste keys. (super-c, super-v). Makes things easier.
This isn't even remotely on the same level as applescript, but at least it is something. You have to understand low-level Linux keyboard stuff, which is still a mess. Versus being able to simply record yourself using applescript.
Gnome certainly is a very relaxing environment once you get used to it. Much less frantic or distraction filled compared to Windows or OS X. I like it.
And personally, I think Gnome is absolutely awesome. If Desktop Linux has any hope of succeeding, it needs exactly what Gnome is doing. A stable UI API that developers can develop apps towards.
Gnome devs got so much flak for getting rid of theming/customization (they haven’t gotten rid of it, but they’ve made it much harder by default), but the reality is that it’s what’s made it possible for Gnome to implement real Dark mode so effectively.
I just updated my Ubuntu to 22.04 and absolutely love all that Gnome has brought to the table (sure Ubuntu added accent colors, but Gnome will likely get that within months).
I think the Fedora + Gnome combo is just brilliant and will potentially make the year of Linux on the Desktop actually achievable.
Windows, with the right BT card/drivers (usually anything Intel) is the best, with Linux a close second, but some of the other vendors have very sketchy Bluetooth support.
For the most part it works out of the box with good latency without extra configuration and provides good routing options as well for more advanced usage.
It only took a few lines for me to switch and I've never had a Linux audio issue ever since! (And when I have, it's been my fault like my volume was turned down or my speakers were unplugged lol)
So far the only anecdotes I have are (a) everything seems to be working and (b) don't forget to reboot after installation.
I always used to delete PA because I had no desire or need ever to have more than one audio source feeding more than one audio sink. We don't live in a world compatible with that model anymore.
What about you give it a try instead?
That is just not true. PW uses ALSA for physical output and it implements PA so that all the apps just work. There is nothing dismissive about that.
Notably, the developer of Jack, the universally admired professional audio system, now uses PipeWire via its Jack-compatible API. He is frequently here on HN.
[0] https://www.freedesktop.org/wiki/Software/PulseAudio/Documen...
I spent an hour the other day trying to figure out how to tell it not to output audio through my DualSense controller haptics (which look like a four-channel audio output) when I connect it to an Intel NUC over USB. I never did succeed, and all the posts I found were basically other people asking how to do similar things.
In the sound cards list, just set to disabled.
For a headless system, it's useless.
DualSense is a game controller. In this context, headless is unlikely.
$ PULSE_SERVER=192.168.1.21 pavucontrol
° Ok, in actuality my kid broke half a male 3.5mm connector in the speaker’s 3.5mm female port and I was too lazy to break it open and solder in a replacement. Mostly due to not wanting to hunt for a layout-compatible female 3.5mm jack.
The delay you describe should be only as long as it takes for the audio packet to be processed by the audio stack as the video syncs with the audio and not the other way around. But I don’t think Bluetooth blocks for an ack of each packet (and if it did, you’d be delayed the other way because of the time it takes for the response to reach after the packet has finished playing)!
The half second of audio playing after you pause can be explained by the same delay I describe: that’s how long of a lag there is between source and sink (like you say, due to buffering - plus the transmission delays).
pavucontrol let's you introduce a delay per device (in Output Devices under "Advanced" for the specific device), which might allow you to use it with Netflix directly. Or at least I managed to get it working wonkily once and then went back to using mpv...
It definitely does, at least for unidirectional/"music" audio (i.e. using A2DP).
A2DP uses ARQ and additionally introduces some buffering to make transmissions more robust in adverse radio environments, at the expense of latency.
But that should not affect your use case; playing movies should work fine, period, end of statement. The fact that there is latency to your speaker is something that an bluetooth or other audio pipeline should know, should be able to compensate for. PulseAudio (which your music players are almost certainly using, under pipewire or other) has great understanding of latency built in. If you do experience big audio latency, open up pavucontrol & adjust your device's latency, and that problem should go away. It should be semi-stable. But pulseaudio & pipewire both should, in a wide range of cirumstances, understand what the expected latency is & "just work."
If you are on a videoconference, however, knowing that there's a second of latency doesn't help, won't bring things closer to real-time. It's still gonna be terrible. Newer specs, newer codecs could help significantly, but the audio daemon won't be able to help. Pulseaudio did have higher latency by default, tuneable (i think i'd tuned to using 2 frames of 16ms each = 32ms, pretty aggressive), but I think they've trimmed it significantly in very recent releases, but pipewire's architecture has allowed it to be significantly more aggressive.
JBL “true wireless” I have to adjust audio to about -200 ms delay while with AirPod pro I don’t have to make any adjustment.
Both the JBL and Apple devices are Bluetooth 5.
Bluetooth 5 isn't the savior though. My Bose Quietcomfort Earbuds have tremendous lag even attached to Bluetooth 5+ devices like my phone or desktop.
My macbook can't even figure out that it should try to connect to my offce trackpad after I have had it connected to my home trackpad! Thankfully it has a built in trackpad that I can use to manually connect when the "automation" fails..
I had a 12" MacBook no-adjectives in the past which didn't even work with AirPods well. I was hoping the M1 would have a better BT stack (the iPhone's...)
Looks like NixOS's pipewire service enables WirePlumber by default. Not sure if it changed recently from media-session, and that's why it's gone unstable, or if it's something else.
Might also help to test out pipewire-media-session to see if that helps, too.
Pipewire is a really great improvement in the audio story for desktop Linux!
why does it do video? is trying to do media capture like OBS or be a compositor like wayland? if so why bother? those solutions exist already... maybe it should just stick to audio, cuz that part of it feels like feature creep.
Handling audio without video fails if they have to be kept in sync.
Anyway that's my outsider's impression.
* (LAN-)devices, most a source/sink/control for various Audio/Video streams.
* Those devices (can) share/use any HW (Microphones/Speakers/V4L-devices) available
* programs producing/consuming sound/video, to be "exported" as individual sinks/sources
* Eventing support to dynamically change media routing
Your stated "reference problem" (Car AV) is (imho) not the most user-"relatable" scenario (after all, who has "hackable car"), a more common scenario I'd see:
* In several of the rooms of the dwelling there are
* Devices large/small with several connection types
* LAN (PCs, TVs, AV-HW, MediaPlayers, ...) with protocols including e.g.
* Well-known programs (VLC, KODI) with their "own" protocol
* UPNP/DLNA/AirPlay/Miracast/PulseAudio/RTSP/...
* SIP/WebRTC devices/clients (Doorbells, VoIP-Phones, VideoConf)
* Devices with Vendor-specific protocols. e.g LG WebOS
* USB connection to one of the above (WebCam, Android-devices, phones)
* Wifi-P2P (Some of LAN devices have this too, for e.g. screencasting)
* Bluetooth BTLE/Classic (devices can be stationary/mobile/transient)
I would like to enable these usecases:
* Send [emulated] [second] screen from PC to any Display surface* View any desktop/UI/program/device on any other display surface
* Control all the above from PCs/Phones/Tablets, or Events (Doorbell -> Camera PiP @TV)
* Route any audio/video source to my speech-recognition/video-conf/VoIP Software
* Use Android device [connected to USB[ of another Device]] as 8+ devices: Camera F/R, Screen I/O, Audio I/O Headphone/Speaker/BT Microphone/App-Output
* Use "hook"-scripts for eventing/device control (TV might need some command to switch to HDMI3)
I realize most of the above can be probably be done using some GST/FFMPEG glue scripts/code and some systemd dependencies, but I'm haven't found quickly relatable examples of: * "Run this command/config to add an ffpmeg commandline as virtual camera"
* "Use this config to represent your TV as another display output device"
* "Run this command On DevA to launch a GUI-binary on DevB, and make this "stream" available as VideoSource in Browser@DevA"
* "Use the Webcam on DevA, bluetooth headsets via DevB for input, TV1 as VideoOutput, AudioOut on AVR, runnings VideoConf on DevC"
* "Do this to implement access-control" (Bob can see Input "foo", but Alice can't)
- Multiple data flows
- Limited available attention
- Need for "just works"
- Need for trivial override
- Funding available
- Strong demand for solutionYes, and also the goal is to support video in addition to audio.
>if so, in what way is it trying to be better?
Well in addition to supporting video, it also supports jack clients without needing to run a separate server. There are a few other things like better security policies, but those are the major ones.
>also, how's the codebase quality? from what i heard, pulse's codebase is a mess, so if it can improve in that sense, i guess that's a win (?)
Pulseaudio's code is fine and pipewire is about the same, it's a relatively small core daemon with most of the major functionality split out into a large collection of loadable modules.
>why does it do video?
A few reasons, but the major one is because video on Linux has the same problem as audio: the low-level device API (V4L) can only be used by one program at a time. This leads to failures if you try to do something like access your webcam in two applications at the same time. Most applications should basically not be using ALSA or V4L directly to access devices for this reason. A sound server like pulseaudio is the typical way to mux/demux the audio devices to allow multiple applications to access it at once, and now pipewire extends that to video.
>is trying to do media capture like OBS or be a compositor like wayland?
Neither, it's used to route video sources between programs. Media players and cameras and Wayland compositors that want to do screencasting can send their video into pipewire; casting programs like OBS or any ffmpeg-based tools can receive any of these video streams from pipewire and do whatever they want with them, or could also output to pipewire so another program can consume their output. If applications support it then the idea is you'll be able to easily connect together any two applications that produce/consume video and it'll all just work.
No, it isn't. Pulseaudio is based on a push model, which is completely broken.
Pipewire uses a pull model, like BeOS/Haiku and jack. It is suitable for pro audio, which pulseaudio could never hope to support.
These two statements are both very wrong. The push model is absolutely not broken, it's actually better for media players, networked sound and other non-pro-audio applications because it uses less power and can do more efficient buffering strategies. You're right that it's not good for pro-audio and other latency-sensitive applications, but pulseaudio was not designed to do that on purpose because jack already filled that niche. The pull model has to wake up every application every quantum on a strict deadline to do processing. In some situations pulseaudio should still be able to provide the smallest power usage compared to pipewire, even just continuing to use the pulseaudio API to do buffering on top of pipewire should be a benefit for applications that want it.
Even if it was broken (it's not), that would be an aspect of the design, not the code itself. The code itself is structured in mostly the same way as pipewire.
pw-metadata -n settings 0 clock.force-quantum 2048
As an alternative to increasing latency, especially if you're not running on batteries, try linux-rt. (PREEMPT_RT).
It makes scheduling latency decent. On my machines, the max column in rt-test cyclictest, after running for a day, remains at <100µs, whereas if I use mainline it easily goes to ms range within a minute or two, and I've seen it go as high as 30ms.
linux-rt patchset is slowly getting merged into mainline. I am hopeful that at some point we will be able to build it with PREEMPT_RT, and that desktop kernels in distributions will do that.
If you do audio at all and run Linux, I can't recommend PREEMPT_RT enough.
In general I feel like we only just got Bluetooth 5.0 devices available on computers. Bluetooth 4.0 or 4.2 has been frighteningly prevalent, until very very recently. Bluetooth 5 harkens back to mid 2016, Bluetooth 5.1 was announced January 2019, 5.2 in January 2020, 5.3 (you guessed it) 2021, but I'd wager you'd need to drop numerous significant figures below 1% to account for how many laptops (much less desktops) are sold today whose bluetooth is >5.0.
Truly one of the slowest, laggiest, least adoptable technologies on the planet. Really weird to me.
I can definitely accept some lag. LC3 is really using bluetooth-le, a very different scheme. At the same time, I see folks like zephyr-project already kind of making inroads into this future[1], in the open. A not small part of me thinks the way we do consumer devices is totally jank. That folks like PineBuds are living in the future, where we can compile our own OS'es for our peripherals. PineBuds[2] could, with a little zeal & push, become the first LC3 device on the planet. And they could, perhaps, unlike most other devices that'll be made in the next couple years, possibly support whatever comes next.
Shifting areas of interest a bit, but: another data-point in opening the future, the software Intel uses for their new PSE management engine just got open sourced[3]. It too is built on Zephyr.
On the positive-side, for PipeWire, incredibly sweet to see Hands-Free Profile get better. This is essentially the idea of a computer acting like a headset. This enables such vast additional degree of system flexibility, creates so many interesting situations. Phones, cars, other things are very limited in what they can do. But if we can wirelessly plug in a general purpose computer, make it act like audio system: we can do so much more. The old Nohands[4] stack is wildly out of date & unsupported. PipeWire just doing the thing is 100% super sweet as the world needs to be. In general, a more amorphous world where computers can act as hosts or devices is one I thing would be vastly empowering: software is soft, and so too should be hardware, when it can.
[1] https://github.com/zephyrproject-rtos/liblc3codec
[2] https://www.pine64.org/2022/04/01/introducing-the-pinebuds-a...
[3] https://news.ycombinator.com/item?id=31121264 (2 points, 7 days ago, 0 comments)
To be honest, that timeline strikes me as pretty comparable with other hardware protocols like 802.11, USB, 5G etc. These are complex protocols, parts of them implemented in fixed-function logic, and that just takes some time to market.
Bluetooth >= 5.2 and LC3 are some of the prerequisites of LE Audio, but LE Audio is a separate standard that builds upon them.
The Bluetooth has only finalised the core parts of the LE Audio standard 22/Mar/2022 [1].
Some optional parts of the standard, e.g. "TMAP: Telephony and Media Audio Profile" are still not finalised. [2]
Many of the phones that support Bluetooth 5.2 should be able to support LE Audio.
On the software side, Android 13 (expected Q3 2022) will be the first OS to fully support LE Audio, and that's a few months away.
It was indeed very poorly communicated, and there was poor expectation management, but within a few months all the pieces should come together and the first devices should appear.
1. List of recently adopted standards: https://www.bluetooth.com/specifications/specs/
2. Diagram of all the different pieces of the specs: https://www.bluetooth.com/learn-about-bluetooth/recent-enhan...
LC3's non-delivery is just one drastic vast highly-observable fuck up. The failure of 5.0 to arrive in consumer devices for basiclly half a decade rings so profoundly scarily true. There still being noting post 5.0 available so widely confirms these horrible beliefs. Bluetooth miserably fails to make it's way into the world. It's a constant wreck, constantly vastly behind. Specs that are so under-performant dont deserve this endless chance to deliver more.
We're well past the point where there need to be other possibilities. Bluetooth has held the world hostage, has perpetually been lopsided in what it does. In other threads I mentioned how pipewire, finally, is creating a more equitable situation by creating a Hands Free Profile bluetooth device, but only via minimal circumstances, short of all the good & better specs. Bluetooth just fails, can't do, is resistance in the world, giving more fixedness & constraint than benefit today. Bluetooth is sad.