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

You mean with the built-in one cause with the dongle works already.
It is very logical, if onboard BT works this should work as well, but the reason why I asked is that I saw some comment from Sam saying that built-in BT will support file transfer…I tough only that … :slight_smile:

Yes with the build in one

Anyone here been able to connect a Windows 10 laptop ?
I can stream from my android phone flawlessly, but can’t even connect to my Asus UX32A laptop with Windows 10…
I’m using the Pi3 with inbuilt bluetooth.

How to remove this package my hifiberry digi isn’t working any more

pls help!

I have no problem at all. Acer Switch 11 with Core i3. Win 10 x64. I did of course had to enable discovery again via MyOsmc and I also enabled “allow devices to find this computer” on my laptop. Works fine.

After a recent release and providing support to RPi’s onboard Bluetooth chip I was trying to stream audio to a bluetooth speaker (Philips OTR 7500). I was able to find the device, pair & connect to it but after few seconds it keeps disconnecting. This is probably the same problem as @ytandogan described in https://discourse.osmc.tv/t/raspberry-pi-3-bluetooth-mega-thread/13977

In journalctl I saw some errors:
Suspend: Connection timed out (110)
Abort: Connection timed out (110)

Any ideas?

The changelog for OSMC 2016.04-01 says:

  • Improved A2DP Bluetooth audio streaming
  • Updated to BlueZ 5.38

What has changed? And does BlueZ mean we won’t need PulseAudio in the near future? (thus enabling the goodies from HiFiberry like AMP and DAC?) Or is that not related at all?

I tried the new release yesterday and am able to pair my Pi 3 with my phone.
Once starting to stream from my phone to OSMC I hear the music but it starts immediately to stutter, and sounds quicker than the original music is. Sometimes it simply stops until I stop the playback on my phone and start it again (with the same result).
I have no issues with other bluetooth devices (bluetooth speaker, car audio,…) when streaming from my phone.
The app I’m streaming from is Amazon Prime Music on Android. Streaming from another app (like YouTube) seems to work, but I guess there are different codecs/bitrates involved causing the issue.

I checked the kodi.log in debug but it does not show anything. But journalctl contains the appended output.
The lines at the end (“frame assembly failed”) repeat quite often so I took only some of them.

Hope that helps finding the issue.
Thanks again for the great support!

Apr 04 17:39:50 osmc bluetoothd[422]: /org/bluez/hci0/dev_C0_EE_FB_59_04_C1/fd0: fd(20) ready
Apr 04 17:39:50 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write!
Apr 04 17:39:50 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Most likely this is a bug in the ALSA driver '(null)'. Please report this issue to the ALSA developers.
Apr 04 17:39:50 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
Apr 04 17:39:53 osmc kernel: input: C0:EE:FB:59:04:C1 as /devices/virtual/input/input4
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c: snd_pcm_delay() returned a value that is exceptionally large: -2070740 bytes (-11738 ms).
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c: Most likely this is a bug in the ALSA driver '(null)'. Please report this issue to the ALSA developers.
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c: snd_pcm_dump():
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c: Hardware PCM card 0 'bcm2835 ALSA' device 0 subdevice 0
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c: Its setup is:
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   stream       : PLAYBACK
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   access       : MMAP_INTERLEAVED
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   format       : S16_LE
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   subformat    : STD
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   channels     : 2
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   rate         : 44100
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   exact rate   : 44100 (44100/1)
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   msbits       : 16
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   buffer_size  : 4408
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   period_size  : 1104
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   period_time  : 25034
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   tstamp_mode  : ENABLE
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   period_step  : 1
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   avail_min    : 1104
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   period_event : 1
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   start_threshold  : -1
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   stop_threshold   : 1155530752
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   silence_threshold: 0
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   silence_size : 0
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   boundary     : 1155530752
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   appl_ptr     : 490084
Apr 04 17:40:12 osmc pulseaudio[255]: E: [alsa-sink-bcm2835 ALSA] alsa-util.c:   hw_ptr       : 485676

Apr 04 17:41:21 osmc pulseaudio[255]: W: [pulseaudio] module-loopback.c: Sample rates too different, not adjusting (44100 vs. 78987).
Apr 04 17:41:27 osmc pulseaudio[255]: E: [bluetooth] module-bluez5-device.c: SBC decoding error (-3)

Apr 04 17:42:32 osmc kernel: Bluetooth: hci0: Frame reassembly failed (-90)

Apr 04 17:42:32 osmc pulseaudio[255]: E: [bluetooth] module-bluez5-device.c: SBC decoding error (-2)
Apr 04 17:42:32 osmc kernel: Bluetooth: hci0: Frame reassembly failed (-84)
Apr 04 17:42:32 osmc kernel: Bluetooth: hci0 SCO packet for unknown connection handle 9156
Apr 04 17:42:32 osmc kernel: Bluetooth: hci0: Frame reassembly failed (-84)
Apr 04 17:42:32 osmc kernel: Bluetooth: hci0: Frame reassembly failed (-84)
Apr 04 17:42:32 osmc kernel: Bluetooth: hci0: Frame reassembly failed (-84)

Just after the laest update I can’t connect to my BT dongle - It connects for a few seconds then disconnects presumably a problem with the bluetooth system and the new update?

Can I just re write the previous version on to the card and re-install the bluetooth stuff?

Here is the log file output as I try and connect.

06:10:55 1136.383423 T:1877607408 WARNING: CActiveAE::StateMachine - signal: 1 from port: OutputDataPort not handled for state: 1
06:11:00 1141.884277 T:1877607408 WARNING: Previous line repeats 2 times.
06:11:00 1141.884644 T:1877607408   ERROR: ActiveAE::InitSink - failed to init
06:11:00 1141.884888 T:1877607408 WARNING: CActiveAE::StateMachine - signal: 1 from port: OutputDataPort not handled for state: 1
06:11:06 1147.386108 T:1877607408 WARNING: Previous line repeats 4 times.
06:11:06 1147.386353 T:1877607408   ERROR: ActiveAE::InitSink - failed to init
06:11:06 1147.386597 T:1877607408 WARNING: CActiveAE::StateMachine - signal: 1 from port: OutputDataPort not handled for state: 1
06:11:11 1152.888428 T:1877607408   ERROR: ActiveAE::InitSink - failed to init
06:11:13 1155.039185 T:1520165872   ERROR: DoWork - Direct texture file loading failed for resource://resource.images.weathericons.default/.png
06:11:17 1158.389648 T:1877607408   ERROR: ActiveAE::InitSink - failed to init
06:11:17 1158.390747 T:1877607408 WARNING: CActiveAE::StateMachine - signal: 13 from port: OutputControlPort not handled for state: 1
06:11:22 1163.891968 T:1877607408   ERROR: ActiveAE::InitSink - failed to init
06:11:28 1169.393433 T:1877607408   ERROR: Previous line repeats 1 times.
06:11:28 1169.394287 T:1877607408 WARNING: CActiveAE::StateMachine - signal: 1 from port: OutputDataPort not handled for state: 1
06:11:33 1174.895508 T:1877607408 WARNING: Previous line repeats 5 times.
06:11:33 1174.896606 T:1877607408   ERROR: ActiveAE::InitSink - failed to init

awesome! it works perfectly and stable :slight_smile:
no need for my scriptwork i posted in late october!

only thing i have trouble is to get it re-connecting after reboot…
no idea how to make a cron Job? would be a systemd service/timer not better?

Worked great on PI2 until the latest update (2016.04-01). Now my Bluetooth headset connects and then instantly disconnects (logs can be found here: http://paste.osmc.io/zepanojafo)

Would appreciate any idea.

Thanks!
Adi

Update: downgraded OSMC, and the problem disappears

1 Like

Similar issue here after the last update

I have the same problem of @adilei with April upgrade Now my Bluetooth headset connects and then instantly disconnects. Thanks

1 Like

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?