Hacker News new | ask | show | jobs
by jelicicm 1281 days ago
Stumbled into PipeWire few months ago when trying to setup Bluetooth headset on Ubuntu OS. It's superior to PulseAudio, but...

Really unbelievable to comprehend that Linux distros have such bad support for Bluetooth audio headsets - something very common in today's tech world. Android, Windows and Apple's OS all very efficiently switch from A2DP codec which is excellent for audio playback, but has no possibility for bidirectional communication (so you can't use your microphone) and HSP/HFP coded which provides worse sound, but you can talk. Linux doesn't have this fixed, there were some attempts [0], but nothing great came out of it.

[0] https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/18...

8 comments

My personal experience is the opposite-- although this behavior perhaps isn't desirable for end users who don't want to fiddle with their codec selection, being able to switch between A2DP and HSP manually in pavucontrol provides me with a much superior experience compared to Windows which would a) keep my headset in HSP because of some rogue application with a stuck open mic and make it really difficult to track it down/undo it and b) (rarely) keep my headset in A2DP while an application is attempting to grab audio or switch it to A2DP in the middle of meetings and break everything until I restart the application trying to use my mic. In my experience, a manual codec switch is a much smoother experience, ironically.
Not sure if this is what you were pointing out here, so just in case: Pipewire does allow you to switch BT codecs including the ones which do better bidi quality. Including autoswitching if you want it to happen automatically https://wiki.archlinux.org/title/PipeWire#Automatic_profile_... (you can switch manually as well)
I came here to say the same thing. This feature has had its fair share of bugs over the last year but lately (using Wireplumber) it's been working quite reliably for me. I no longer use any Bluetooth USB dongles!
Thanks. Will give it a try!
I'm actually confused; The past couple years, PulseAudio has been pretty good at switching between the two for me. Getting stuck in HSP isn't unique to Linux of course; it can happen if anything holds the mic open, there's reports of issues with both macOS and Windows too, for the same reason. Especially common with programs like Discord.

PulseAudio absolutely supports it with the Bluetooth module's auto_switch feature. I guess I'm not sure if Pipewire supports it, but it's likely handled by whatever is doing session management. I can only assume it's possible to configure Wireplumber to handle it if it doesn't have native support for it yet.

Hm, not really sure about `auto_switch`, didn't dig deep enough to find it I guess. PulseAudio only offered HSF/HSP which sounded simply terrible. PipeWire's HSP sounds pretty good (mSBC codec), although it's still obviously worse than A2DP. I'll have to look into auto switching and how to enable on either system.
Are you saying that in pavucontrol, you see no A2DP modes at all? That's very strange, since all Bluetooth certified stuff should at least support A2DP SBC mode.

Out of the box, Pipewire should also be able to support LDAC and maybe AptX. PulseAudio can use Gstreamer to support additional codecs, so on PulseAudio with GStreamer 1.20+ you can get better A2DP coverage, assuming you have the right codec packages installed on your distro.

In general, Linux Bluetooth support has been a lot better as of late, to the point where I didn't need to mess with much, so most of what I know about it is actually older. (I used to use a third-party PulseAudio module to get better A2DP support for example, but when I looked it up, I found that it was deprecated in favor of just using newer GStreamer.)

My personal Bluetooth experience also improved drastically when I finally got around properly importing the pairing keys from Windows into Linux. Now everything works flawlessly.

If anyone is dual-booting Linux and Windows, here's a gotcha to keep in mind: Bluetooth pairing works using keys associated the MAC address of a Bluetooth interface. If you pair a device on Windows (key A) and then try to pair/connect to the same device after booting into Linux (key B), it simply won't work without anything telling you the real reason: To the device it looks like someone is impersonating the host interface, since it was previously set up using key A, but suddenly someone (Linux) pretends to be the same host (MAC address still the same) but with key B. The solution is simply looking up the key in the Windows registry and then using the same key in Linux.

Unfortunately, the process is a little complicated, but the Arch wiki page [1] does a really good job of explaining this nowadays. I've previously tried to set this up a few years back, but it didn't really work. Perhaps the wiki page was expanded in the meantime, or I simply did something wrong back then.

Just posting this here hoping I might be able to help some people wondering why the hell some of their devices just don't want to connect on Linux.

By the way, AFAIK some devices just don't care about the keys, that's why you might only have issues with a subset of devices.

[1] https://wiki.archlinux.org/title/Bluetooth#Dual_boot_pairing

jelicicm mentioned ubuntu in the original comment. I seem to remember that as of Ubuntu 20.04, LDAC wasn't supported. I needed to jump through some hoops to get it to work. It was still using full-on pulseaudio, not pipewire, at the time. I wouldn't be surprised for it to still not support non-free codecs out of the box.

I've indeed had no issues on my Arch install. Works perfectly with LDAC on my Sony headphones and aptx-hd on my Shure.

The mic of the Sony is a bad joke so I never use it, but I've tried it and switching modes worked fine on Linux.

I hear you on that one. I'm patiently awaiting end-to-end support for LE audio with bidirectional audio streams, and maybe, if we're really lucky, Sony will release a pair of headphones that has a better microphone to go with it.
Sorry, not saying that. I do have an option of either A2DP or HSP. I was not familiar with auto switch. But you kind people have filled me in in this thread. A2DP sounds amazing for listening to music, no problems there. The problem is the hassle of switching between profiles, since I tend to use my headphones in work environment (calls, meetings) - this is the reason I still keep a pair of cabled headphones around.
Interesting. Not sure what the deal is. Someone is suggesting that at least for PulseAudio, it could just be the older version of PulseAudio that shipped with Ubuntu. However, you should be able to get it working on Pipewire just as well. Pipewire stuff is still pretty immature, so your distro may have an older and less stable Wireplumber at the moment. In that case, it might be worth just trying to set the Pipewire Media Session option for this instead. Wireplumber is really powerful, though, so it's a nice tool to have available.
+1 For Pipewire + Wireplumber! With it, automatic codec switching has worked quite well for me!
What is really unbelieveable is that Bluetooth still cannot do high quality full duplex streams in 2022, and that anyone that wants to use wireless has to accept sounding like a telephone line / old radio from the early 90ties in meetings.
When I ask sales people "does their bluetooth headset actually do high quality full duplex streams" they give me the strangest look.

I am glad to see that I'm not the only one asking for this, i feel like i'm taking crazy pills.

Are you complaining that Linux can't handle Bluetooth because PulseAudio breaks your setup, on a Pipewire post?

Use Pipewire then. As other have said, this is not a problem anymore with the recommended setup of Pipewire + WirePlumber.

Wideband (mSBC) support was added into Pulseaudio 15 btw: https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/1...

It also added support for using higher bitpools for the SBC codec (sbc, sbc_xq_453, sbc_xq_512, sbc_xq_552) which pushes its quality above APTx and the other proprietary codecs. Info about bitpools and SBC here: https://habr.com/en/post/456182/

I've personally had a smoother experience on KDE with PipeWire because it seems to switch quicker for my headphones automatically, and worst case I can just right click it in the bottom right and select the correct codec.

On Mac OS X however with the same headset, there's no manual switching, and I have to try to "coax" it into switching back by playing media like Spotify and it's not super consistent.

Granted I only switch accidentally when I accidentally have my headphones selected as the audio source.

When using recent packages (e.g. NixOS) it's become quite good in the last ~6-ish months. It switches automatically when I open zoom, which is very nice