[How-to] set up Bluetooth audio

[Updated August 2021]

Bluez-alsa allows you to stream audio both to and from your OSMC device. We have now integrated bluez-alsa into OSMC as a replacement for our a2dp package which is deprecated. Our Kodi v19 builds include bluez-alsa. If you are still on v18.9, you can install it on Vero 4k or RPi 2/3 with:

sudo apt-get install armv7-bluezalsa-osmc

and re-boot to get the bluealsa service started.

If you have previously installed one of our older BT audio packages, you will need to remove it/them (see below).

Streaming to your OSMC device

This works out-of-the-box. Just use My OSMC → Networking → Bluetooth to pair and trust your source (eg a smartphone). You should now be able to choose your OSMC device in the list of BT devices on your smartphone.

Make sure Kodi isn’t trying to use HDMI audio at the same time - turn off “Keep audio device alive” in Settings->System->Audio.

Streaming from your OSMC device

This currently needs some manual work to make the necessary ALSA configuration file. You need to be familiar with the commandline and a text editor (eg nano).

You need to make a file called .asoundrc in your home directory (/home/osmc) to use with your BT headphones or speaker. Your .asoundrc file should look like this

pcm.mybtspeaker {
        type bluealsa
        device "01:23:45:67:89:AB"
        profile "a2dp"
        hint { show on description "My BT Speaker"}

mybtspeaker can be any name you like, as long as it’s unique.

01:23:45:67:89:AB is a bluetooth MAC address. You need to substitute the MAC address of your speaker/headphones. You may see this when you connect it using My OSMC. If not, use bluetoothctl devices to find it.

My BT Speaker can also be anything you like and it will show up in Kodi’s list of audio devices.

If you have more than one BT audio device, make a separate entry in .asoundrc for each of them.

After saving the .asoundrc file, re-start Kodi (Power->Exit) or disconnect and re-connect your BT device so that Kodi knows it’s available.

Connecting using bluetoothctl

If you can’t connect using My OSMC, try using the command bluetoothctl. Start it from the command line, make your BT device discoverable, then type

agent on
scan on

Wait for your headphones/speaker to show up, then, using its MAC instead of 01:23:45:67:89:ab (bluetoothctl supports tab completion so type, eg 01 Tab):

pair 01:23:45:67:89:ab
trust 01:23:45:67:89:ab
connect 01:23:45:67:89:ab
scan off
agent off

Removing older BT audio packages

OSMC used to ship a package called a2dp-app-osmc which used a customised version of pulseaudio. This needs to be removed as we no longer support pulse. Also remove any previous version of this bluez-alsa based package.

sudo dpkg -r armv7-bluez-alsa-app-osmc
sudo dpkg -r armv7-bluez-alsa-osmc
sudo apt-get --fix-broken install
sudo apt-get remove --purge a2dp-app-osmc
sudo apt-get remove --purge pulseaudio-module-bluetooth
sudo apt-get remove --purge pulseaudio

Marvellous grahamh - many thanks for the heads up.

I spent half a day trying to work around why a2dp no longer worked on the Oct version of OSMC. I was thinking I might have to just revert to the Jun version (BT fine(ish) for internal Pi3 BT).

But no need - your helped worked like a dream! Am now listening happily to carols through Bluealsa service and my Bose.


Glad it works. This is very much a temporary implementation (WIP).

Hi Graham,
Just repeating the installation of bluez-alsa using your notes and find I can no longer find libfdk-aac1 as in your post

We have compiled bluez-alsa for Vero and Pi2/3. Download armv7-bluez-alsa-osmc.deb from here https://collab.osmc.tv/s/hxG3JX4m3rY2XiM and put it onto your Vero/Pi. Run

sudo apt-get install wget libbluetooth3 libsbc1 libfdk-aac1
sudo dpkg -i armv7-bluez-alsa-osmc.deb

Any idea how I can find this library item?

What do you see when you type

sudo apt-get install libfdk-aac1 ?

This is what I have:-

abr@rpi-sound:~ $ sudo apt-get install libfdk-aac1
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package libfdk-aac1 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘libfdk-aac1’ has no installation candidate
abr@rpi-sound:~ $

BTW as suggested by others I have now moved to Raspberrypi OS Lite so although I had been working with your earlier posts I notice that I was using an osmc repo so it is possible I have a crossed wire in my head.

As you may recall I had everything working well with your advice on bluez-alsa except for getting the playing using mpd and connecting to BT device.
Moving to the OS Lite I have gone backwards with the new OS card installed. I can easily switch back but I couldn’t get the mpd player working. If you are able and have the time I can swap SD card and resume from where I had reached. Let me know. I am on my own because of Covid and rest of family abroad so happy to press on if you are.
Otherwise again, Happy Christmas.

Thanks. So I was able to connect to my bluetooth speaker but no audio is coming through. In the GUI in OSMC it shows as connected with the blue logo. I enabled gui sounds and I can hear them if I plug in my headphones plugged into the raspberry pi but not the speakers. Is this a audio settings issue?

If I shouldn’t be selecting HDMI as output device in audio settings, what should I select?
I only have these options:

ALSA: DEFAULT( bcm2835 ALSA bcm2835 ALSA)
ALSA: BCM2835 alsa, BCM2835 ALSA
PI: Analogue
PI: HDMI and Analogue

bluetooth speaker definitely works. I can play via my mac.

I also turned Keep Audio Device Alive off

Seems you are missing your Bluetooth device.
Did you create an appropriate .asoundrc?

Ok, stupid mistake on the file. Yeah it’s working now!! THANK YOU . This is amazing

Hi grahamh,
I am stuck with this libfdk-aac1 and libfdk-aac-dev. Can you help please?

If you are compiling bluez-alsa on RaspberryPiOS then the right place to ask would be Raspberry Pi forums. Otherwise try the bluez-alsa guys on github. Note RasberryPiOS now uses pulseaudio instead of bluez-alsa so that may provide a solution for you.

If you are using mpd on OSMC I’ve no experience of that. OSMC supports Kodi and has no need of other players.

Hi Graham and many thanks for your reply. Your help with bluez-alsa is much appreciated and my RPi3 with OSMC installed and your bluetooth advice worked a treat, as did upnpdcli but I couldn’t get the mpd part to work and play to BT device.

Rather than unpick the Kodi setup I thought I would try a Raspberry Pi OS lite and just install what I needed and you are right to point me to RPi forum.

I tripped up on one of the dependencies, libfdk-aac1 which was not in the Raspbian version of Buster. I think it is in the Debian non-free repo but have hesitated to try and fetch it from there because I do not know if apt will sort out the fact that I need a 32 bit arm version. But shall continue through RPi Forum. Just wanted to say thanks again.
best wishes for the New Year.

1 Like

This works, nice! Only when connecting through command line though. Always fails connecting to speakers in MyOSMC.

I’ve followed the instruction to the letter and managed to connect to the ENACFIRE Future headphones and stream audio over it.
Previously I couldn’t even pair RPI 3b bluetooth and the headphones, so thank you @grahamh.

I have a small issue though. The streaming is not continuous, it drops pretty frequently and comes back almost immediately - quite annoying :slight_smile:

Is there anything I can do about it?

We might be able to see something in debug logs if you could grab those. I can’t recall if there’s an option for logging of bluetooth but if there is, turn it on.

I’ve done the following:

  1. Enabled debug and event logging

  2. Connected the headphones

  3. Started a movie

  4. Got a few drops every few seconds

  5. Stopped the movie

  6. Grabbed the logs (grab-logs -A)

Hopefully this will provide useful information.

Can you try turning off DD capable receiver and changing audio to Best match?

Do you mean Output configuration -> Best match?
Where can I find DD capable receiver option?

My bad - you have passthrough turned off anyway. Dolby Digital capable receiver shows up when Settings level is Advanced or Expert only when passthrough is enabled.

Any luck with Best match?

Unfortunately not :frowning: