diff options
author | KUDr <kudr@openttd.org> | 2007-01-10 18:12:09 +0000 |
---|---|---|
committer | KUDr <kudr@openttd.org> | 2007-01-10 18:12:09 +0000 |
commit | e373ea7096c741a8189f7a480863fd21dd6f6be1 (patch) | |
tree | d9abc3d9810159441bed9f82a52bd1ee52d770dd /src/sound/sdl_s.cpp | |
parent | 001d858b528d78743deaf7dcea46ea8f0736bad9 (diff) | |
download | openttd-e373ea7096c741a8189f7a480863fd21dd6f6be1.tar.xz |
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
Diffstat (limited to 'src/sound/sdl_s.cpp')
-rw-r--r-- | src/sound/sdl_s.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/sound/sdl_s.cpp b/src/sound/sdl_s.cpp new file mode 100644 index 000000000..4b1da52d6 --- /dev/null +++ b/src/sound/sdl_s.cpp @@ -0,0 +1,47 @@ +/* $Id$ */ + +#include "../stdafx.h" + +#ifdef WITH_SDL + +#include "../openttd.h" +#include "../driver.h" +#include "../mixer.h" +#include "../sdl.h" +#include "sdl_s.h" +#include <SDL.h> + +static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len) +{ + MxMixSamples(stream, len / 4); +} + +static const char *SdlSoundStart(const char * const *parm) +{ + SDL_AudioSpec spec; + + const char *s = SdlOpen(SDL_INIT_AUDIO); + if (s != NULL) return s; + + spec.freq = GetDriverParamInt(parm, "hz", 11025); + spec.format = AUDIO_S16SYS; + spec.channels = 2; + spec.samples = 512; + spec.callback = fill_sound_buffer; + SDL_CALL SDL_OpenAudio(&spec, &spec); + SDL_CALL SDL_PauseAudio(0); + return NULL; +} + +static void SdlSoundStop(void) +{ + SDL_CALL SDL_CloseAudio(); + SdlClose(SDL_INIT_AUDIO); +} + +const HalSoundDriver _sdl_sound_driver = { + SdlSoundStart, + SdlSoundStop, +}; + +#endif |