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

Glitched audio on Raspberry Pi 3 when using ALSA driver #43927

Closed
charasyn opened this issue Nov 27, 2020 · 1 comment · Fixed by #43928
Closed

Glitched audio on Raspberry Pi 3 when using ALSA driver #43927

charasyn opened this issue Nov 27, 2020 · 1 comment · Fixed by #43928

Comments

@charasyn
Copy link
Contributor

Godot version:

3.2.3

OS/device including version:

Linux raspberrypi-fgts 5.4.72-v7+ #1356 SMP Thu Oct 22 13:56:54 BST 2020 armv7l GNU/Linux
Debian 10.6 on Raspberry Pi 3
Audio driver: snd_bcm2835

Issue description:

Audio playback is garbled and swaps back and forth between sound channels (ex. sounds playing on only Left/Right channel can be heard on both speakers)

Steps to reproduce:
Run the given project on Raspberry Pi 3 and observe bad audio quality.

Minimal reproduction project:

testaudiopi.zip

I have debugged this and have determined that there is a bug in the ALSA driver, please see https://github.com/efornara/frt/issues/14#issuecomment-734964644

@hiulit
Copy link

hiulit commented Nov 27, 2020

I can confirm this issue.
In my case, I'm using a Raspberry Pi 4.
I've tested Godot 3.1.2 and 3.2.3.

Here you can listen the same audio played on VLC and then in Godot https://twitter.com/hiulit/status/1330873256904110081?s=20

charasyn added a commit to charasyn/godot that referenced this issue Nov 27, 2020
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.
@akien-mga akien-mga added this to the 4.0 milestone Nov 28, 2020
akien-mga pushed a commit to akien-mga/godot that referenced this issue Dec 2, 2020
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.

(cherry picked from commit 25b2f82)
HEAVYPOLY pushed a commit to HEAVYPOLY/godot that referenced this issue Dec 14, 2020
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.

(cherry picked from commit 25b2f82)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants