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