GithubHelp home page GithubHelp logo

Comments (21)

lukasjapan avatar lukasjapan commented on August 21, 2024 4

Thanks for sharing.

Looks like a common problem with the Pi and people fix it by investing in an additional WiFi or Bluetooth dongle.

More info:

from bt-speaker.

photon-schiesser avatar photon-schiesser commented on August 21, 2024 3

@lnorton89 I can confirm that behavior regarding wlan0.

I am using a Raspberry Pi Zero W. I was also seeing overruns in the journal. I saw your comment and brought down wlan0 while playing music. The dropouts immediately stopped. Now it is playing quite smoothly.

Are the WiFi and Bluetooth chips on these boards (RPi 3 & Zero W) sharing a bus or channel? Perhaps that is the cause.

Could we attempt to get around this by using a lower sampling rate on the ALSA side?

A temporary workaround that would work for my use-case is to have a hook when a bluetooth client connects/disconnects that brings up/down the WiFi.

from bt-speaker.

lnorton89 avatar lnorton89 commented on August 21, 2024 1

I am having what appears to be the same issue; from my Galaxy S4 I can pair and play audio but with severe drop outs / noise / crazy things happening with audio playback speed (double speed!). With a Galaxy S5 I can pair and play audio as well with zero drop outs but with a fair amount of static in the background.

I have an idle load of 25% with bt_speaker.py being the source. I have uninstalled PulseAudio but have not updated bluez (due to inability to / no straightforward instructions to do so).

What can I do to troubleshoot this further / correct the issue? I have Wi-Fi disabled via the taskbar tool to do so.

from bt-speaker.

ritiek avatar ritiek commented on August 21, 2024 1

I am tinkering more into this and I found something weird.

I ran the command $ aplay - and KeyboardInterrupt (Control-C) it after a few seconds and then restarted the service $ sudo systemctl restart bt_speaker. I was able to connect back to my Pi and stream music without any issues! I am able to reproduce this behavior consistently and it works for me every time. Also, I am using an Android device (OnePlus Two) to stream music so this might also help with #12 (comment).

I have no idea what's happening at the moment. I'll see more into this if I can find anything useful.

Can you guys test this out?

from bt-speaker.

ElShapovalov avatar ElShapovalov commented on August 21, 2024 1

I have same problem with sound (very fast with pauses) (Samsung A5 2017).
I am a noob in python programming, but i change line 182 in file codecs.py (https://github.com/lukasjapan/bt-speaker/blob/master/bt_manager/codecs.py#L182), i set max_len=10240 and the problem is gone, even with working wi-fi.

from bt-speaker.

lukasjapan avatar lukasjapan commented on August 21, 2024

It looks like the daemon is not sending the audio data fast enough so alsa complains.
If it works with your phone it sounds like some compatibility issue with bluez (the linux bluetooth system).

In general you could try to do the following things in case of underruns:

  1. Check the CPU load
    Maybe the decoding process does not have enough resources.

  2. Check for PulseAudio
    If PulseAudio is installed I would recomnend to uninstall it.
    aplay should send the data straight to the soundcard.

  3. Update bluez
    Try another version or wait for an update of bluez. For this repository, at least bluez5 is needed.

In your case, the best bet would be option 3, I suppose.

from bt-speaker.

lukasjapan avatar lukasjapan commented on August 21, 2024

Playback with double speed and such may indicate that format negotiation (sampling rate, channels, etc) failed. But I am not sure about that since the arriving stream is encoded anyway.

If I can get hand on a device that reproduces the error, maybe I will look into this in the future.

from bt-speaker.

lnorton89 avatar lnorton89 commented on August 21, 2024

After some digging and messing around I was able to test with my S3 and have no issues with that device. After attempting to setup a hotspot via wlan0 when I brought the adapter up the dropouts occurred again. Taking down wlan0 reverses that action and also allows my S4 to perform without issues. I'm guessing when I disabled the wlan0 via the GUI it really wasn't disabled because I'm doing all of this via SSH. Using another Wi-Fi adapter via USB works and does not cause drop outs with either handset.

from bt-speaker.

pathammer avatar pathammer commented on August 21, 2024

I can confirm that using an external wifi adapter resolves the original issue I reported. I'll let @lukasjapan decide if he wants to close the issue.

from bt-speaker.

lukasjapan avatar lukasjapan commented on August 21, 2024

I'll leave it open for people to know. Using WiFi and Bluetooth at the same time is a very likely use case.

from bt-speaker.

matisflores avatar matisflores commented on August 21, 2024

Hi @lukasjapan, great project.
You consider add 'ifconfig wlan0 (up|down)' on connect/disconnect events?
I add 'subprocess.Popen('ifconfig wlan0 down', shell=True)' but nothing happen.

from bt-speaker.

pathammer avatar pathammer commented on August 21, 2024

from bt-speaker.

jdubbandroid avatar jdubbandroid commented on August 21, 2024

I'm experiencing the same problem, only with an Anker Bluetooth keyboard, not a speaker. The keyboard works fine until I enable Bluetooth on my brand new Pi 3 model B. Then it stops working.

from bt-speaker.

ritiek avatar ritiek commented on August 21, 2024

I am facing a similar problem on my Pi 2. I use an external wifi adapter but disabling it doesn't fix the problem.

from bt-speaker.

ritiek avatar ritiek commented on August 21, 2024

Another thing I noticed that if I remove bt-speaker service and run the python file directly without root, the sound works fine as well. It causes problems only when running as root. Although, stuff like volume control, etc. is not available without root. Going to take a better look.

from bt-speaker.

ritiek avatar ritiek commented on August 21, 2024

As an update, I tried to follow this gist and now everything works perfect for me, including volume control.

from bt-speaker.

photon-schiesser avatar photon-schiesser commented on August 21, 2024

@ElShapovalov Thank you! I tried your suggestion, but I found that changing it to 32768 (2^15, seemed like a good number?) did the trick. I was still getting underruns with 10240. WiFi still on as well! Thank you!

Edit: Of course, as I send this message, I started getting underruns again... :( Strangely, after about 2 minutes of perfect playback. I was streaming, but now I am playing a downloaded song via YouTube Music app on Android 5.1.1. Will report back.

from bt-speaker.

insoPL avatar insoPL commented on August 21, 2024

I had same problems (Stuttering audio and buffer underruns) when connecting from sm-t530. I checked 2 different android phones and everything worked smoothly. I can confirm that changing max_len to 10240 did the trick. I'm still getting 1/2 second lag but i guess with raspberry pi zero running bt and wifi it will just be like that.

from bt-speaker.

roflmaostc avatar roflmaostc commented on August 21, 2024

For me I had to adapt /etc/bt_speaker/config.ini:
play_command = aplay -Dplug:default -f cd -

Now it works flawlessly with a external USB card.

from bt-speaker.

pktmterenceg avatar pktmterenceg commented on August 21, 2024

Confirming that @ScheissSchiesser 's suggestion above to increase the buffer to 32768 works with the wifi interface off (ifconfig lwan0 down).

I found that playing music from iTunes (12.8) from a Mac (Mac OS 10.13) produced the stuttering effect/underrun situation described by others here.

from bt-speaker.

Josonosimiti avatar Josonosimiti commented on August 21, 2024

Hello, how exactly can i edit codecs.py? I have the same issue with audio playing too fast and stopping every 2 seconds.

from bt-speaker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.