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

I have been trying it, but I can’t.

Could we please start creating a list of “working” Bluetooth dongles?
If anyone wants to buy one to try this out it would be good to know what to buy.

Also, has anyone been able to test this with a HifiBerry DAC+ ? Since the analog output of the Raspberry Pi2 has low audio quality (limited to 8Bit, you can notice the difference!).

Do any one do Iphone BT pair and connect to Osmc without touching OSMC?

I just tried to make my Vero OSMC (October release) stream to my BT headphones, but wasn’t quite successful. Is that a feature that should theoretically work or should I better stop trying?

It’s not working on all platforms yet, in particular platforms that use ALSA. @DBMandrake and I need to look in to this.

Sam

Hi Sam,
Just tried out the “wget http://paste.osmc.io/raw/qiyekuvafe -O- | sudo sh” approach on OSMC 2015.10-1 with a CSR CSR8510 A10 USB dongle with a RPi B+.

The script runs for 98% and than crashes OSMC completely into a reboot. Rerunning the script yields the same results.
It there a better way to install and test A2DP?

I would like to use the RPi for receiving audio from my phone and playing it to a hifi set connected to the audio jack.

If you could provide some pointers I will test again and provide you the results. If you need any logs/outputs, let me know.

Regards, Ruud

had that too, fixed it with rfkill:

apt-get install rfkill

search for device:
rfkill list

check bluetooth device id (maybe 0)

rfkill unblock 0

There shouldn’t be any need for you to install rfkill - connman has this built in and does it automatically for Bluetooth devices. Debug logs might show why this was not working for you.

you’re right, when powering the device with connman first, there is no need to do the rfkil thing, thanks

two more questions:

I’m using a iPhone 5S to stream music to Kodi, a manual connect, works fine. How to configure the controller to connect directly when the device is in range?

Is it possible to send commands do the connected BT device (next track …) maybe with avrcp ?

regards

Hi,

I have Raspberry Pi 2 with OSMC nov.2015 and very old bluetooth dongle. It worked, when I follow the instructions on link: http://www.instructables.com/id/Enhance-your-Raspberry-Pi-media-center-with-Blueto so I think it should be ok.

So far I run
sudo apt-get update && sudo apt-get install wget http://paste.osmc.io/raw/qiyekuvafe -O- | sudo sh

but installation stopped at step
Processing triggers for dbus (1.8.20-0+deb8u1) ...
and OSMC restart itself. When I select audio output to bluetooth in KODI, audio from jack stops working even if I change back to audio output. If I set audio out back to analog and restart OSMC, then i get sound from audio jack.

  1. I can pair and connect my phone to OSMC, but when I start playing phone disconnect immediately.

  2. I can pair and connect OSMC to Belkin U25 bluetooth audio device. It connected successfully but no sound come from Belkin. Is this in connection with bluetooth audio output in KODI which in my case doesn’t work?

Could a successful installation remove the this problems? How can I install without errors?

Thanks for your help.

You cannot mix both sets of instructions. Did you follow these steps on a new install?

Yes. I repeat the whole process on fresh install and I got the same error. The problem is, that OSMC suddenly reboot at the same step of upgrading to bluetooth as before:

Setting up a2dp-app-osmc (1.0.5) ...
Processing triggers for libc-bin (2.19-18+deb8u1) ...
Processing triggers for systemd (215-17+deb8u2) ...
Processing triggers for dbus (1.8.20-0+deb8u1) ...

During upgrading I found this problem:

dpkg: dependency problems prevent configuration of a2dp-app-osmc:
 a2dp-app-osmc depends on pulseaudio; however:
  Package pulseaudio is not installed.
 a2dp-app-osmc depends on pulseaudio-module-bluetooth; however:
  Package pulseaudio-module-bluetooth is not installed.
 a2dp-app-osmc depends on pulseaudio-module-zeroconf; however:
  Package pulseaudio-module-zeroconf is not installed.
dpkg: error processing package a2dp-app-osmc (--install):
 dependency problems - leaving unconfigured
Processing triggers for dbus (1.8.20-0+deb8u1) ...
Errors were encountered while processing:
 a2dp-app-osmc

Could this be an issue? How can I fix this?

Thanks.

Hi

Did you run sudo apt-get update before installing the a2dp package?

I would try:

sudo apt-get update
sudo apt-get install -f

this should then install the missing pulseaudio packages

Yes I did as described above. I installed fresh OSMC 2015.10-1, run sudo apt-get update and sudo apt-get install. A also try sudo apt-get install -f but I got the same error.

If your system has randomly rebooted in the middle of installing packages, this is why you are having problems. There will be a partially installed package, and very likely file system corruption too.

You really need to find why your system is unstable first and resolve that issue before proceeding. I would start by setting your overclock back to normal if you have increased it.

Is the command from the first post unchanged?
I performed update via MyOSMC. Just to be sure I also ran:
sudo apt-get update && sudo apt-get dist-upgrade
then I ran the command from the first post:
wget http://paste.osmc.io/raw/qiyekuvafe -O- | sudo sh

Find the log here, it shows errors, also the system rebooted automatically at the end of that log.
http://pastebin.com/6eH7FcTv

But what is the next step? After the auto reboot, my Android HTC phone finds 2 Bluetooth devices, but only show the MAC addresses so I have no clue if it is a device from my neighbours.

So I tried myself:
osmc@KodiTV:~$ bluetoothctl [NEW] Controller 00:1A:7D:DA:71:13 KodiTV [default]

I cannot find devices with that MAC address. Also, I do not know the Bluetooth MAC address of my phone… so I cannot connect using bluetoothctl connect [MAC].

EDIT:
Oh no! Now that I installed Bluetooth, my HiFiBerry DAC+ is no longer working. It is missing in the list of Audio Outputs, it seems to have been replaced by ALSA:Bluetooth.
Would it be possible to use a HiFiBerry DAC in combination with Bluetooth App if I only want to stream to OSMC? And potentially output the audio via HiFiBerry DAC?

Hi…

I’ve been testing A2DP integration (audio from osmc to headphones), and it’s fantastic!.. when it works.

Apart from the minor issue of re-pairing when rebooting the pi (surprising thing is that not always I reboot the pi I need to re-pair it), the annoying thing is that usually, when disconnecting and reconnecting headphones, the sound just disappears and can’t hear anything from tv neither from the headphones… It seems like audio engine in kodi gets crazy sending the sound to nowhere. In this case if I force audio output to HDMI and try to play a movie, kodi just gets freeze (OS is up). Bluez stack seems to work properly, detecting correctly if the headphone is connected or not in any moment.

In the case I reboot the pi without changing previously to HDMI output, the issue of no having sound persists, it doesn’t matter if the headphone is on or off. I need to force HDMI output, reboot my pi… then I can recover the sound from my TV. Once TV sound is working, if I repeat the process, changing again to Alsa:Osmc bluetooth output, it works again until the next issue when powering on or off my headphones. As I said when it works, the sound is just perfect no crackling audio or disconnects.

I’m running a raspberry pi 1 (B model), connected directly a bluetooth dongle with csr8510 a10 chipset (it’s a Inateck model that works pretty well in Linux/Raspi… except in this scenary).

Reviewing kodi.log when the issue appears I see some strange erros with Kodi audio engine when playing a movie (no sound):
ERROR: CAESinkALSA - snd_pcm_writei(-32) Broken pipe - trying to recover
The following one repeats during all the play:
ERROR: ActiveAE::FlushEngine - failed to flush

When rebooting the PI after kodi freeze:
23:23:42 5269.300781 T:2944984096 ERROR: ActiveAE::InitSink - failed to init
23:23:43 5270.281250 T:3008533536 ERROR: CAESinkALSA - snd_pcm_writei(-5) Input/output error - trying to recover
23:23:43 5270.281250 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(1)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.281738 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - underrun
23:23:43 5270.282227 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_prepare returned -5 (Input/output error)
23:23:43 5270.307617 T:3008533536 ERROR: CAESinkALSA - snd_pcm_writei(-5) Input/output error - trying to recover
23:23:43 5270.308105 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(1)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.308105 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.333496 T:3008533536 ERROR: CAESinkALSA - snd_pcm_writei(-5) Input/output error - trying to recover
23:23:43 5270.333984 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(1)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.333984 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.359863 T:3008533536 ERROR: CAESinkALSA - snd_pcm_writei(-5) Input/output error - trying to recover
23:23:43 5270.360352 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(1)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.360352 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.385742 T:3008533536 ERROR: CAESinkALSA - snd_pcm_writei(-5) Input/output error - trying to recover
23:23:43 5270.386230 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(1)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.386230 T:3008533536 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -5 (Input/output error)
23:23:43 5270.411621 T:3008533536 ERROR: CActiveAESink::OutputSamples - failed
23:23:43 5270.412109 T:3008533536 ERROR: CEngineStats::UpdateSinkDelay - inconsistency in buffer time

Regards,

After some more testing… more interesting things. In kodi audio output settings, usually appears as output device “ALSA:OSMC streaming to Bluetooth speaker/headphones”, but sometimes when i reboot the raspberry pi, this option dissapears and two additional devices are added, something like these: ALSA: playback/recording… and ALSA:PulseServer… . The behaviour is the same than with the previous device.

Now I discover new errors in kodi log when trying to play a movie with no sound comming from TV/headphones in both cases (headphones on and off):
14:17:12 453.030579 T:2944857120 ERROR: ActiveAE::InitSink - failed to init
14:17:12 453.030945 T:2944857120 WARNING: CActiveAE::StateMachine - signal: 10 from port: OutputControlPort not handled for state: 1
14:17:12 453.031158 T:2944857120 WARNING: CActiveAE::StateMachine - signal: 11 from port: OutputControlPort not handled for state: 1
14:17:12 453.031372 T:2944857120 WARNING: CActiveAE::StateMachine - signal: 7 from port: OutputControlPort not handled for state: 1

I checked pulseaudio server is running with systemctl, but if I launch:
pulseaudio --check -v
I: [pulseaudio] main.c: The daemon is not running

Although kodi not being able to play any sound throught TV or headphones, everything is working properly from command line and I have sound from my headpones when this happens:

pactl list sinks

Sink #3
State: SUSPENDED
Name: bluez_sink.BC_6E_64_06_C4_A0
Description: SBH20

pactl set-default-sink bluez_sink.BC_6E_64_06_C4_A0
mplayer music.mp3

So, it seems associated to some nasty issue that makes kodi not to choose the proper audio sink with pulseaudio.

If you need any more tests or log, please let me know it.

Regards,

Well I would like to continue testing but I am kinda stuck (2 posts above). I cannot find the Bluetooth device with my phone (a MAC address does appear but it is not the same one as Bluetoothctl shows) and I do not know how to initiate a connection from OSMC to my phone. I only want to stream to OSMC.
And output via HiFiBerry… which is now impossible because the audio output ALSA:Hifiberry Dacplus has been replaced by Bluetooth.

Hi sam,
I’ve finished your package and connect to speaker bluetooth perfectly! Thanks for your work!
But I have a problem when streaming HD video (just 720p or mHD) from my NAS using wifi adapter (TP-link wn725), this playing so lag (video and audio).
I’ve tried HD movie with ethernet with bluetooth speaker, it’s so smooth, but so lag with wifi
Trying HD movies with wifi and audio pass through HDMI so good.
How can i fix it?
Thank you so much!