tron@2186: /* $Id$ */ tron@2186: tron@2189: #include "../stdafx.h" tron@2189: tron@2189: #ifdef WITH_SDL tron@2189: tron@2189: #include "../openttd.h" tron@2189: #include "../driver.h" tron@2189: #include "../mixer.h" tron@2189: #include "../sdl.h" tron@2189: #include "sdl_s.h" tron@2174: #include tron@2174: tron@2174: static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len) tron@2174: { tron@2977: MxMixSamples(stream, len / 4); tron@2174: } tron@2174: tron@2174: static const char *SdlSoundStart(const char * const *parm) tron@2174: { tron@2174: SDL_AudioSpec spec; tron@2174: tron@2174: const char *s = SdlOpen(SDL_INIT_AUDIO); tron@2174: if (s != NULL) return s; tron@2174: tron@2174: spec.freq = GetDriverParamInt(parm, "hz", 11025); tron@2174: spec.format = AUDIO_S16SYS; tron@2174: spec.channels = 2; tron@2174: spec.samples = 512; tron@2174: spec.callback = fill_sound_buffer; tron@2174: SDL_CALL SDL_OpenAudio(&spec, &spec); tron@2174: SDL_CALL SDL_PauseAudio(0); tron@2174: return NULL; tron@2174: } tron@2174: tron@2174: static void SdlSoundStop(void) tron@2174: { tron@2174: SDL_CALL SDL_CloseAudio(); tron@2174: SdlClose(SDL_INIT_AUDIO); tron@2174: } tron@2174: tron@2174: const HalSoundDriver _sdl_sound_driver = { tron@2174: SdlSoundStart, tron@2174: SdlSoundStop, tron@2174: }; tron@2189: tron@2189: #endif