diff options
author | tron <tron@openttd.org> | 2005-07-23 15:48:00 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-07-23 15:48:00 +0000 |
commit | 10fd03e222dfd78abd7e9c78a215d4b8bc36cf3b (patch) | |
tree | 265b5c47cc68bef828546de2508f0641f8563050 /sound/sdl_s.c | |
parent | 54e02a620a6e71e30ac49c604ff225a44a3d623b (diff) | |
download | openttd-10fd03e222dfd78abd7e9c78a215d4b8bc36cf3b.tar.xz |
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
Diffstat (limited to 'sound/sdl_s.c')
-rw-r--r-- | sound/sdl_s.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sound/sdl_s.c b/sound/sdl_s.c new file mode 100644 index 000000000..9ff1ca5cb --- /dev/null +++ b/sound/sdl_s.c @@ -0,0 +1,40 @@ +#include "stdafx.h" +#include "openttd.h" +#include "driver.h" +#include "mixer.h" +#include "sdl.h" +#include "sound/sdl_s.h" +#include <SDL.h> + +static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len) +{ + MxMixSamples(_mixer, 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, +}; |