sdl播放音频
DWORD playaudio(void* lpParam)
{
UINT dwDuration = 0;
UINT start_time = 0;
DWORD lastplaytime = GetTickCount();
if ( SDL_Init( SDL_INIT_AUDIO| SDL_INIT_TIMER ) )
{ return 0; }
SDL_AudioSpec wanted_spec;
wanted_spec.freq = 8000;
wanted_spec.format = AUDIO_S16;/*AUDIO_S32SYS*//*AUDIO_S16SYS*/;
wanted_spec.channels = 1;
wanted_spec.silence = 0;
wanted_spec.samples = 640/*1024*/;
wanted_spec.callback = fill_audio;
int sdlres = SDL_OpenAudio(&wanted_spec, NULL);
if (sdlres <0)
{ return 0; }
audio_chunk = (Uint8*)decbuf;
audio_len = declen;
audio_pos = audio_chunk;
SDL_PauseAudio(0);
}
}
扫描下方二维码,关注业余草微信公众号,回复“FFmpeg”关键词,获取 FFmpeg 视频教程!