sdl_s.cpp
Go to the documentation of this file.00001
00002
00005 #ifdef WITH_SDL
00006
00007 #include "../stdafx.h"
00008
00009 #include "../mixer.h"
00010 #include "../sdl.h"
00011 #include "sdl_s.h"
00012 #include <SDL.h>
00013
00014 static FSoundDriver_SDL iFSoundDriver_SDL;
00015
00016 static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
00017 {
00018 MxMixSamples(stream, len / 4);
00019 }
00020
00021 const char *SoundDriver_SDL::Start(const char * const *parm)
00022 {
00023 SDL_AudioSpec spec;
00024
00025 const char *s = SdlOpen(SDL_INIT_AUDIO);
00026 if (s != NULL) return s;
00027
00028 spec.freq = GetDriverParamInt(parm, "hz", 11025);
00029 spec.format = AUDIO_S16SYS;
00030 spec.channels = 2;
00031 spec.samples = 512;
00032 spec.callback = fill_sound_buffer;
00033 SDL_CALL SDL_OpenAudio(&spec, &spec);
00034 SDL_CALL SDL_PauseAudio(0);
00035 return NULL;
00036 }
00037
00038 void SoundDriver_SDL::Stop()
00039 {
00040 SDL_CALL SDL_CloseAudio();
00041 SdlClose(SDL_INIT_AUDIO);
00042 }
00043
00044 #endif