New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pi3 bluetooth audio stutters with Wifi enabled #1402

Open
SebTC opened this Issue Apr 11, 2016 · 122 comments

Comments

Projects
None yet
@SebTC

SebTC commented Apr 11, 2016

Hello,

I'm testing with streaming music using a2dp over bluetooth on the Pi3. When Wifi is enabled, I get constant buffer underruns wit Pulseaudio (Blueman shows a downstream of around 34kB/s). As soon as I disable the Wifi interface (ifdown wlan0), the audio starts to play normally and the downstream is around 42kB/s (which is correct high quality stereo audio if I see http://soundexpert.org/news/-/blogs/bluetooth-audio-quality-a2dp).
Also tried making the buffer much larger, changing resampling type, realtime-scheduling etc. Also tried latest Pulseaudio, no difference. Seems like it is a Raspberry problem.

First thought it was because the Wifi and Bluetooth both use UART, but the is not true (and would be too slow if Wifi was over the 921600 baud if I see it correctly). They still share the same chip (BCM43438). Is there a known reason why I (and also heard others) have this problem?

@pbros

This comment has been minimized.

pbros commented Apr 17, 2016

I've been having the exact same issue. Disabling WLAN0 fixed the audio issues. However, I would very much like to be able to use the wifi...

@REY-01

This comment has been minimized.

REY-01 commented Apr 19, 2016

Same is here. Took me 3 days, 2 distros to figure out it was the build in WiFi. Same error appears when i use a WiFi stick direktly at the USB Ports. When i use a USB connection cable with the USB stick everything works fine. So i simply think it comes from the build in antenna that the two 2.4 GHz services interfer each other. :-/

@pbros

This comment has been minimized.

pbros commented Apr 19, 2016

I was able to get A2DP to work by disabling the on-board wifi and using a Wi-Pi USB adapter, without any extension cable.

@Ferroin

This comment has been minimized.

Contributor

Ferroin commented Apr 19, 2016

This brings up a rather interesting question: Does the on-board WiFi chip support Bluetooth co-existence, does the driver support this, and does it work correctly? Based on what I've seen from multiple sources, there's considerably better latency when you either disable the on-board WiFi or disable the on-board Bluetooth and use a USB adapter instead, and that sounds to me like either the on-board chip doesn't correctly implement BT co-existence, or the driver doesn't properly support it.

@pelwell

This comment has been minimized.

Contributor

pelwell commented Apr 19, 2016

The BCM43438 has a co-existence interface between the WiFi and Bluetooth interfaces - no software support is required.

@WayneKeenan

This comment has been minimized.

WayneKeenan commented Apr 19, 2016

@Ferroin From my experience I would say /fundamentally/ yes it does, although I'm not an authoritative source and I do not demand much on the Bluetooth side.... Whilst developing Bluetooth LE central and peripheral applications on a Pi 3 I run a VNC X session, 2x SSH sessions and have NFS share mounted all via WiFi and all are ok.

@rschulman

This comment has been minimized.

rschulman commented Oct 7, 2016

+1 on this, as I've just discovered tonight. Took wlan0 down and the audio played just fine. Has anyone gotten any new word since August on what's going on here and if there's a fix?

@adn77

This comment has been minimized.

adn77 commented Nov 14, 2016

+1 me too, "ifdown wlan0" and pulseaudio streams fine via a2dp

@libertineplusplus

This comment has been minimized.

libertineplusplus commented Dec 12, 2016

+1, just updated today, using an Anker Sound Core bluetooth speaker. Plays beautifully if I turn off wifi, but that's a pretty big workaround. It's annoying but workable for this project (OKAY FINE, I'll connect via hdmi instead of vncserver I GUESS ) but I too am waiting on a fix because it seriously limits my ability to make my projects mobile. VNCserver is a must.

@vgallissot

This comment has been minimized.

vgallissot commented Jan 7, 2017

+1 that gave me headaches finding this problem out !

I needed WiFi so I just:

  1. Use a USB dongle as WiFi adapter
  2. Disable onboard WiFi adapter in /etc/network/interfaces

No more sound problems.

@daryltucker

This comment has been minimized.

daryltucker commented Jan 12, 2017

I'm excited to see any progress on this, but as a reminder, you can Subscribe to this thread and add a reaction to the original post. It is not recommended to post a response of +1.

@jeffleus

This comment has been minimized.

jeffleus commented Jan 24, 2017

Agreed that no WiFi is crippling to the base Pi3. Adding a usb dongle defeats one of the big gains w/ the Pi3 of onboard WiFi/BT. :-(

@mohitkalraniit

This comment has been minimized.

mohitkalraniit commented Jan 24, 2017

I have also tested the behavior and facing same issue as reported here. Planning to add additional USB WiFi adapter to overcome the problem. Hope pi would support second WiFi without much problems.

@hurda

This comment has been minimized.

hurda commented Feb 28, 2017

I guess the Zero W will suffer from the same issues regarding Bluetooth and WLAN, as its using the same chip?
Using USB-devices as workarounds ain't that easy with the Zero W, though.

@BaReinhard

This comment has been minimized.

BaReinhard commented Mar 3, 2017

Is this happening to everyones Raspberry Pi? How is the music being played? (Pi hat DACs, sound cards, BCM?) What are you using the Wifi for?

Because, I haven't had any issues with my Pi3

@abatardi

This comment has been minimized.

abatardi commented Mar 3, 2017

Only an issue when both are going. WiFi actively transmitting and then try to use Bluetooth. Bluetooth + LAN is no problem. So most people and applications won't see the issue.

@kalramohit

This comment has been minimized.

kalramohit commented Mar 3, 2017

I have added secondary WiFi receiver and made it primary and using embedded WiFi as bluetooth receiver. This is a cheapest way to get this working.

@hurda

This comment has been minimized.

hurda commented Mar 3, 2017

Bluetooth + LAN is no problem.

Please show me the LAN-port on the Pi0W.

@BaReinhard

This comment has been minimized.

BaReinhard commented Mar 6, 2017

Has anyone tried renicing pulseaudio to have a higher priority?

@pradeepprakash

This comment has been minimized.

pradeepprakash commented Mar 7, 2017

Yes, I tried with with higher priority with no discernible difference in the outcome.

@pradeepprakash

This comment has been minimized.

pradeepprakash commented Mar 7, 2017

@Michiman

This comment has been minimized.

Michiman commented Mar 7, 2017

I am also trying to solve this problem. The choppiness seems to change a bit among different BT speakers/headphones, but it's still there using a WiFi dongle and disabling the onboard WiFi. Even using a BT dongle, the choppiness is still there while playing a local mp3 or using Pithos (Pandora). I also used a lower bitrate mp3 file, and the choppiness improved.

I downloaded a couple of sample files from 16 to 64kbps and played them using VLC on RPi3. I am running pulseaudio and connecting to some cheap bluetooth earbuds.
http://www.digitalprosound.com/Htm/WebAudio/2000/Oct/MP3bitrates3.htm

With only background WiFi activity, each file played, but did exhibit some choppiness with the increasing bitrate. Then, I ran an apt-get update and while it was running played the 16k file. Very choppy. Same for the others. In fact, the wifi activity had more of an effect than the bitrate of the file.

Now attach a WiFi dongle and disable the onboard Wifi (sudo ifdown wlan0). Try again.
All files completely smooth. What about while performing a download over Wifi? Also smooth at 64kbps.
Running Pithos(Pandora)? Smooth. This was not the case last night, so I am not convinced I have a solid solution.

@mwestphal

This comment has been minimized.

mwestphal commented Mar 8, 2017

I experience the same issue.

I resolved it by using a Bluetooth dongle wich is a complete success.
Plugable Technologies USB-BT4LE

Still not happy with this though, what is the point of having features that cannot be used.

@Michiman

This comment has been minimized.

Michiman commented Mar 9, 2017

One thing you have to make sure is that you turn off bluetooth scanning (scan off) while in the bluetoothctl prompt. That resolved my issue and I was able to stream nicely with a Pi Zero W, Pi3, using the built-in wifi/BT and Pi Zero + redbear IoT PiHat.

@mwestphal

This comment has been minimized.

mwestphal commented Mar 9, 2017

@Michiman : I'm 100% sure that i tried it without scanning on at the same time. still had the issue. I'm using rpi3 though.

MilhouseVH added a commit to MilhouseVH/brcmfmac_sdio-firmware-rpi that referenced this issue Aug 16, 2018

@fatg3erman

This comment has been minimized.

fatg3erman commented Aug 17, 2018

Been following this thread with interest. I've been using a Pi ZeroW/Raspbian Lite to play internet streams through bluealsa to a bluetooth speaker using Mopidy. Up until today nothing in this thread has solved the stuttering problem.

bluez 5.50 - no difference
disabling WiFi and using a USB ethernet adaptor - some change but still stuttering every few minutes

Changing the NVRAM settings - seems perfect so far. I'm back to using WiFi and there is no stuttering in the bluetooth audio. Still using bluez 5.50. I'll report back if I do get any stuttering.

@paul-1

This comment has been minimized.

paul-1 commented Aug 17, 2018

Positive results so far. I am also using Bluez 5.50 also. Board - RPi3

I've removed the previous modprobe parameters that were thrown up as a solution. So far no stuttering. Using iperf3, you can definitely see it stealing time from the wifi radio. But no stuttering, even when pushing extra data across.

While playing bluetooth,

[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  22.8 MBytes  19.2 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  22.7 MBytes  19.1 Mbits/sec                  receiver

Stopping playback, and disconnecting speaker.

[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  55.3 MBytes  46.4 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  54.9 MBytes  46.0 Mbits/sec                  receiver

Bluetooth disabled via dtoverlay

[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  58.1 MBytes  48.8 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  57.0 MBytes  47.8 Mbits/sec                  receiver
@marcosvfc

This comment has been minimized.

marcosvfc commented Aug 17, 2018

Works for me raspi 3B, no stuttering, even moving an large file over wifi while playing audio (a2dp), but i'm seeing tons of
"Bluetooth: hci0: Frame reassembly failed (-84)" in milliseconds!

$ dmesg
[ 2331.758484] Bluetooth: hci0: Frame reassembly failed (-84)
[ 2331.758689] Bluetooth: hci0: Frame reassembly failed (-84)
[ 2331.758750] Bluetooth: hci0: Frame reassembly failed (-84)
[ 2331.758833] Bluetooth: hci0: Frame reassembly failed (-84)
@fatg3erman

This comment has been minimized.

fatg3erman commented Aug 17, 2018

Been trying this for a few hours now. It's better than it was, but it's not perfect. I now get, often 20 to 30 minutes of continuous playback, but then the stuttering starts again and will not go away unitl I stop and restart the audio stream. Also my ssh session stalls for a moment when the stuttering starts. It's not audio buffering, because I've put logging in my player to tell me when it's buffering.

@amilino

This comment has been minimized.

amilino commented Aug 17, 2018

Maybe you should switch to RPi3 b+, I have no problems at all.

@fatg3erman

This comment has been minimized.

fatg3erman commented Aug 17, 2018

Maybe you should switch to RPi3 b+, I have no problems at all.

Not exactly the point though is it? The changes were said to "completely fix" the audio stuttering. I'm just reporting that that doesn't seem to be the case. The 3B+ uses a different chipset from the W, so perhaps the settings need tweaking a little.

@amilino

This comment has been minimized.

amilino commented Aug 17, 2018

Yes I agree, but looking at the issue subject it is related to RPi3. This discussion is anyway too long maybe it would be good to have new separate issue opened related to Pi W.

@paul-1

This comment has been minimized.

paul-1 commented Aug 18, 2018

This solution works for a ZeroW as well. Been playing for well over 2 hours without issue.

@fatg3erman

This comment has been minimized.

fatg3erman commented Aug 19, 2018

I think the issues I've been experiencing on ZeroW are probably down to the Bluetooth not having quite the same range as the Bluetooth on my iMac. Putting the speaker closer to the Pi, I've been playing internet radio now for 4 hours without issues. I'll have to re-situate the Pi so the signal reaches the kitchen :)

paul-1 added a commit to piCorePlayer/firmware-rpi-wireless that referenced this issue Aug 19, 2018

@pelwell

This comment has been minimized.

Contributor

pelwell commented Aug 19, 2018

Thanks for all the feedback, which suggest that these settings are at least a big improvement with no regressions. Feel free to chime in if your experiences are suggest otherwise, but I'm planning to make these the new defaults.

@rgson

This comment has been minimized.

rgson commented Aug 19, 2018

I can add one more observation with a positive outcome. I've been using both Bluetooth and Wi-Fi simultaneously on my ZeroW for about an hour now with no stuttering. Definitely a +1 on making this the new default.

@edio

This comment has been minimized.

edio commented Aug 19, 2018

Do you discuss here only the issue when rPi is used as a2dp source or also as a2dp sink?

I'm trying to use my rPi3 as a bluetooth sink (i.e. I try to play audio from my phone to my rPi), and stuttering is so intense, that you barely recognize played songs. Wi-fi is not used. I tried with external BT adapter - no luck. However, with different bt adapter stuttering was different (like if different buffer size was used).

Should I report a different issue?

@rgson

This comment has been minimized.

rgson commented Aug 20, 2018

@edio I've been using the RPi ZeroW as the sink, streaming audio from my phone to the RPi over Bluetooth. Until yesterday, I too had horrible stuttering, but the most recently suggested solution seems to have solved it.

pelwell added a commit to pelwell/firmware-nonfree that referenced this issue Aug 20, 2018

Improved brcmfmac BT coexistence parameters
Cypress have provided some Bluetooth coexistence settings that
greatly improve BT streaming quality when WiFi is active.

See: raspberrypi/linux#1402

Signed-off-by: Phil Elwell <phil@raspberrypi.org>

paul-1 added a commit to piCorePlayer/firmware-rpi-wireless that referenced this issue Aug 20, 2018

@peetereczek

This comment has been minimized.

peetereczek commented Aug 21, 2018

Solution presented by @paul-1 works for me, on Pi 3+ board. I can use Wi-Fi normally and enjoy good BT audio stream

@bwims

This comment has been minimized.

bwims commented Aug 26, 2018

Hello,
does anyone have any idea how to use the NVRAM solution on a Libreelec system with a read-only squashFS system? As I understand it, it is read-only because the next distribution overwrites the system files.

@MilhouseVH

This comment has been minimized.

MilhouseVH commented Aug 26, 2018

@bwims

RPi3:

mkdir /storage/.config/firmware/brcm
cp /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt /storage/.config/firmware/brcm

RPi3+:

mkdir /storage/.config/firmware/brcm
cp /usr/lib/firmware/brcm/brcmfmac43455-sdio.txt /storage/.config/firmware/brcm

Now edit the file in /storage/.config/firmware/brcm and reboot.

Or you can use a recent LibreELEC 9.0 test build with Kodi 18 which includes this fix already: https://forum.kodi.tv/showthread.php?tid=298461

@edio

This comment has been minimized.

edio commented Aug 26, 2018

Does anyone in this thread still have occasional dropouts after the fix applied? It's not as terrible as stuttering I had initially, but still bluetooth sink is pretty unusable for me, as every couple of seconds I have bursts of clicks, roughly each one corresponding to series of records in pulseudio output

E: [bluetooth] module-bluez5-device.c: SBC decoding error (-2)
E: [bluetooth] module-bluez5-device.c: SBC decoding error (-2)
E: [bluetooth] module-bluez5-device.c: SBC decoding error (-2)
E: [bluetooth] module-bluez5-device.c: SBC decoding error (-3)
E: [bluetooth] module-bluez5-device.c: SBC decoding error (-2)
E: [bluetooth] module-bluez5-device.c: SBC decoding error (-2)
E: [bluetooth] module-bluez5-device.c: SBC decoding error (-2)
E: [bluetooth] module-bluez5-device.c: SBC decoding error (-3)
E: [bluetooth] module-bluez5-device.c: SBC decoding error (-2)

and from bluez I get

Aug 26 17:49:07 mu kernel: Bluetooth: hci0: Frame reassembly failed (-84)
Aug 26 17:49:07 mu kernel: Bluetooth: hci0: Frame reassembly failed (-90)
Aug 26 17:49:07 mu kernel: Bluetooth: hci0: Frame reassembly failed (-84)
Aug 26 17:49:07 mu kernel: Bluetooth: hci0: Frame reassembly failed (-84)
Aug 26 17:49:07 mu kernel: Bluetooth: hci0: SCO packet for unknown connection handle 50346
@fatg3erman

This comment has been minimized.

fatg3erman commented Aug 26, 2018

I get periods of up to a minute of clicks and pops, then it goes away, often for several hours. It's worse when the speaker is futher away from the Pi.

@bwims

This comment has been minimized.

bwims commented Aug 27, 2018

@MilhouseVH many thanks for that! It let me to here which others might find useful.

@bwims

This comment has been minimized.

bwims commented Aug 27, 2018

FYI on libreELEC (Rpi 3+) the fix cures the stuttering but introduces an unacceptable audio delay if the movie is being served over WiFi. I guess it is a limitation of the platform.

@popcornmix

This comment has been minimized.

Collaborator

popcornmix commented Aug 29, 2018

Is the audio delay fixed? Can you correct for it using audio delay?
https://kodi.wiki/view/Video_playback#Audio_and_Subtitle_Settings

@lavermil

This comment has been minimized.

lavermil commented Nov 9, 2018

I moved my data from the builtin wlan0 to eth0 and bluetooth issues were resolved. Unfortunately we cannot have our cake and eat it too :(
I will have to try the NVRAM suggestion above when I get a chance.

@amilino

This comment has been minimized.

amilino commented Nov 24, 2018

I am still experiencing stuttering after trying all kind of fixes on my RPi 3+. Will disable wifi completely and use wire. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment