-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Prevent ALSA audio corruption #43928
Conversation
When using the ALSA driver, corruption would occur if `snd_pcm_writei` was unable to consume the entire sound buffer. This would occur frequently on the Raspberry Pi 3 which uses the `snd_bcm2835` audio driver. This bug resulted from incorrect pointer math on line 187, resulting in the sample source pointer being advanced by `total * ad->channels` bytes instead of `total * ad->channels` samples. In my opinion, the best fix is to change `*src` to type `int16_t`, since that is the sample type in use. Fixes godotengine#43927.
Thanks! And congrats for your first merged Godot contribution 🎉 |
Do you think this could be back ported to 3.x.x? |
That's what |
Oh, sorry! I didn't see that. Thanks! |
FYI, I've compiled Godot 3.2.3 on a Raspberry Pi 4 with that change and it fixed the issue! :) |
Cherry-picked for 3.2.4. |
I was having this problem with ALSA. Installing pulseaudio and running with I've applied this patch to the
Sometimes it kills pulseaudio completely:
And also:
|
I'm not an expert @cesarizu , but try uninstalling |
@cesarizu The problem you are noticing was likely already there before this patch. If you follow the original discussion (https://github.com/efornara/frt/issues/14), it looks like that, at least on a Raspberry Pi 3, changing the project audio mix rate to 44000 and increasing the audio latency to 20ms was needed to fix the buffer underrun problem. Maybe this helps. |
@hiulit and @efornara yes indeed I been having this problem for some time. I'm running a few games in multiple raspberry pi 4 (64bits) in some sort of a kiosk (14h a day) for months. Initially, without pulseaudio installed, I would get very choppy audio and the errors would show up very quickly (in the first hour). Then audio would stop. After installing pulseaudio I would get the error once a day and the audio wouldn't stop most of the days. Without I've been running with the latency to 45ms for weeks but I haven't tried changing the audio mix rate to 48000. I will do that right away. I just applied this patch a few days ago (as soon as I saw it). Since then, I've seen around the same number of errors but also pulseaudio started to crash completely and I'm seeing some new errors like:
I'll try uninstalling pulseaudio and making the other changes and I'll report back any news on that. |
@akien-mga will this only be cherry picked for |
I can cherry-pick it to earlier branches but aside from |
Ok, I understand. Thanks! |
Just an update: I've been running the PIs almost continuously for a couple days with some different configurations and this is what works and doesn't work for me:
These are the results: A. Without pulseaudio installed (with or without |
When using the ALSA driver, corruption would occur if
snd_pcm_writei
was unable to consume the entire sound buffer. This would occur
frequently on the Raspberry Pi 3 which uses the
snd_bcm2835
audiodriver.
This bug resulted from incorrect pointer math on line 187, resulting in
the sample source pointer being advanced by
total * ad->channels
bytesinstead of
total * ad->channels
samples. In my opinion, the best fixis to change
*src
to typeint16_t
, since that is the sample type inuse.
Fixes #43927.