问题描述
ffmpeg解码音频后,经过swr_convert重采样,然后送入sdl进行播放,播放声音会出现卡顿的现象。
原因分析
swr_convert重采样后的帧样本数同sdl的输入帧样本数不一致导致。
解决方案
SDL_OpenAudio(&audioSpec, NULL)打开设备时需要传入SDL_AudioSpec结构体audioSpec,其中包含一个成员samples,此成员需要与
int swr_convert(struct SwrContext *s, uint8_t **out, int out_count,
const uint8_t **in , int in_count);
第三个参数out_count一致。