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
00022 static FSoundDriver_SDL iFSoundDriver_SDL;
00023
00030 static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
00031 {
00032 MxMixSamples(stream, len / 4);
00033 }
00034
00035 const char *SoundDriver_SDL::Start(const char * const *parm)
00036 {
00037 SDL_AudioSpec spec;
00038
00039 const char *s = SdlOpen(SDL_INIT_AUDIO);
00040 if (s != NULL) return s;
00041
00042 spec.freq = GetDriverParamInt(parm, "hz", 44100);
00043 spec.format = AUDIO_S16SYS;
00044 spec.channels = 2;
00045 spec.samples = GetDriverParamInt(parm, "samples", 1024);
00046 spec.callback = fill_sound_buffer;
00047 MxInitialize(spec.freq);
00048 SDL_CALL SDL_OpenAudio(&spec, &spec);
00049 SDL_CALL SDL_PauseAudio(0);
00050 return NULL;
00051 }
00052
00053 void SoundDriver_SDL::Stop()
00054 {
00055 SDL_CALL SDL_CloseAudio();
00056 SdlClose(SDL_INIT_AUDIO);
00057 }
00058
00059 #endif