author | tron |
Sat, 23 Jul 2005 15:34:05 +0000 | |
changeset 2173 | dabe358aec40 |
parent 2171 | 008122046f7f |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1881
diff
changeset
|
2 |
#include "openttd.h" |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
2169
diff
changeset
|
3 |
#include "driver.h" |
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1474
diff
changeset
|
4 |
#include "mixer.h" |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
2169
diff
changeset
|
5 |
#include "sdl.h" |
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
2169
diff
changeset
|
6 |
#include "sound/sdl.h" |
0 | 7 |
#include <SDL.h> |
8 |
||
9 |
static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len) |
|
10 |
{ |
|
423 | 11 |
MxMixSamples(_mixer, stream, len / 4); |
0 | 12 |
} |
13 |
||
1301
313804601383
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
14 |
static const char *SdlSoundStart(const char * const *parm) |
0 | 15 |
{ |
16 |
SDL_AudioSpec spec; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
17 |
|
1301
313804601383
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
18 |
const char *s = SdlOpen(SDL_INIT_AUDIO); |
423 | 19 |
if (s != NULL) return s; |
20 |
||
0 | 21 |
spec.freq = GetDriverParamInt(parm, "hz", 11025); |
22 |
spec.format = AUDIO_S16SYS; |
|
23 |
spec.channels = 2; |
|
24 |
spec.samples = 512; |
|
423 | 25 |
spec.callback = fill_sound_buffer; |
0 | 26 |
SDL_CALL SDL_OpenAudio(&spec, &spec); |
27 |
SDL_CALL SDL_PauseAudio(0); |
|
28 |
return NULL; |
|
29 |
} |
|
30 |
||
423 | 31 |
static void SdlSoundStop(void) |
0 | 32 |
{ |
33 |
SDL_CALL SDL_CloseAudio(); |
|
34 |
SdlClose(SDL_INIT_AUDIO); |
|
35 |
} |
|
36 |
||
37 |
const HalSoundDriver _sdl_sound_driver = { |
|
38 |
SdlSoundStart, |
|
39 |
SdlSoundStop, |
|
40 |
}; |