[Deprecated] [TESTING] Bluetooth audio streaming (A2DP)

hi, you have mentioned downgrade and problem disappeared. Can you advise me how to do so??
I have try to flash old version to SD card and still have the problem.

Nothing special, simply used the OSMC installer with the previous version.

i used my old systemd Services to reconnect after reboot:

1: i made a script in /var/scripts/ called startBTaudio.sh with chmod 755

#!/bin/sh
echo "connect YOURMACADDRESSOFSPEAKER" | bluetoothctl
echo "exit" | bluetoothctl

2: in /etc/systemd/system i create a file named BTspeaker.service

[Unit]
Description=Bluetooth Speaker automatic connect

[Service]
Type=simple
ExecStart=/var/scripts/startBTaudio.sh

3: in /etc/systemd/system i create a file named BTspeaker.timer

[Unit]
Description=Run Script after some time

[Timer]
# Time to wait after booting before activation
OnBootSec=45
Unit=BTspeaker.service

[Install]
WantedBy=multi-user.target

and enable this service with

systemctl enable BTspeaker.timer

because it’s not stable over 24 hours i did also a systemd.timer Job who restart my osmc early in the morning…

1: i made a script in /var/scripts/ called reboot.sh with chmod 755

#!/bin/sh
sudo reboot

2: in /etc/systemd/system i create a file named reboot.service

[Unit]
Description=Reboot System automatically

[Service]
Type=simple
ExecStart=/var/scripts/reboot.sh

3: in /etc/systemd/system i create a file named reboot.timer

[Unit]
Description=Reboot System with this script at 5:30 in the morning

[Timer]
# Time when script will start
OnCalendar=05:30
Unit=reboot.service

[Install]
WantedBy=multi-user.target

and enable this service with

systemctl enable reboot.timer

Hope this help in some cases

would be great if someone can help me out… i think about a timer script that check all 10 minutes Status of bluetootctl if the Speaker is connected, if not it will re-connect. that will let the above Code out of state. sadly i have no idea how to do so…
EDIT: I guess i got a Bashscript who reconnects with a timer Service but i Need to test at home

 #!/bin/bash
 mac_addr=“YOURMACADDRESS”
 if bluetoothctl <<< “info $mac_addr” | grep -qi “Connected: no”; then
      bluetoothctl <<< “connect $mac_addr”
 else
      echo "Bluetooth is connected"
 fi

Hi,

Did someone manage to stream sound via bluetooth to OSMC and output it to the connected USB soundcard? The USB soundcard is selected as audio output in OSMC but no sound when streaming. What would I have to configure for the bluetooth stream going to the USB soundcard?

Thanks!

Yes I set it to use Alsa:Osmc streaming to Bluetooth speaker, I may have from memory changed dtparam=audio=on to =off, I can’t check right now.
My problem was going from headless to monitor and back again and sound being routed to hdmi.

It works! I was mislead by the naming I guess.

Thank you!

On RPi 3 on latest update the devices are discovered and are able to connect.
But… when I try to stream the audio it’s stuttering what makes it unusable.

Can I somehow improve that? Try other options or test some new packages?

Same here. I posted my details earlier, see: [Deprecated] [TESTING] Bluetooth audio streaming (A2DP) - #285 by zulu

From testing i’ve found the rpi3 bluetooth to do the same. An external dongle works perfectly though. I guess it’s the bluetooth drivers for the internal BT are not up to speed as the other dongles at this point.

As a workaround for the time being you can inhibit the internal BT and use an external dongle.

Put this in you /etc/modprobe.d/raspi-blacklist.conf file:

blacklist btbcm
blacklist hci_uart

That will blacklist the internal BT from starting up and will utilise an external BT dongle.

Appreciate that’s not an ideal solution but it’s the best i’ve found so far.

dtoverlay=pi3-disable-bt

should also work in config.txt

1 Like

Even better! Didn’t know about this method. Nice.

1 Like

Just a short update, with May update I still experience major stutters when streaming from my smartphone to Rpi3’s internal bluetooth. It’s consistently from any app I tried (YouTube, AmazonMusic).
I thought that maybe the following bullet point of the release notes might affect this but it didn’t:

Fixed an issue which could cause A2DP audio dropouts after updating
BlueZ support last month to include support for Raspberry Pi 3

Any new when using hifiberry?

1 Like

Hi there.

The fix that went into the May update fixes issues where connectivity would drop almost immediately when pairing an audio device. Previously, it would pair up only to immediately disconnect. This fixes that issue.

In regards to the issue you’re experiencing - the internal bluetooth still seems to be stuttering regularly and i imagine this will be fixed in a future update (bluez) but at the moment the only way i’ve found to get around this is to use a USB bluetooth adapter.

Is there any ideas on when the Pi3’s bluetooth can be used for a2dp streaming? I’ve followed the instructions for install, and even edited the /boot/config.txt, but I still get no sound whilst trying to stream from my phone to OSMC.

on another note, it may be beneficial to include that it doesnt work currently with Pi3’s BT currently, I wasted a good few hours trying to get it to work :slight_smile:

AFAIK there is no difference between Pi3 Bluetooth and any other.

I’ve tried multiple times from fresh installs, just get no sound at all, connectivity seems to be okay.

take alook at this post, and a few afterwards:

EDIT: Just realised it was yourself who replied to this. Is there a changelog of this function anywhere, so i can tell if its been updated since the post above was made?

Added support for Raspberry Pi 3’s internal Bluetooth adapter. This is particularly useful as we are developing streaming capabilities for OSMC.

The Pi3 build in Bluetooth is supported since the April Update. And supports the same functions that are described at the top of this testing thread. No other functions have been implemented.

Thanks, I wasn’t totally convinced that this was my issue, as my bluetooth would connect fine. The issue seems to be my sample rate, which seems excessive:

May 07 15:08:40 osmc pulseaudio[257]: W: [pulseaudio] module-loopback.c: Sample rates too different, not adjusting (44100 vs. 462613).
May 07 15:08:40 osmc pulseaudio[257]: W: [pulseaudio] module-loopback.c: Sample rates too different, not adjusting (44100 vs. 462613).

Pulseaudio can only handle <192k, but it seems highly unlikely my S6 edge+ is outputting at such high sample rates, even on low quality youtube videos

EDIT:
I’ve noticed that the sample rate actually “increases” until it reaches 462624, I can’t find out why this is at all!

Hi,

i’m using a RPi 3 running OSMC May 2016 2016.05-1.

I’m also using a Logitech Bluetooth Audio Adapter (this one).
Pairing/Trusting and Playback worked pretty much out of the box.

I just had to turn on Bluetooth and set audio output to “ALSA: OSMC streaming to Bluetooth speaker / headphones”.
Playback works without stuttering or anything.
Even synchronisation issues/audio delay is barely noticeable.

But there’s a problem. After a while (i mean a pretty random amount of
time ranging from just a few seconds to > 1h) audio playback suddenly stops
with the following error message:

ERROR: CDVDAudio::AddPacketsRenderer - timeout adding data to renderer

After rebooting the RPi, bluetooth would reconnect and playback is fine until the next time this error comes up.

A truncated log (with audio debug) can be found here:

the video i was playing was already running for a while, maybe 10
min, there was some visible stuttering (no sound stuttering) at 19:07
(line 2 to 9 in the log)
the sound went off at 19:10 (line 18)

another non truncated log from another instance of the same error:
http://paste.osmc.io/osicerupoq
with the error coming up at
20:08:27 35.352921 T:1411888112

NOTE:
i’m using a hdmi to vga adapter if that matters at all… (“VicTsing®Gold-plated HDMI to VGA Converter Adapter For PC”, i can’t post link because of forum restrictions)