I recently acquired a new (actually secondhand, but new to me) set of Bluetooth headphones (Sennheiser HD1 Wireless), and decided that I wanted to get them working properly in Linux.

The problem with Bluetooth (especially if we’re talking version 4.x or lower) is the lack of bandwidth for a high-quality audio signal. In order to get the most out of that bandwidth, you need to be using a codec. There are a few to choose from, but the feature codec for my particular headphone model is aptX, so that’s what I’m aiming for.

By default, Debian 10 Linux with PulseAudio 12.2 supports A2DP with the standard SBC codec*, but not aptX specifically. However, one nice fellow on GitHub has created a plugin that adds this support. It is just up to me to compile and install it.

I am only going to document here the steps I took to install this plugin. Depending on the packages you already have installed on your system, you may need more or fewer. And most of this is just following instructions from the GitHub page – this article is just for my own quick reference in the future. Finally, disclaimer: do this at your own risk – I have not properly evaluated any of the code in question.

Packages:

  • pkg-config
  • cmake
  • libtool
  • libpulse-dev
  • libdbus-1-dev
  • libsbc-dev
  • libbluetooth-dev
  • libavcodec-dev
  • libltdl-dev

Commands:

git clone https://github.com/EHfive/pulseaudio-modules-bt.git
cd pulseaudio-modules-bt
git submodule update --init
git -C pa/ checkout v`pkg-config libpulse --modversion|sed 's/[^0-9.]*\([0-9.]*\).*/\1/'`
mkdir build && cd build
cmake ..
make
sudo make install
pulseaudio -k

Config:

I’m not sure if this actually does anything. But it doesn’t hurt. Edit /etc/pulse/default.pa:

load-module module-bluetooth-discover a2dp_config="ldac_eqmid=hq"

 

Disconnect and reconnect the audio device, making sure you select it as a high-quality audio sink (as opposed to a headset). You should now be able to select the “A2DP Sink: aptX” profile in the PulseAudio GUI (pavucontrol).

There is some talk in the discussion on another blog about work being done to import some of the higher quality codecs into mainstream PulseAudio. I’m hoping it eventually makes it into Debian 10 repos.

If pulseaudio is updated, you may receive an error “blueman.bluez.errors.DBusFailedError: Protocol not available”. In which case, reinstalling this plugin may resolve the issue.

 

* SBC is supposedly mandatory in the implementation of A2DP. However, I noticed a jump in audio quality from PulseAudio’s default A2DP to EHfive’s SBC implementation. It’s possible that vanilla PA from the Debian repos doesn’t actually use SBC (if that’s possible, I don’t know), or it defaulted to a lower quality setting.