[Workaround] A RPI2 sound is crackli ng and lagging

Applies to : Raspberry Pi 2 and SDL2
OS : Raspbian Jessie

Problems encountered:

  • the sound of your SDL2 game is lagging by half a second over HDMI audio
  • the sound in your headset (with a jack) is crackling when plugged into the RPI

Possible cause:??your SDL application uses Pulseaudio

Workarounds:

  • Compile SDL without pulseaudio support (and ship it with your game):
    ./configure --disable-esd --enable-alsa --disable-pulseaudio --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl

  • Open audio mixer at 48Khz (matching hardware decoder)
    Mix_OpenAudio(48000, MIX_DEFAULT_FORMAT, 2, 4096)