# sdl_s.cpp

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