sdl播放音频

分类: C/C++ 发布时间: 2018-06-10 21:11

 

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);

}

}


如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!