Support for HSP/HFP headset profiles on Ubuntu and Debian
A few months ago I was given a “remote work toolset” that includes a bluetooth headset simply referred as “EC717”.
To be honest, they come in handy for me, because I was using the hands-free kit of my phone, and it is not the same in quality or comfort.
However, I found it impossible to get them to work on Ubuntu 20.04 and Debian 10, two of the platforms that I regularly use. They do work for listening to music, as A2DP profile, but they don’t work as a microphone for video calls, thus losing their main function. When trying to set the profile from a2dp_sink
to headset_head_unit
, I get this error:
W: [pulseaudio] module-bluez5-device.c: Refused to switch profile to headset_head_unit: Not connected
This issue is extensively documented in lots of bugs and pulseaudio tickets at bugs.freedesktop.org (93898, 97316, 73325) and in the new gitlab.freedesktop.org (84, 122, 742, 776, 960).
In short, there’s no complete support for the variety of HandSet Profile / Hands Free Profile / HSP&HFP profiles by which the audio and control channels are coordinated in Bluetooth. Actually there was support, but changes to the architecture of Bluez and PulseAudio made it disappear. And this affects some headsets that implement only one of these profiles.
Around 2017, James Bottomley coded support for those profiles in pulseaudio 11, 12 and 13, but unfortunately those patches were not incorporated into the stable branch of the pulseaudio library when he published them, and they were only added a few days ago, thus they are not available in current releases of modern distributions.
Fortunately, he segmented two branches of work in which he neatly documents the code changes in order to make this type of headsets work with pulseaudio 12 and pulseaudio 13, and from them I was able to modify and compile two versions of the pulseaudio-module-bluetooth package with HSP/HFP support for both Debian and Ubuntu:
- pulseaudio-module-bluetooth (13.99.1-1ubuntu3.10) with HSP/HSP support for Ubuntu.
- pulseaudio-module-bluetooth (12.2-4+deb10u1) with HSP/HFP support for Debian
By the way, and before you complain, according to the Bluetooth specification the HSP/HFP profile is single channel (mono) and in 8 khz (Volume 2, Section 6.12, of the Bluetooth Core 2.0 specification), so the audio quality is similar to that of a landline phone (well, that’s the spirit of HSP). In short, it sounds awful just like an analog phone. If you want to listen to music, use the A2DP profile, but with this profile it is not possible to use the headset as a microphone. Newer versions of the patch bring support for multiple codecs that improve audio quality, but of course these improvements are only available on newer, higher-quality hardware.
As for me, I also opted to make a passthru module using python3-bluez and pulseaudio virtual sources/sinks, in a script of about 600 lines, so as to communicate directly with the headset and pass the audio as new inputs and outputs on the pulseaudio stack, but the latency it added to the spoken voice made it unusable. Bottomley patches, on the other hand, worked great.
Finally, regarding code quality, if you’ve worked on SCSI, Secure Boot, TPMs and UEFI, then there is a very high probability that you’ve come across James code. So, James, cheers to you!
You must be logged in to post a comment.