mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-21 22:53:19 +00:00
07a6e612ec
This results in shorter and hopefully easier to maintain files. Note: I had to change paths in #include statements of some unrelated files, because I added the ottd base directory to the include path (-I.)
41 lines
821 B
C
41 lines
821 B
C
#include "stdafx.h"
|
|
#include "openttd.h"
|
|
#include "driver.h"
|
|
#include "mixer.h"
|
|
#include "sdl.h"
|
|
#include "sound/sdl.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,
|
|
};
|