[How-to] set up Bluetooth audio

Did you change to mybtdevice output in audio settings?

1 Like

That’s something we half supported a few years ago, but unfortunately it’s not trivial to support this again at this time.

Checked this on raspberry pi4 (own build, latest 19.1 kodi) and streaming from phone does not work. the phone plays the file and stream it via Bluetooth, but no sound is played on OSMC. this is in dmesg:

[  182.486977] Bluetooth: Dropping L2CAP data: receive buffer overflow

Steaming from OSMC to Bluetooth headphone is fine though, but it needs a manual audio output switching in the settings > System > Audio.

Only once, afterwards it will be automatic as soon as you switch on the bluetooth device.

1 Like

Somehow this isn’t working for me yet. I am trying to get a UE Megaboom to work with a Pi 3.

I went through the uninstall steps, which did not find anything to uninstall (in fact I don’t remember installing bluez-alsa before). Then I installed the packages (both those from the repos and the downloaded armv7-bluez-alsa-osmc) and rebooted. I was able to successfully pair and connect to my speaker with bluetoothctl (it shows as connected). I placed an .asoundrc file in ~osmc, based on the sample file (uncommented the lines, changed the MAC address and updated the hint), see below:

# This file describes the bluetooth sinks available for Kodi to play to
# add lines like the following for each BT device (speaker or headphones)

pcm.mybtdevice {
        type bluealsa
        device "88:C6:26:F2:DA:5A"
        profile "a2dp"
        hint { show on description "UE MEGABOOM"}
}

# using the MAC of the device (see bluetoothctl) instead of 12:34:56:78:9A:BC
# Use any letters or numbers for the description which will show up in Settings-System-Audio

Even after rebooting and reconnecting the BT speaker, it is not showing in Settings > System > Audio, and sound still goes through the analog and (presumably) HDMI port. In My OSMC, the speaker is listed as a paired BT device and I can connect it (the red icon turns blue).

What gives?

Let’s see if ALSA is doing what it should. Can you try:

sudo apt-get update
sudo apt-get install alsa-utils
speaker-test -c 2 -t wav -l 3 -Dmybtdevice

and can you post debug logs, please.

Got it. The issue was that the pairing failed – I hadn’t noticed I kept getting an authentication error. Here’s what worked for me:

  • Enter bluetoothctl
  • remove <mac> to remove any botched traces of the device
  • agent on
  • default-agent
  • power on
  • press and hold the BT button on the Megaboom until it starts flashing (or whatever it takes to get your speaker into pairable state)
  • connect <mac>
  • trust <mac>
  • pair <mac>
  • quit
  • Enter My OSMC > Network > Bluetooth
  • Select the entry for the Megaboom. The icon turned blue, and this time the speaker played its pairing sound (which it hadn’t done before).
  • Go back to Audio, and select ALSA: UE MEGABOOM (or whatever name you set)

So, as some sources on the net have indicated, the issue is with the order of BT commands. First connect, then trust, then pair – not the other way round.

Surely not the right order. And as you went again into MyOSMC > Network > Bluetooth afterwards to connect it surely show you still had an issue.
The right order in bluetoothctl is:

agent on
scan on
pair <MAC of the device>
trust  <MAC of the device>
connect  <MAC of the device>

Interesting but as @fzinken says it shouldn’t be. You seem to have missed out scan on from the bluetoothctl commands and there shouldn’t be a need for power on. TBH it should all be possible from My OSMC which is programmed to do things in the right order.

I think what can happen is a device can end up connected but only for non-audio services (like what’s needed for volume buttons). A difficult thing to debug. Removing the device completely and starting again is always a good strategy.

I’m certainly not an authority on this and somehow got to where I am with try and error.

Quite possibly the bluetoothctl sequence ended up with the speaker not being connected, and only the GUI sequence did that. Maybe connect after pair would have done the trick just as well.

A comment on bluetooth - Not getting an "Enter Pin" prompt when pairing with BLE device - Raspberry Pi Stack Exchange, as well as pulseaudio - Pairing Bose QC 35 over Bluetooth on Fedora - Unix & Linux Stack Exchange indicate that trust is required before pair, not after – which is consistent with my observations.

During one of my attempts I did in fact miss scan on, which resulted in a different error message (device not found). That implies there’s a different issue.

I can’t guarantee every part of the BT commands in the sequence is required (particularly default-agent and power on), it would take some extra commands to figure that out. A that point I was simply trying out solutions to similar-looking problems one by one.

What I can tell for sure is that pair – trust – connect reproducibly failed at the pair stage for me, whereas connect – trust –pair at least gave me a correctly paired device. However, if you have previously paired the device and not removed all traces, you might still have the trust stored somewhere, so a pair operation without a previous trust would succeed in your case, but not for a fresh setup.

If anyone else runs into similar issues, I would suggest trying the following sequence:

agent on
scan on
trust <mac>
pair <mac>
connect <mac>
scan off
agent off

Seems it’s in the repo now.

Yes, please see the OP as the package names have been changed.

Is it possibility to connect more then one Bluetooth headphones at the same time and watch movie?

I thought I remembered there was someone who tried it before. But when I was searching I only found this thread which says not possible

That user did follow up with a how-to but it’s not for the feint-hearted.

Had that in mind, but search “multiple bluetooth” didn’t made it show up

Found it. Not that user but @rupert_s

Thanks for info.

Will we get back the feature for showing track title and interpret and player controls in future releases?