Sound Delay


Raspberry Pi3, Allegro 5.

I have delays when playing wav sounds.

I used pulseaudio (very bad, 5+ seconds).
With pulseaudio disabled and alsa, about 500ms.

I tried al_load_sample/al_play_sample and also al_create_sample_instance/al_play_sample_instance.

The wav file is short, about 1-2 seconds.

With command aplay is ok.

I have read
and other threads but I can't solve.

Mark Oates

Are you loading your samples right at play time or are you preloading them all first before using al_play_sample.

Chris Katko

Looks like others had it happen... both with Allegro ... and SDL.

See last post here:


Okay, so I think I have the high latency issue resolved. It would seem to be an issue with the Raspberry Pi's sound hardware, or at least that's the perhaps simplistic conclusion I draw from getting low latency audio playback using USB headphones. I have heard the Raspberry Pi's audio is a little flaky and that external USB audio adapters have been handy with the RPi. Here's what I found works...

1) Disable the Raspberry Pi's on-board sound hardware.
2) Connect USB headphones to the RPi.
3) Reboot.
4) Specify to use PulseAudio before I initialize audio in my program.
5) Start PulseAudio.
6) Run my program.

Not sure if it's related to your case or not. But I've definitely seem multiple threads about RPi and delay.


Please try the attached patch, it helped significantly on my RPI.

It adds a new configuration option under the alsa section called buffer_frames. Try reducing it if you still see a delay, or increasing it if the sound appears choppy. If this works, there'll be a slightly more advanced version of this change committed soon.


Yes, that is.

I leave value (2048) unchanged in your patch.
Sounds starts ok now.

Many thanks SiegeLord.

Thread #617264. Printed from