Nayar
Posts: 5
Joined: Thu Jul 25, 2013 5:39 pm
Contact: Website

Re: Bluetooth audio streaming

Mon Feb 01, 2016 9:16 am

After lots of trial and error, managed to arrive till step 6. However, the music would stop playing after few time.

Code: Select all

$ tail -f /var/log/syslog
Feb  1 08:52:38 raspberrypi bluetoothd[2531]: Endpoint registered: sender=:1.11 path=/MediaEndpoint/HFPAG
Feb  1 08:52:38 raspberrypi bluetoothd[2531]: Endpoint registered: sender=:1.11 path=/MediaEndpoint/HFPHS
Feb  1 08:52:38 raspberrypi bluetoothd[2531]: Endpoint registered: sender=:1.11 path=/MediaEndpoint/A2DPSource
Feb  1 08:52:38 raspberrypi bluetoothd[2531]: Endpoint registered: sender=:1.11 path=/MediaEndpoint/A2DPSink
Feb  1 08:57:30 raspberrypi bluetoothd[2531]: Endpoint unregistered: sender=:1.11 path=/MediaEndpoint/HFPAG
Feb  1 08:57:30 raspberrypi bluetoothd[2531]: Endpoint unregistered: sender=:1.11 path=/MediaEndpoint/HFPHS
Feb  1 08:57:30 raspberrypi bluetoothd[2531]: Endpoint unregistered: sender=:1.11 path=/MediaEndpoint/A2DPSource
Feb  1 08:57:30 raspberrypi bluetoothd[2531]: Endpoint unregistered: sender=:1.11 path=/MediaEndpoint/A2DPSink
However, more trial and error by running pactl subsribe seems to keep it alive

Code: Select all

$ pactl load-module module-loopback source=bluez_source.XX_XX_XX_XX_XX_XX sink=alsa_output.0.analog-stereo
22
$ pactl subscribe >> subs.log

RabbitlL
Posts: 1
Joined: Mon Mar 28, 2016 8:43 am

Re: Bluetooth audio streaming

Mon Mar 28, 2016 8:48 am

I succeeded config raspberryPi 3 with bluetooth audio last night.

There are something new in raspberryPi 3 with newest operate system, in pure command environments.

I've recorded all the processes
https://github.com/jobpassion/raspberry ... Speaker.md

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sat Apr 02, 2016 7:25 am

@RabbitIL, I can't get your instructions to work at all. The steps fail at almost the first hurdle (I get a connection failed when trying to connect my phone to the Pi with Bluetoothctl).

The phone is trusted and paired (although there's no pairing in your steps). However, when I try to connect I get:

Code: Select all

Attempting to connect to XX:XX:XX:XX:XX:XX
Failed to connect: org.bluez.Error.Failed
It's not the most helpful of error messages...

I don't think there's much point in moving on to the pulseaudio bits (which I suspect will be harder) before I can pair my phone. Has anyone got any tips?

EDIT:
"sudo systemctl status bluetooth.service" showed this:

Code: Select all

Apr 02 07:18:03 pi-radio bluetoothd[594]: GAP and GATT are mandatory
Apr 02 07:18:03 pi-radio bluetoothd[594]: gap-gatt-profile profile probe failed for XX:XX:XX:XX:XX:XX
Apr 02 07:18:17 pi-radio bluetoothd[594]: a2dp-source profile connect failed for XX:XX:XX:XX:XX:XX: Protocol not available
Apr 02 07:20:12 pi-radio bluetoothd[594]: GAP and GATT are mandatory
Apr 02 07:20:12 pi-radio bluetoothd[594]: gap-gatt-profile profile probe failed for XX:XX:XX:XX:XX:XX
Apr 02 07:20:12 pi-radio bluetoothd[594]: a2dp-source profile connect failed for XX:XX:XX:XX:XX:XX: Protocol not available
Apr 02 07:20:47 pi-radio bluetoothd[594]: a2dp-source profile connect failed for XX:XX:XX:XX:XX:XX: Protocol not available
Apr 02 07:24:09 pi-radio bluetoothd[594]: a2dp-source profile connect failed for XX:XX:XX:XX:XX:XX: Protocol not available
That might have something to do with it!
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
Douglas6
Posts: 4346
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming

Sat Apr 02, 2016 8:09 am

RabbitIL's procedure looks like a mess to me, with missing and superfluous steps. If you're trying to stream music from the phone to the Pi, another thread mentioned this procedure, which worked for me and others: https://github.com/davidedg/NAS-mod-con ... Audio5.txt
I would (did) add loading the module-bluetooth-policy [code]load-module module-bluetooth-policy[/code] at the end of /etc/pulse/system.pa. That will automatically loop back the source to the sink when the phone connects.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sat Apr 02, 2016 8:16 am

Thanks. I'll take a look.

I also found this: https://github.com/ev3dev/ev3dev/issues/198 which mentions getting bluez5 and pulseaudio 5 working together.

Will report back.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
Douglas6
Posts: 4346
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming

Sat Apr 02, 2016 8:51 am

Yeah, that's a useful link. The one above boils it down.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sat Apr 02, 2016 8:58 am

Presumably I'm ok doing this on Jessie Lite (will be a headless system)?
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
Douglas6
Posts: 4346
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming

Sat Apr 02, 2016 9:01 am

elParaguayo wrote:Presumably I'm ok doing this on Jessie Lite (will be a headless system)?
Yuppers.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sat Apr 02, 2016 9:02 am

Nice. Thank you.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
Douglas6
Posts: 4346
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming

Sat Apr 02, 2016 9:14 am

Douglas6 wrote:
elParaguayo wrote:Presumably I'm ok doing this on Jessie Lite (will be a headless system)?
Yuppers.
I should say I haven't tried it on Lite. Pi3? I'm assuming Lite has the same Bluetooth firmware as the full version. That could be wrong.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sat Apr 02, 2016 9:15 am

Yes. Pi3. Will let you know how I get on.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sat Apr 02, 2016 12:18 pm

ok. All went fine up until

Code: Select all

pactl list short |grep bluez
	11      module-bluez5-discover
	12      module-bluez4-discover
	13      module-bluez5-device    path=/org/bluez/hci0/dev_00_1D_DF_BE_10_4C
	1       bluez_sink.00_1D_DF_BE_10_4C    module-bluez5-device.c  s16le 2ch 44100Hz       SUSPENDED
	1       bluez_sink.00_1D_DF_BE_10_4C.monitor    module-bluez5-device.c  s16le 2ch 44100Hz       SUSPENDED
	0       bluez_card.00_1D_DF_BE_10_4C    module-bluez5-device.c
What I got was just:

Code: Select all

11	module-bluez5-discover		
12	module-bluez4-discover
No device.

Anyone got any ideas?
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sat Apr 02, 2016 12:33 pm

Update: I put this in /etc/pulse/system.pa (instead of what was on the earlier link)

Code: Select all

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
I can now connect the phone via Bluetoothctl and play music from my phone.

However, the quality is truly atrocious - very stuttery. Still, it's progress!

I assume there's a way to autoconnect without having to use bluetoothctl too. After rebooting, it seems to accept a connect request from my phone.

Edit: Squeezelite plays perfectly with pulseaudio so I'm guessing the stutter is something to do with the bluetooth settings (loopback, sample rate?).
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
Douglas6
Posts: 4346
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming

Sat Apr 02, 2016 3:45 pm

Good work. That's actually where I'm at also. I was hoping that adding a USB sound card would fix that, but I haven't tried it yet.

[EDIT: I added a USB sound card, and the audio problems went away. Sounds pretty good.]

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sun Apr 03, 2016 12:40 pm

Ok. I'm building a Squeezeplayer/Bluetooth/Airplay/Internet radio player inside a vintage looking radio. Bluetooth is the only bit I'm struggling with. I might try one of the audio HATs and see if that works.

I may also see if there's anything useful in this: http://raspberrypi.stackexchange.com/qu ... stuttering
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
Douglas6
Posts: 4346
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming

Sun Apr 03, 2016 12:56 pm

Yeah, I've spent a lot of time messing with PulseAudio, Bluetooth, and the standard on-board audio driver. I haven't tried the new one. It was worth $5 to me to just avoid all that.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sun Apr 03, 2016 1:19 pm

I have an old usb sound card lying around but I can't get the pi to make it the default device. I'm being a muppet obviously...

EDIT: still stutters through USB.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sun Apr 03, 2016 1:28 pm

It might be the wifi...
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
Douglas6
Posts: 4346
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming

Sun Apr 03, 2016 3:55 pm

I did make one change in /etc/pulse/system.pa, adding tsched=0 to the module-udev-detect line:

Code: Select all

load-module module-udev-detect tsched=0
Not sure if that helps.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Sun Apr 03, 2016 6:10 pm

I noticed the red power light was flashing so I thought "well, that must be it", plugged in a more powerful supply. Still stuttering... grr.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

Moef
Posts: 4
Joined: Fri Mar 18, 2016 1:29 pm

Re: Bluetooth audio streaming

Tue Apr 05, 2016 1:09 pm

I got less stutter when I disabled the real time scheduling. May be this is what "tsched=0" implies, but this command wasn't recorgnized by my pi (maybe because of Jessie). So I went into the /etc/pulse/daemon.conf and changed it to no.

Code: Select all

sudo nano /etc/pulse/daemon.conf
find the line:
;realtime-scheduling = yes
press enter and add

Code: Select all

realtime-scheduling = no

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Tue Apr 05, 2016 1:53 pm

Thanks. I'll give it a try.

Out of interest does "less stutter" mean that you've still got some stutter?
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Wed Apr 06, 2016 10:26 pm

Sadly that didn't work either.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

SebTC
Posts: 9
Joined: Sun Mar 13, 2016 12:01 am

Re: Bluetooth audio streaming

Sun Apr 10, 2016 10:45 pm

Do you use the Pi3 bluetooth? I had the same problems. Tried other sample rates, realtime-scheduling etc. No luck. Even built newest Pulseaudio from source.

Streaming sounds good when disabling on-board Wifi using the following command:
sudo ifdown wlan0

Funny thing: without Wifi, I can see in Blueman a downstream of 42kB/s which is roughly 336000 bits/s. When enabling wifi during streaming, the sound starts to stutter due to a buffer underrun. You can see the bluetooth downstream changes to a changing value, average 34kB/s which is not enough to stream the audio. Don't know what exactly the problem is, but disabling wifi seems to be a workaround. Maybe Wifi and Bluetooth share something.

User avatar
elParaguayo
Posts: 1936
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Bluetooth audio streaming

Mon Apr 11, 2016 8:01 am

That was my thought too (see one of my earlier posts).

Disabling the wifi didn't seem to fix it completely though.

Happy to have another try when I'm back from holiday.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: No registered users and 7 guests