c++ - Jerky sound from libretro using libao -


i'm trying create tiny libretro frontend in c++ using sfml graphics, libao sound , parts of qt framework.

here logic : using sfml's built-in clock system, refresh @ every frame libretro core, @ given cadency. core first polls inputs , gives me video , audio output generated frame.

the problem audio : every frame, core gives me enough audio match sample rate (for snes it's 32000 samples per second, example). so, each time audio callback, use ao_play play needed.

here code run @ every frame ; i've initialized libao using parameters given core : signed 16bits integers, sample rate , 2 channels.

size_t retrocore::processaudiosamplebatch(const int16_t *data, size_t frames) {     ao_play(&aodevice, (char*)data, frames*4);     return frames; //just inform core } 

but result quite jerky, if there latency between each frame. sound accurate, sounds low quality , poor outputted. i've been told need stronger sound implementation, mean ? need resample sound, or make external thread ?

thanks !