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

Read the first post in this thread…

OK - I have completely re-installed OSMC, updated it via the OSMC Update Option, and used the link you refer to to install the official PulseAudio app. I have copied across my test mp3 files to the Pi. Now, the Audio Output options from the Settings/System/Audio Output just provide the one additional output option (streaming to bluetooth speakers etc) which I have selected. I can connect to my bluetooth speaker (Bluetooth option under OSMC Networking). However when I play my mp3 file(s) there is no sound from the speaker, and although playback ‘starts’ the playback time display stays at zero… This doesn’t happen when I playback via the Analogue Audio output. Any suggestions? Are different applications used for playback when different audio outputs are selected?

A few days on… no real improvement, but checking the logs see the following error (regularly appears after a reboot…)

22:31:54 23.841501 T:3024658992 NOTICE: Loaded playercorefactory configuration
22:31:54 23.842844 T:3024658992 NOTICE: Loading player core factory settings from special://masterprofile/playercorefactory.xml.
22:31:54 23.843710 T:3024658992 NOTICE: special://masterprofile/playercorefactory.xml does not exist. Skipping.
22:31:54 24.309248 T:3024658992 INFO: creating subdirectories
22:31:54 24.309788 T:3024658992 INFO: userdata folder: special://masterprofile/
22:31:54 24.310452 T:3024658992 INFO: recording folder:
22:31:54 24.310810 T:3024658992 INFO: screenshots folder:
22:31:54 24.340876 T:2944111600 DEBUG: Thread ActiveAE start, auto delete: false
22:31:54 24.342049 T:3011224560 DEBUG: Thread AESink start, auto delete: false
22:31:54 24.343464 T:3011224560 INFO: CActiveAESink::OpenSink - initialize sink
22:31:54 24.344004 T:3011224560 DEBUG: CActiveAESink::OpenSink - trying to open device ALSA:pulse
22:31:54 24.344305 T:3011224560 INFO: CAESinkALSA::Initialize - Attempting to open device “pulse”
22:31:54 24.358387 T:3011224560 INFO: CAESinkALSA::Initialize - Opened device “pulse”
22:31:54 24.361027 T:3011224560 DEBUG: CAESinkALSA::InitializeHW - Request: periodSize 2205, bufferSize 8820
22:31:54 24.376268 T:3011224560 DEBUG: CAESinkALSA::InitializeHW - Got: periodSize 2205, bufferSize 8820
22:31:54 24.376907 T:3011224560 DEBUG: CAESinkALSA::InitializeHW - Setting timeout to 200 ms
22:31:54 24.394165 T:3011224560 DEBUG: CAESinkALSA::GetChannelLayout - Input Channel Count: 2 Output Channel Count: 2
22:31:54 24.394499 T:3011224560 DEBUG: CAESinkALSA::GetChannelLayout - Requested Layout: FL,FR
22:31:54 24.394756 T:3011224560 DEBUG: CAESinkALSA::GetChannelLayout - Got Layout: FL,FR (ALSA: none)
22:31:54 24.395044 T:3011224560 DEBUG: CActiveAESink::OpenSink - ALSA Initialized:
22:31:54 24.395273 T:3011224560 DEBUG: Output Device : OSMC streaming to Bluetooth speaker / headphones
22:31:54 24.395445 T:3011224560 DEBUG: Sample Rate : 44100
22:31:54 24.395668 T:3011224560 DEBUG: Sample Format : AE_FMT_FLOAT
22:31:54 24.395866 T:3011224560 DEBUG: Channel Count : 2
22:31:54 24.396122 T:3011224560 DEBUG: Channel Layout: FL,FR
22:31:54 24.396393 T:3011224560 DEBUG: Frames : 2205
22:31:54 24.396572 T:3011224560 DEBUG: Frame Samples : 4410
22:31:54 24.396851 T:3011224560 DEBUG: Frame Size : 8
22:31:54 24.455559 T:3011224560 ERROR: CAESinkALSA - snd_pcm_writei(-32) Broken pipe - trying to recover
22:31:54 24.483501 T:3024658992 NOTICE: Running database version Addons20

Is this ‘broken’ pipe where the audio output is put when playback starts? (To send to the driver responsible for doing the Bluetooth transmission). Which may explain why Playback ‘starts’, but there is no pipe to put it into, and so Playback just hangs?
What should I do to correct this problem?

This system is totally update (as far as I know). Bluetooth connection to the speaker is fine.

Have testing BT audio sink for over a month now. Everything works quite well :slightly_smiling:
But after upgrade to rbp2-image-4.4.3-3-osmc audio stutters begun. There was no related errors in system log nor in dmesg output just random sutters. I also took a look at CPU load suspecting pulseaudio but nothing there as well. After a while I downgraded the to rbp2-image-4.4.1-1-osmc and at the moment everything works fine again.
PS! I did not changed BT dongle, PI position or any other HW related configuration.

Ive been using my osmc pi as a bt sink for several weeks now and things are working extremely well for me.
The pi is installed in my car, so with a cronjob @restart the pi will attempt to connect with my phone, and automatically begin streaming- exactly what I wanted!

I can’t wait for the btplayer implementation- adding track info and controls will make the experience complete. Is there any insight into when a testable btplayer will be available?

Hi

I used wget command but my osmc is rebooting each time. I tried uninstall install cycle but nothing changed.
I also checked apt-get log but there is not any tip there. I saw another people has also this probelm bu I did not see solution.
Where can I access A2DP application…
Thanks for your help…

PS: After trying first reboot I used wget… command but after
Reading state information… Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

this information osmc rebooted again.

Hi,
I managed to do some more testing - this time the other way around. I tried to connect my phone to my raspberry pi to stream music via bluetooth to the pi.
I managed to pair my mobile without any bigger issues using the user interface in myOSMC. So far so good.

First I tried playing a podcast on my phone. The sound was loud and clear. There was some stuttering but it was fully understandable what the people where saying. There was nothing exciting in the log (journalctl -f) either
Mar 09 22:48:00 mm bluetoothd[281]: /org/bluez/hci0/dev_40_B8_37_64_80_3C/fd4: fd(21) ready

So I started some music on my phone (using the soundcloud app)
In the beginning there was some light stuttering but the sound was pretty good. But the music stopped after about a minute. So I stopped the music playing on the phone and started it again after a short time. Now the music sounded really weird and I got the following kind of message every ten seconds in the syslog
Mar 09 22:51:30 mm pulseaudio[259]: W: [pulseaudio] module-loopback.c: Sample rates too different, not adjusting (44100 vs. 93226). Mar 09 22:51:40 mm pulseaudio[259]: W: [pulseaudio] module-loopback.c: Sample rates too different, not adjusting (44100 vs. 92856).

So I stopped the music again and tried the music player that shipped with my phone. The Music sounded okay at first but after about 20s there where short dropouts every couple of seconds. Half a minute later the music stops and I get the messages about the too different sample rates again (without hearing any music playing):
Mar 09 22:57:28 mm pulseaudio[259]: W: [pulseaudio] module-loopback.c: Sample rates too different, not adjusting (44100 vs. 70681). Mar 09 22:57:38 mm pulseaudio[259]: W: [pulseaudio] module-loopback.c: Sample rates too different, not adjusting (44100 vs. 112550).

Being all excited that I had at least a little success I tried another time to connect my bluetooth speaker and headphones to the pi (which is my actual goal). But the results where exactly the same as last time. I couldn’t establish any connection to either - The headphones are not detected at all and the speakers won’t connect.

Do you have any ideas what I’m doing wrong?


Edit: Meh, it seems like I can’t post more than three posts in the same topic :unamused:

I’m pretty sure now, that the bluetooth dongle I received is faulty. I borrowed another dongle and this one has no problems connecting to my speaker/headphones whatsoever.
However, now I got stuck at another weirdness. When I choose “ALSA: OSMC Streaming to bluetooth speaker/headphones” as audio output device all sound is played via HDMI.

So I wanted to check the state/configuration of pulseaudio - without any success.
Using pacmd I just get the error message “No PulseAudio daemon running, or not running as session daemon.” Which is exactly right, as pulseaudio is started with the --system option. This seems to be a rather uncommon way of running pulseaudio - at least I couldn’t find any information how to get around this.

Do you have any ideas why my sound is played through HDMI even though bluetooth is choosen as output device? Or could any of the devs give me a hint on how to access the pulseaudio daemon?

Thanks a lot!

So what do I have to do to get this? Is the command in the OP still the way to go? Thx

I just saw that the Pi 3’s inbuilt bluetooth is not even supported yet. Lol, my bad!

is it possible that there is an audio conflict between ALSA: OSMC streaming Bluethoot and ALSA: Hifiberry? Because i have install Audio Card and i only see in audio Option ALSA:OSMC Bluethoot. Thanks

If you had used Search in this topic you would have found your answer immediately :slight_smile:

It seems a bug . Nobody has found a solution

Sam explained above why HifiBerry and its clones will not work in combination with PulseAudio. Using one excludes the other (not a bug).

1 Like

excuse me. I had to reinstall OSMC (2016.02-3) and now i have to reinstall bluetooth audio streaming.
the procedure is still the one indicated in the first post ?
“wget http://paste.osmc.io/raw/qiyekuvafe -O- | sudo sh”
thanks a lot. Bye

We have to set audio output for bluetooth after reboot. Is there any solution to choose bluetooth after reboot.

Someone else suggested earlier in this thread setting up a cronjob @ reboot

mine looks something like this –
> @reboot sleep 20 && /bin/echo -e ‘connect 08:DF:1F:21:CB:03 \n’ | bluetoothctl

Got my dongle from the store and installed the blueooth stuff using the command in the first post

When I look at the dmesg output I get the following:

[ 98.410618] usb 1-1.5: new full-speed USB device number 6 using dwc_otg
[ 98.511160] usb 1-1.5: device descriptor read/all, error -32
[ 98.590620] usb 1-1.5: new full-speed USB device number 7 using dwc_otg
[ 98.695340] usb 1-1.5: New USB device found, idVendor=0a12, idProduct=0001
[ 98.695375] usb 1-1.5: New USB device strings: Mfr=0, Product=0, SerialNumber=0

Does that device error mean I need a powered hub? Am connecting it to the standard Pi USB ports. Get the same error whichever port I plug it into.

Also how do I start the bluetooth stack on reboot - I have to run /etc/init.d/bluetooth start every time from the shell.

Are you sure that you manually have to start the bluetooth stack? On my OSMC installation systemd is starting bluetooth as soon as dbus comes up.
What’s your output of systemctl status bluetooth.service after rebooting?

And when it comes to the device descriptor error, do you experience any problems except the error message? If the dongle is working otherwise I wouldn’t worry too much.

osmc@Weiss:~$ systemctl status bluetooth.service
* bluetooth.service - Bluetooth service

Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Drop-In: /etc/systemd/system/bluetooth.service.d
-local.conf Active: active (running) since Sun 2016-03-20 08:46:37 GMT; 11h ago Docs: man:bluetoothd(8) Main PID: 277 (bluetoothd) Status: "Running" CGroup: /system.slice/bluetooth.service -277 /usr/lib/bluetooth/bluetoothd

Device descriptor errors have disappeared now so thats not a problem. Next problem is I have no idea how to pair my dongle to my speaker dongle…

To me that looks like bluetoothd got started successfully. No need to start it manually.
You pair the dongle with the speakers in myOSMC -> Network -> Bluetooth.

Thanks all working now no problems :slight_smile: