Hi there,
I’ve been experimenting with this setting (audio latency) on my Pi2, and there’s something strange I don’t quite understand here. The onboard audio works good with 1024 bytes buffer sizes, which at 48000Hz, 32bits per sample (stereo sound), would be: 1024 / 48000 * 4bytes/sample = 5.333ms
As you can see here, I did some experiments with this in the past on the official Raspberry Pi repository with the kernel/tools people:
We came to the conclussion that, for a 1024 buffer size, the ALSA driver needs to have that buffer divided in only a period, but that’s all.
However, if I set, for example, 32ms of audio latency in RetroArch, even if CPU usage of the Pi2 running, let’s say, the fceumm NES core, is aways ~30%, I start to get audio distortion. At 16ms, the audio is horribly distorted. That makes no sense, as far as I know. I event tried changing, on sound/arm/bcm2835-pcm.c in the kernel
.period_bytes_min = 1 * 256
into:
.period_bytes_min = 1 * 256
However, the results are the same. Also, according to this:
http://wiki.linuxaudio.org/wiki/raspberrypi
" Don’t expect wonders from using the onboard audio in a real-time context, the onboard audio uses an intermediate buffer so you probably can’t use period settings below 256." Well, I am not trying to go THAT low, so something ~16ms should work well enough.
I have found that RetroArch sets periods number in audio/drivers/alsa.c here:
unsigned periods = 4;
So there I went and changed that to 2 and sound becomes distorted even for 64ms of latency. Again, makes no sense in my head… Setting the period number to 1 produces a RA executable that’s so slow that NES games will take minutes to render a frame. Again, I don’t get it.
Any ideas?