2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2005-07-25 07:16:10 +00:00
|
|
|
#include "../stdafx.h"
|
|
|
|
|
|
|
|
#ifdef WITH_SDL
|
|
|
|
|
|
|
|
#include "../openttd.h"
|
|
|
|
#include "../driver.h"
|
|
|
|
#include "../mixer.h"
|
|
|
|
#include "../sdl.h"
|
|
|
|
#include "sdl_s.h"
|
2005-07-23 15:16:57 +00:00
|
|
|
#include <SDL.h>
|
|
|
|
|
|
|
|
static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len)
|
|
|
|
{
|
2006-02-05 09:56:04 +00:00
|
|
|
MxMixSamples(stream, len / 4);
|
2005-07-23 15:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
2005-07-25 07:16:10 +00:00
|
|
|
|
|
|
|
#endif
|