[How-to] install bluez-alsa for Bluetooth audio

Bluez-alsa allows you to stream audio both to and from your OSMC device. We have been working on integrating bluez-alsa into OSMC as a replacement for our a2dp package which is now deprecated.

There is some more development work to be done to make the new package simple to use. Meanwhile, you can install bluez-alsa and make the necessary ALSA configuration files yourself. You need to be familiar with the commandline and a text editor (eg nano).

Update for Kodi v19 Our Kodi v19 builds include bluez-alsa so you don’t have to install the package. You still have to write a .asoundrc file.

If you have already installed bluez-alsa under v18, then please uninstall any previous versions first:

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

If you forget to do that and get an error when upgrading, run those uninstall commands, then:

sudo apt-get --fix-broken install

For Kodi v18

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

Re-boot to get the bluealsa service started.

For all versions of Kodi

Have a look at the file .asoundrc.example in your home directory for instructions on how to make a file .asoundrc to use with your BT headphones or speaker. You need to find out the device’s MAC number which looks something like 01:23:45:67:89:ab and put it into .asoundrc. The MAC will show up when you attempt to connect.

Connect your BT headphones/speaker using MyOSMC or bluetoothctl from the commandline and your device should show up in Kodi’s audio settings. If using bluetoothctl, start it from the commandline, make your BT device discoverable, then

agent on
scan on

Wait for your headphones/speaker to show up, then, using its MAC instead of 01:23:45:67:89:ab:

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
quit

You can also stream audio from your smartphone (eg) to your OSMC device by pairing and connecting them. Pair and trust your smartphone as above. 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.

4 Likes

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.

pgt44

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?
Regards,
Budgie

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.
Budgie

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: HDMI
PI: Analogue
PI: HDMI and Analogue

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

THANKS!!
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.
Budgie

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: