Skip to content
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 · 143 comments
Open

Pi3 bluetooth audio stutters with Wifi enabled #1402

SebTC opened this issue Apr 11, 2016 · 143 comments

Comments

@SebTC
Copy link

@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
Copy link

@pbros 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
Copy link

@REY-01 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
Copy link

@pbros 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
Copy link
Contributor

@Ferroin 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
Copy link
Contributor

@pelwell pelwell commented Apr 19, 2016

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

@WayneKeenan
Copy link

@WayneKeenan 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
Copy link

@rschulman 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
Copy link

@adn77 adn77 commented Nov 14, 2016

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

@libertineplusplus
Copy link

@libertineplusplus 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
Copy link

@vgallissot 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
Copy link

@daryltucker 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
Copy link

@jeffleus 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
Copy link

@mohitkalraniit 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
Copy link

@hurda 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
Copy link

@BaReinhard 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
Copy link

@abatardi 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
Copy link

@kalramohit 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
Copy link

@hurda hurda commented Mar 3, 2017

Bluetooth + LAN is no problem.

Please show me the LAN-port on the Pi0W.

@BaReinhard
Copy link

@BaReinhard BaReinhard commented Mar 6, 2017

Has anyone tried renicing pulseaudio to have a higher priority?

@pradeepprakash
Copy link

@pradeepprakash pradeepprakash commented Mar 7, 2017

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

@pradeepprakash
Copy link

@pradeepprakash pradeepprakash commented Mar 7, 2017

@Michiman
Copy link

@Michiman 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
Copy link

@mwestphal 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
Copy link

@Michiman 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
Copy link

@mwestphal 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.

@JamesH65
Copy link
Contributor

@JamesH65 JamesH65 commented Jan 18, 2019

@pelwell
Copy link
Contributor

@pelwell pelwell commented Jan 18, 2019

The updated NVRAM files have been in Raspbian updates since August 2018. Alternatively you can download them directly:

Copy them into the /lib/firmware/brcm folder (you will need to sudo cp ...).

@alanmilinovic
Copy link

@alanmilinovic alanmilinovic commented Jan 18, 2019

Sorry but that doesn't work. Still have stuttering with Wifi.

@pelwell
Copy link
Contributor

@pelwell pelwell commented Jan 18, 2019

That's a shame. Did you reboot after installing?

Unfortunately there are limits to what can be achieved with a shared antenna. Have you tried changing the distance from the Pi to the AP and/or the BT device?

@alanmilinovic
Copy link

@alanmilinovic alanmilinovic commented Jan 18, 2019

Yes, have struggled with this for some months now. I switched to the network cable and no problems any more.

romybompart added a commit to romybompart/AudioStreaming_RPI_Zero_W_Bluetooth that referenced this issue Mar 4, 2019
The bluetoothctl sometimes needs to be turned on 3 times in order to make it run. 
The wlan0 is not disable in this code, but it should be because there is audio stutters with Wifi enabled: raspberrypi/linux#1402
@flok99
Copy link
Contributor

@flok99 flok99 commented Mar 5, 2019

Hi,
With the updated /usr/lib/firmware/updates/brcm/brcmfmac43430-sdio.txt and friend, and yes I rebooted :-), I still hear underruns on usb audio that are not there with on-board audio (every 5 seconds or so).
Not using wifi, all ethernet.

If on the otherhand I do ifconfig wlan0 down first, then all is fine...!
oh, no, it isn't. just far less

@pelwell
Copy link
Contributor

@pelwell pelwell commented Mar 5, 2019

You're reporting stuttering USB audio with Ethernet in an issue about Bluetooth audio with WiFi?

@flok99
Copy link
Contributor

@flok99 flok99 commented Mar 5, 2019

oops!

@pratt-jeremy
Copy link

@pratt-jeremy pratt-jeremy commented Mar 29, 2019

This Bluetooth + WiFi issue is causing issues with my keyboard doing multiple keystrokes for 1 key down up.

@JamesH65
Copy link
Contributor

@JamesH65 JamesH65 commented Mar 29, 2019

@pratt-jeremy Is that a wireless keyboard?

@gearhead
Copy link

@gearhead gearhead commented Apr 9, 2019

I have the same problem. Running Arch on a Pi B3, B3+ and Zero. All exhibit the same symptoms: Choppy play with a2dp. Arch has not updated the firmware as listed here, but I did that manually first. If I use the onboard BT on these 3 machines, Bluealsa complains of buffer under runs and it plays music in spurts. The journal shows a buffer under run. If I use a USB dongle it all works as expected. Can we try anything else? fwiw, my kernel is 4.19.32

@bwims
Copy link

@bwims bwims commented Apr 9, 2019

It seems clear to me that putting bluetooth and wifi on a RPi is like making a silk purse out of a sow's ear.

The Raspberry Pi development team should state that playing audio over bluetooth whilst playing a video over wifi is simply unsupported thanks to a lack of horsepower / bandwidth.

Since day one the Pi has been touted as an updated replacement for the BBC micro, for teaching kids in schools. Kodi was a major bonus. I have just given up on this idea. I wanted to serve films to a pi-top with a bluetooth link to my caravan's audio system, but now I just plug a movie hard drive into a usb port. No Wifi, no stuttering. Sad, but not too inconvenient.

@gearhead
Copy link

@gearhead gearhead commented Apr 9, 2019

Is this the appropriate command to run to get the onboard BT working?
/usr/bin/btattach -B /dev/ttyAMA0 -P bcm -S 3000000
This is the command in the service file for Arch Linux with the default install of Bluez 5.50

@gearhead
Copy link

@gearhead gearhead commented Apr 10, 2019

So I have streaming audio to a B3+ with wifi enabled and active (I am logged in via ssh). I am running Arch Linux. I had to install bluez-utils-compat to get the hciattach command installed. I believe Raspian has this already...

cat /proc/asound/card0/pcm0p/sub0/hw_params 
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (352800/8)
period_size: 4410
buffer_size: 22050

The default Bluez 5.50 package has btattach which Arch uses to turn on the BT adapter. This did not work. All I got was stuttering sound. This the Arch pi-bluetooth package calls for the command to be:
ExecStart=/usr/bin/btattach -B /dev/ttyAMA0 -P bcm -S 3000000
The command that worked was from an older version of the package:
ExecStart=/usr/bin/hciattach -n /dev/ttyAMA0 bcm43xx 921600 noflow -
I do not claim to know if this is 'correct' or whatever, just that this is the first time I have had smooth playing bluetooth using the onboard adapter.

greg-erskine pushed a commit to greg-erskine/pCP-github that referenced this issue Aug 19, 2019
@vitaminace33
Copy link

@vitaminace33 vitaminace33 commented Oct 29, 2019

Just to avoid confusions. Broadcom WiFi tech was bought by Cypress back in June 2016. Since then

  • BCM43438 is CYW43438
  • BCM43455 is CYW43455
@pratt-jeremy
Copy link

@pratt-jeremy pratt-jeremy commented Oct 29, 2019

@pratt-jeremy Is that a wireless keyboard?

@JamesH65 yes, it's a bluetooth keyboard I see this was for audio, but thought i'd mention it. Once I turned off the wifi the bluetooth keyboard worked perfectly. No repeated characters i didn't press.

@JamesH65
Copy link
Contributor

@JamesH65 JamesH65 commented Oct 30, 2019

Presumably your distro is fully up to date?

@pratt-jeremy
Copy link

@pratt-jeremy pratt-jeremy commented Oct 30, 2019

Presumably your distro is fully up to date?

It was up to date when I posted here, it's probably out of date by now since it was in Mar. I'll update and see if it still is happening.

@parkerlreed
Copy link

@parkerlreed parkerlreed commented May 12, 2020

On an RPI4 with WiFi soft blocked in rfkill. Still choppy on Pulseaudio A2DP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet