[How-to] set up Bluetooth audio

It’s not high on the todo list, unfortunately. It was implemented by a virtual audio player which someone developed for earlier Kodi versions but it hasn’t been updated and the author is no longer around. Quite a lot of work for someone to pick up. How are your coding skills?

exist an old patch file to see the modifications?
would work the addon for patched kodi or will need it mods too?

There was something called BTplayer but it seems to have gone from the osmc github.

The problem is the way that BTPlayer ‘knew’ when audio was being streamed to it would likely need changing as we don’t use PulseAudio anymore.

I’m doubtful whether bluez-alsa has the ability to get the track and volume information.

there’s no .asoundrc.example file after upgrarding but I found this thread to be helpful - My Bluetooth speakers won't connect either! - #22 by grahamh

Hi,

i have not tried to stream to my BT-Headphone’s yet but at least both were listed in Settings->Audio->Output with the provided .asoundrc-template.
This really should find it’s place back in ~/.asoundrc.template or at least in here.

Am I correct to look into /usr/share/kodi/addons/script.module/omcsetting.networking/ressources/lib/osmcnetworking/*py, especially osmc_bluetooth.py, to try to implement an ‘Add Alsa-Plug’-Button in the Drop-Down-Field?
First i thought about a shell-script but now that i found the Python-Files I would need to comb through them…
Or maybe just an dirty os.exec()/shutil…with a Shell-Script. My Python-Skills aren’t that sophisticated.
But on the other hand, one should first check if the device can stream Audio before allowing this action. So even more to look up…

Maybe I will first write a shell-script as helper for lets say adding a device with connectbot from my mobile’ or just being lazy…
echo "exit" |bluetoothctl |grep Device |cat -A |cut -c59- |rev |cut -c2-|rev
… got rid of everything ‘nasty’ and the rest will have to do later when i have the time.

That is, if anyone would be interested.

with regards,
Christopher

PS: This would even be my second official contribution to osmc after one in ~2014 :joy:

got bored waiting for someone who didn’t show…

image

Thanks for your interest, but can you explain what problem this solves?

this doesn’t solve a problem, it just makes things easier… as i mentioned…
I couldn’t switch to my headset until i found this thread. i didn’t need it… it was just annoying that i even had to look around why the … my Headset wasn’t shown in the Audio-Output. And didn’t have that much time either.
With my former device , an wetek play 2 and libreelec it just worked out of the box…
And know that i got myself a new Vero, i just thought this would be a given… my bad.

And for the Shell-Script. One could wrap ‘dialog’ or ‘whiptail’ around and read the current .asoundrc… to check if the Device is already listed. or something or just overwrite it …
i would have welcomed a executable to just generate the config a week ago.

with regards,
Christopher

Sorry, I’ve been away with patchy internet access.

Thanks for your contribution - I see now what the objective is and it’s something we’ve been working on. We do have some python which generates the required alsa nodes but it wasn’t released because it was in MyOSMC networking and wouldn’t recognise a connection via bluetoothctl. There are changes needed in Kodi to listen for a BT audio device connection.

Meanwhile, the latest bluez-alsa version made a change so that a .asoundrc is unnecessary. I think that will be in the next OSMC release which should be out within days - I’ll check. With that, OSMC will recognise automatically the last BT device to connect.

Fixed, thanks.

I’ve had this set up and running without problems on the previous Kodi version, but since upgrade to Kodi V19 it’s not working.

Although I still have both BT headphones paired up and I’m able to connect with them, I cannot see the entries in Settings->System->Audio->Audio output device.

I can see that bluealsa service is running:

osmc@osmc:~$ sudo systemctl status bluealsa
* bluealsa.service - Bluealsa daemon
   Loaded: loaded (/lib/systemd/system/bluealsa.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-11-02 20:30:55 CET; 1 weeks 2 days ago
     Docs: https://github.com/Arkq/bluez-alsa/
 Main PID: 359 (bluealsa)
    Tasks: 3 (limit: 975)
   CGroup: /system.slice/bluealsa.service
           `-359 /usr/bin/bluealsa -p a2dp-source -p a2dp-sink --a2dp-volume

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

Here is my .asoundrc:

# 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.mybtspeaker {
        type bluealsa
        device "00:00:90:B0:EF:77"
        profile "a2dp"
        hint { show on description "ENACFIRE Future"}
}

pcm.mybtspeaker {
        type bluealsa
        device "64:03:7F:56:E6:ED"
        profile "a2dp"
        hint { show on description "Galaxy Buds+"}
}

# 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$

Any suggestions?

Please turn on debug logging, re-start Kodi (Power->Exit) and post full logs.

Here is the log.

Also, since I enabled logging, I’ve noticed that my FPS is anywhere between 5 and 15 which seems low. Is this to be expected while sitting in the main menu?

You must use a different name for each BT device pcm. eg pcm.enacfire and pcm.galaxybuds.

I’ve renamed the pcm entries, saved the file, rebooted rpi3.
It didn’t help unfortunately. Still can’t see the entries for BT headphones in audio settings.

Note your device(s) will only show up if they are connected. You may have to restart Kodi (Power->Exit) after the first time you connect a BT device.

If that doesn’t help post your .asoundrc and logs again, please.

That did it, at least for ENACFIRE headset.

Galaxy Buds+ are not working, although I’ve succesfully paired them again. I manage to connect to them, I can choose them in the Audio menu, but there is no sound coming to them afterwards.
If I try to play any movie, it starts stuttering after a few seconds and then freezes.

Here is the output of the bluetoothctl pairing and connecting to Galaxy Buds+:

[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:A8:15:31 Discovering: yes
[NEW] Device 64:03:7F:56:E6:ED Galaxy Buds+ (E6ED)
[CHG] Device 64:03:7F:56:E6:ED RSSI: -74
[bluetooth]# pair 64:03:7F:56:E6:ED
Attempting to pair with 64:03:7F:56:E6:ED
[CHG] Device 64:03:7F:56:E6:ED Connected: yes
[CHG] Device 64:03:7F:56:E6:ED Modalias: bluetooth:v0075pA012d0001
[CHG] Device 64:03:7F:56:E6:ED UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device 64:03:7F:56:E6:ED UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
[CHG] Device 64:03:7F:56:E6:ED UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device 64:03:7F:56:E6:ED UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device 64:03:7F:56:E6:ED UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Device 64:03:7F:56:E6:ED UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 64:03:7F:56:E6:ED UUIDs: a23d00bc-217c-123b-9c00-fc44577136ee
[CHG] Device 64:03:7F:56:E6:ED UUIDs: b4a9d6a0-b2e3-4e40-976d-a69f167ea895
[CHG] Device 64:03:7F:56:E6:ED UUIDs: e7ab2241-ca64-4a69-ac02-05f5c6fe2d62
[CHG] Device 64:03:7F:56:E6:ED UUIDs: f8620674-a1ed-41ab-a8b9-de9ad655729d
[CHG] Device 64:03:7F:56:E6:ED ServicesResolved: yes
[CHG] Device 64:03:7F:56:E6:ED Paired: yes
Pairing successful
[CHG] Device 64:03:7F:56:E6:ED ServicesResolved: no
[CHG] Device 64:03:7F:56:E6:ED Connected: no
[bluetooth]# trust 64:03:7F:56:E6:ED
[CHG] Device 64:03:7F:56:E6:ED Trusted: yes
Changing 64:03:7F:56:E6:ED trust succeeded
[bluetooth]# connect 64:03:7F:56:E6:ED
Attempting to connect to 64:03:7F:56:E6:ED
[CHG] Device 64:03:7F:56:E6:ED Connected: yes
Connection successful
[CHG] Device 64:03:7F:56:E6:ED ServicesResolved: yes

Here is the .asoundrc:

# 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.enacfire {
        type bluealsa
        device "00:00:90:B0:EF:77"
        profile "a2dp"
        hint { show on description "ENACFIRE Future"}
}

pcm.galaxybuds {
        type bluealsa
        device "64:03:7F:56:E6:ED"
        profile "a2dp"
        hint { show on description "Galaxy Buds+"}
}

# 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$

Here are the logs.

I’m using RPI3 internal bluetooth, wireless is off.
I’ve also tried rebooting/poweroff, but it didn’t help.

Hmmm, I’ve seen this before but can’t remember what it signified and how we got rid of it

2021-11-14 22:47:19.059 T:423     ERROR <general>: ActiveAE::FlushEngine - failed to flush

If you switch to the default audio device then back to the galaxy buds, does that work better?

Do you mean video and audio or just audio?

Switching back an forth between the default audio device and Galaxy Buds didn’t do anything.

The moment I select Buds from Audio meni, the sound disappears.

Regarding the stuttering, I was referring to video as there is no sound.

One thing you should do is remove the old armv7-bluez-alsa-osmc as shown here.

Then you may find the next update makes things better.