-
Notifications
You must be signed in to change notification settings - Fork 5.2k
snd_bcm2835 and Pulseaudio 5 do not get along #688
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
Comments
I am having a similar problem with Pulseaudio 6.0. Pulseaudio tends to either not play at all, or lock up after a few minutes of playback. Also using Arch Linux. Have tried both user mode (running as root) as well as system mode, as I have the Pi set up headless. |
The following is the error printed by Pulseaudio whenever it hangs (after about a minute or two of playback, usually) E: [alsa-sink-bcm2835 ALSA] alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write! |
I too am having terrible issues with the bcm2835 and pulse 6. |
My setup: pulseaudio+mpd+ncmpcpp. My test setup is to start a song and play/pause repeatedly. After a maximum 3 times of play/pause pulseaudio will hang and has to be restarted. None of the workarounds to be found on the web (tsched=0, disabling module-suspend-on-idle, ...) has worked. I'll finally give up on this issue because I didn't find a solution for more than a year now. Either I'll buy myself a Raspberry 2 or I'll use mpd with the ALSA backend, because that works great. |
@maxnet has this issue been resolved? If yes, then please close this issue. |
I don't think so. It doesn't work with Raspberry 3 either (which is no wonder because it uses the same chip/driver: snd_bcm2835). |
I have this problem on my Raspberry 3 running ubuntu 16.04. As a workaround I will put a 5 second timeout delay in my program, but that messes up the naturalness of the output (It is a speech synthesizer) |
Same issue with my pi3 and ubuntu mate 16.04 and mpd sounds fantastic unless I change volume (which causes stuttering or sound loss) also looses sound randomly among other issues.really frustrating. |
Same issue at Rpi B (not 2 or 3) with latest kernel (684be4bc8cc343f60fdc3240c6d55d41d0a5b56c) |
Can confirm that issue with an rpi3 running |
Confirming issue on rpi3 running
|
Having the same problematic behavior as described by @flittermice 😞 Has anyone found a solution to this yet? 🤞 😄 |
Found something interesting (maybe):
Works for a random amount of time, then it's back to @flittermice's behavior 😭 |
I debugged further into this issue, and found that Pulseaudio's use of an esoteric ALSA feature called "rewinding" is causing this problem. |
But can Pulse function properly if you take away that feature? Keep in mind that part of the functionality it offers as sound server is mixing sound that can originate from multiple applications together. |
@maxnet A proper fix (mine isn't) would fix the latency at a rather low value, which eliminates the need for rewinding, at the cost of a slightly higher CPU load / power consumption. |
Always having low latency, would imply using tiny buffers. Would argue that a proper fix would be in the kernel module... |
@strfry: relation to ALSA rewinding sounds reasonable. When pulseaudio gets "unhappy", it usually ends in this line:
However, I somewhat agree with @maxnet, and there's probably a reason for ALSA doing this in the first place... 😉 Is this only non-functional on the Raspberry Pi or a general issue of pulseaudio+ALSA? |
@pjotrek-b It is non-functional only with Raspberry PI built-in sound 'card'. We use pulseaudio as network sound server successfully with USB sound card for number of months without issues. |
I can confirm @jekhor's statement. As the log file says: "E: [alsa-sink-bcm2835 ALSA] alsa-sink.c: Most likely this is a bug in the ALSA driver '(null)'. Please report this issue to the ALSA developers.". Does anyone know how to do this? |
@jekhor: Thanks for clearing this up! 😄 What's now puzzling is that, I always thought it's like this: If so, how can the same applications that have this issue, work flawlessly when using ALSA directly? Now if this issue is specific to RPi's built-in sound card/chip, how come these problems don't appear with alsa-only use, too? 😕 |
@strfry: I've found a quite detailed article about "Rewinding" in pulseaudio's documentation. I've read parts of it and it doesn't seem that "esoteric" to me now anymore. Since you've looked at its code: Any ideas what could cause it to make pulseaudio "get stuck"? |
@pjotrek-b Sure it makes sense given the design goals of Pulseaudio. It is "esoteric" in the sense that 99% of normal ALSA applications will never use rewind, and thus trigger a less tested path in the ALSA driver. Unfortunately, Pulseaudio lacks on option to disable use of this potentially buggy feature (like other, e.g. timer-based scheduling). @flittermice I guess in this case, the responsible ALSA developer is someone of the Raspberry Pi kernel developers who wrote the snd_bcm2835 driver, so this repository would be the right place to report this. A simple code example that demonstrates a clearly wrong behaviour of ALSA when using rewind would probably be helpful to the kernel developers when taking a closer look at this bug. |
1 similar comment
@pjotrek-b Sure it makes sense given the design goals of Pulseaudio. It is "esoteric" in the sense that 99% of normal ALSA applications will never use rewind, and thus trigger a less tested path in the ALSA driver. Unfortunately, Pulseaudio lacks on option to disable use of this potentially buggy feature (like other, e.g. timer-based scheduling). @flittermice I guess in this case, the responsible ALSA developer is someone of the Raspberry Pi kernel developers who wrote the snd_bcm2835 driver, so this repository would be the right place to report this. A simple code example that demonstrates a clearly wrong behaviour of ALSA when using rewind would probably be helpful to the kernel developers when taking a closer look at this bug. |
Applications using ALSA directly typically have no need to use rewind. It is used in situations in which there is a change of plans. Sure, if you use tiny buffers that hold milliseconds instead of seconds of audio, one could do without rewinds.
Pulse Audio also closes the connection to the sound device 5 seconds after the last client using it disconnects, if no other clients connect during that time. |
Does anyone know if this is still an issue in the latest Raspbian (with kernel 4.14.y)? This issue will be closed within 30 days unless further interactions are posted. If you wish this issue to remain open, please add a comment. A closed issue may be reopened if requested. |
I'd check, but I currently don't have the time to test it... 😞 |
Though I'm pretty sure there have been no improvements, I cannot contribute much for this particular bug. I bought an external USB sound card with a PCM2704 chipset and am now happy with the snd_usb_audio driver. |
Closing due to lack of activity. Please request to be reopened if you feel this issue is still relevant. |
Can confirm that this happens to my Rasp Pi 3 |
Can confirm this is still happening on my RPI3:
Trying to use mpd with pulseaudio I get:
Any chance we can reopen this issue? |
|
@l4rzy: you're making us curious. Which permissions? |
@flittermice: Oops, I misunderstood the situation since I commented on this for months. It was not about permissions. |
@l4rzy: Working around is the way to go :-) BTW: Did you ever try not to load "module-suspend-on-idle" in default.pa? |
@flittermice i tried. Doesn't help. |
Pulseaudio is still not working with snd_bcm2835. Can you reopen this issue, please? |
I can confirm it not working for me either. I've been testing different code and compile options and I've been unable to get it to work. I'm on ArchLinux ARM and all the newest software. I'm happy to help debug if possible. For me, near as I can tell, the issue comes from the buffer size reported by the bcm2835_alsa module. The audio buffer reported to pulse is 8816 bits, or just enough for approximately 1.56 ms of audio from a network stream. I'm not enough of a hardware geek to find the specs but something seems off here. According to ALSA itself (i.e. not the pulse module) the buffer size is a much more logical 131072 bits. If I were to guess, pulse thinks it can't keep the buffer full for the card and tries to rewind because it is being told there's a software limit of 8816 bits... but maybe I'm way off base here. |
Just had the same issue (it's really anoying), @JamesH65 could you reopen it to further track it? |
Hmmm... I cannot reproduce this with Raspberry Pi 3 B v1.2 and latest 4.19.34 kernel (updated by rpi-update to Hexxeh/rpi-firmware@99c2746). I have no idea why, driver seems not changed from 2016. Maybe some VC firmware changes? |
Hi, on Raspberry Pi 4 B v1.1, kernel 5.3.0-1014 has the same problem with sound fading with pulseaudio v13.0. Sound is lost if a stereo output is selected in pavucontrol. Is there any solution? |
I think this is because PulseAudio is detecting the sinks as Mono by default (because of this issue), and the default buffer size for these is lower.
Make sure to update PA's default profile config file so that stereo output actually works using PA on the RPI 4, and make sure you have |
kbuild: canonicalization of target path not needed anymore
I can confirm that this error still regularly appears in the log on latest RPI OS aarch64 running on RPI 4B 4G rev 1.5:
Also I notice that sometimes OS freezes and sound disappears for a short period of time. But I'm not sure if its related with this error. It also may be related with this bug: #5582 |
I am having unreliable audio on a system that has Pulseaudio 5.0 installed.
It seems that when Pulseaudio is installed, and an application has finished playing audio, Pulseaudio doesn't close the audio device straight away, but waits 5 seconds.
If another application shows up that wants to play audio within that time, it re-uses the same connection.
However it seems that does not work properly on the Pi.
If I do:
The file plays correctly the first time, but the second time there is no sound, and the program never finishes executing.
It just prints "Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono", and sits there.
Problem doesn't happen when sleeping at least 5 seconds.
No idea how to debug this, and if the problem is in the ALSA module or in Pulseaudio.
But here is the output of bcm2835_snd with debugging enabled in case that is useful to anyone: https://paste.ee/r/soht7
Was able to reproduce the issue with both my own custom Linux distribution, and with Arch Linux (installed Pulse with: "pacman -Sy pulseaudio pulseaudio-alsa alsa-utils ; pulseaudio --start")
Doesn't seem to happen with very old versions of Pulse, like 2.0 which you get when you install it through Raspbian.
The text was updated successfully, but these errors were encountered: