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

I’m finding the same as Abhishek_Kumar. Tried RPi B and Zero, 3 different BT dongles (which have A2DP support) and Android tablet and Android phone. Can always pair and tablet or phone shows osmc as connected for media. But when I play audio file on phone or tablet no sound from anywhere. Volume rocker on phone or tablet shows it adjusting Bluetooth but even at maximum, nothing from OSMC (latest available version).

OMG! I finally figured it out!! Can’t believe why nobody wrote about a new part in My OSMC after installing bluetooth :rage:

3 Guides: enable Bluetooth, pair a device, stream.

Install Bluetooth streaming

  1. Update OSMC, do it via MyOSMC> Update>Manual and reboot.
  2. Run the command provided by Sam:
    wget http://paste.osmc.io/raw/qiyekuvafe -O- | sudo sh
  3. (since the November 2015 update) edit /boot/config/txt and add this line to the bottom:
    dtparam=audio=on to /boot/config.txt

Pairing a device

You need to pair your phone or other device. The great OSMC developers did not mention it but they created a nice UI in MyOSMC that works reasonably.

  1. Go to MyOSMC. If you use a different skin, go to Settings>Addons>My Addons> Program Addons > OSMC and launch it. I would recommend you use your skin’s settings to add MyOSMC to your Kodi Homescreen.
  2. MyOSMC > Network (it is the ‘share’ icon) and you will find “Bluetooth” there!
  3. First enable it
  4. now enable Bluetooth on your phone, wait up to a minute and your phone’s name will appear in the list. Use it to pair WITH PIN. You don’t have to enter a pin, just acknowledge on both your phone and in MyOSMC the shown pin is correct. You can now stream music to OSMC/Kodi!

NOTE
If your goal is to stream from OSMC to a Bluetooth speaker:
In Kodi, Settings>System>Audio Output you can select to output audio to ALSA: Bluetooth.

BUGS

OSMC streaming to speakers:

  1. user @JohnDoe has reported errors and wrote about it extensively with Kodi log showing errors.

Streaming to OSMC:

  1. November update broke Bluetooth streaming! Pairing and connecting works perfectly, but there is no audio played back in OSMC. It worked fine before the update. I updated last night and since that moment, there is no audio when I stream to OSMC. FIXED, step 3 has been added above.
  2. HiFiBerry users: the option to output audio via HiFiBerry is missing in Settings>Audio Output.
5 Likes

Did you enable the audio dtoverlay? Pi now requires a Device Tree overlay specified in config.txt to load sound

Sam, can you expand on that? What needs to be specified in config.txt to make audio streamed over Bluetooth to OSMC be added into the HDMI output.

Hi

If you scroll up a couple of posts, you’ll should see it:

Sam

Got audio working by adding dtparam=audio=on in config.txt.
Audio is choppy sometimes,Is it because I am using an old generic adapter(bluetooth 2.0,I think)?

The dtparam=audio=on line got audio coming out of the HDMI fed TV but stuttering and broken up. Same with 4 different BT dongles. But good audio if operated without the Wi-Fi dongle plugged in. I put a short USB extension lead on the BT dongle and now working perfectly with both the BT and the Wi-Fi dongles in use.

So don’t immediately assume your BT dongle is no good!

It works perfectly again, no stuttering! I have updated my little guide in case others need it.

I am using a CSR8510 BT4.0 nano dongle:
https://www.kiwi-electronics.eu/nano-bluetooth-4-0-usb-adapter

I believe CSR8510 is the recommended one, I’m sure the one in the OSMC shop is also a CSR8510.

Bluetooth uses the same 2.4Ghz frequencies as wifi - if you have the two adaptors right next to each other they will interfere with each other badly, as you discovered. An extension cable on one or both adaptors to get them as far apart as possible is a reasonable solution.

Awesome work, I’ve been looking forward for this feature for a long time :smile:
Right now I can see the Bluetooth menu under MyOSMC (which is gone if my BT dongle is unplugged) but when I enable it I can see the “Working” popup but nothing shows up, and then, after a while, it gets disabled again.
Which logging would be useful for diagnosing what could be going on?

Edit: some logging

-- Logs begin at Mon 2015-12-14 20:19:21 ART, end at Mon 2015-12-14 20:43:02 ART. --
Dec 14 20:19:29 osmc bluetoothd[325]: Bluetooth daemon 5.23
Dec 14 20:19:29 osmc bluetoothd[325]: Starting SDP server
Dec 14 20:19:29 osmc bluetoothd[325]: Bluetooth management interface 1.10 initialized
Dec 14 20:28:03 osmc bluetoothd[325]: Sap driver initialization failed.
Dec 14 20:28:03 osmc bluetoothd[325]: sap-server: Operation not permitted (1)
Dec 14 20:28:03 osmc bluetoothd[325]: Endpoint registered: sender=:1.5 path=/MediaEndpoint/A2DPSource
Dec 14 20:28:03 osmc bluetoothd[325]: Endpoint registered: sender=:1.5 path=/MediaEndpoint/A2DPSink
Dec 14 20:29:45 osmc bluetoothd[325]: Failed to set mode: Blocked through rfkill (0x12)
Dec 14 20:31:04 osmc bluetoothd[325]: Failed to set mode: Blocked through rfkill (0x12)
Dec 14 20:33:37 osmc bluetoothd[325]: Failed to set mode: Blocked through rfkill (0x12)
Dec 14 20:34:01 osmc bluetoothd[325]: Failed to set mode: Blocked through rfkill (0x12)
Dec 14 20:36:37 osmc bluetoothd[325]: Failed to set mode: Blocked through rfkill (0x12)

Use the Log Uploader tool in MyOSMC to upload all logs and post the resulting URL here.

Just tried this with my bluetooth headphones. They work great eventually, but there is approximately 2 minutes of caching and video stutter while silent audio before it kicks off.

awesome, altering the /boot/config.txt file did the trick for me!

for the terminal-savvy folks (not sure if all steps are required):

bluetoothctl
power on
scan on
agent on
devices
pair {{mac address as shown by devices}}
connect {{mac address}
exit

as found here: https://wiki.archlinux.org/index.php/Bluetooth

for the devs, audio playback sometimes suffers from some noise (I think, not sure how to describe it. Quality is perfect and no lag) that is probably best described as poking your finger on a poorly (requited?) aux cable which makes the speakers crack for a second. Might be my (old) bluetooth dongle though, not sure. Definitely not the output device.

/home/osmc > dmesg | grep Bluetooth
[    4.314149] Bluetooth: Core ver 2.20
[    4.314260] Bluetooth: HCI device and connection manager initialized
[    4.314283] Bluetooth: HCI socket layer initialized
[    4.314299] Bluetooth: L2CAP socket layer initialized
[    4.314335] Bluetooth: SCO socket layer initialized
[    5.604841] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    5.604862] Bluetooth: BNEP filters: protocol multicast
[    5.604886] Bluetooth: BNEP socket layer initialized

bluetoothctl info A8:5B:78:7D:F0:6C 
Device A8:5B:78:7D:F0:6C
	Name: iPhone van Rowan
	Alias: iPhone van Rowan
	Class: 0x7a020c
	Icon: phone
	Paired: yes
	Trusted: no
	Blocked: no
	Connected: yes
	LegacyPairing: no
	UUID: Vendor specific           (00000000-deca-fade-deca-deafdecacafe)
	UUID: Service Discovery Serve.. (00001000-0000-1000-8000-00805f9b34fb)
	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: NAP                       (00001116-0000-1000-8000-00805f9b34fb)
	UUID: Handsfree Audio Gateway   (0000111f-0000-1000-8000-00805f9b34fb)
	UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
	UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	Modalias: bluetooth:v004Cp6E00d0920

Sam,

Any chance you have a guidance for the HiFiBerry not showing up in Settings->Audio Output after following the steps outlined above. This was mentioned by @zilexa too.

Thanks much!

  • Micky

I think you’ll find that installing pulse-audio and trying to use a Hifiberry are mutually exclusive, at least for now. So if you have a Hifiberry I would not recommend trying to use the A2DP package at the moment.

Issues with pulse-audio and side effects from it being installed are the main thing that is keeping this package experimental at the moment.

Just what I needed to know. Appreciate the quick turnaround!

sudo apt-get purge pulse-audio

Should remove pulse audio as well as the A2DP package and get your Hifiberry working again.

first post here, just switched to osmc from oe (been meaning to try it but I’m lazy lol). I’m a very infrequent linux user so forgive any dumbness!

(I have 2015.11-1 on a Rpi 2b)

Firstly, I initially had problems with my Belkin F8T012 dongle (pairing always failed). I found this information and now pairing is working. Not sure what the pegasus kernel module does (as mentioned in the link), but everything seems ok with it blocked.

Secondly, like others I was getting a long period of initial audio stuttering. I seem to have fixed this by turning off ‘Start/Stop Discovery’ in Bluetooth options after I’ve successfully paired. This makes a lot of sense, but I didn’t think to try it at first so thought I would mention it in case it helps anyone else.

I do need to remove the device and then re-pair it in osmc when I want to pair (re-connect in the Paired Devices sub-menu doesn’t work for me), but it may be my old Motorola S705 receiver that I’m using (I’ll keep playing around).