equal
deleted
inserted
replaced
1 #include "stdafx.h" |
|
2 #include "openttd.h" |
|
3 #include "driver.h" |
|
4 #include "mixer.h" |
|
5 #include "sdl.h" |
|
6 #include "sound/sdl.h" |
|
7 #include <SDL.h> |
|
8 |
|
9 static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len) |
|
10 { |
|
11 MxMixSamples(_mixer, stream, len / 4); |
|
12 } |
|
13 |
|
14 static const char *SdlSoundStart(const char * const *parm) |
|
15 { |
|
16 SDL_AudioSpec spec; |
|
17 |
|
18 const char *s = SdlOpen(SDL_INIT_AUDIO); |
|
19 if (s != NULL) return s; |
|
20 |
|
21 spec.freq = GetDriverParamInt(parm, "hz", 11025); |
|
22 spec.format = AUDIO_S16SYS; |
|
23 spec.channels = 2; |
|
24 spec.samples = 512; |
|
25 spec.callback = fill_sound_buffer; |
|
26 SDL_CALL SDL_OpenAudio(&spec, &spec); |
|
27 SDL_CALL SDL_PauseAudio(0); |
|
28 return NULL; |
|
29 } |
|
30 |
|
31 static void SdlSoundStop(void) |
|
32 { |
|
33 SDL_CALL SDL_CloseAudio(); |
|
34 SdlClose(SDL_INIT_AUDIO); |
|
35 } |
|
36 |
|
37 const HalSoundDriver _sdl_sound_driver = { |
|
38 SdlSoundStart, |
|
39 SdlSoundStop, |
|
40 }; |
|