author | richk |
Tue, 17 Jun 2008 13:22:13 +0000 | |
branch | NewGRF_ports |
changeset 10994 | cd9968b6f96b |
parent 10724 | 68a692eacf22 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
6720
diff
changeset
|
3 |
/** @file sdl_s.cpp Playing sound via SDL. */ |
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
6720
diff
changeset
|
4 |
|
6450
1c2016673250
(svn r8860) -Cleanup: some style changes, proper #endif comments, variable initialisation, WINCE ifdef and a vsprintf to vsnprintf change.
Darkvater
parents:
6314
diff
changeset
|
5 |
#ifdef WITH_SDL |
1c2016673250
(svn r8860) -Cleanup: some style changes, proper #endif comments, variable initialisation, WINCE ifdef and a vsprintf to vsnprintf change.
Darkvater
parents:
6314
diff
changeset
|
6 |
|
2189
d240b9097139
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
7 |
#include "../stdafx.h" |
d240b9097139
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
8 |
|
d240b9097139
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
9 |
#include "../driver.h" |
d240b9097139
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
10 |
#include "../mixer.h" |
d240b9097139
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
11 |
#include "../sdl.h" |
d240b9097139
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
12 |
#include "sdl_s.h" |
0 | 13 |
#include <SDL.h> |
14 |
||
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6573
diff
changeset
|
15 |
static FSoundDriver_SDL iFSoundDriver_SDL; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6573
diff
changeset
|
16 |
|
0 | 17 |
static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len) |
18 |
{ |
|
2977 | 19 |
MxMixSamples(stream, len / 4); |
0 | 20 |
} |
21 |
||
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6573
diff
changeset
|
22 |
const char *SoundDriver_SDL::Start(const char * const *parm) |
0 | 23 |
{ |
24 |
SDL_AudioSpec spec; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
179
diff
changeset
|
25 |
|
1301
313804601383
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
26 |
const char *s = SdlOpen(SDL_INIT_AUDIO); |
423 | 27 |
if (s != NULL) return s; |
28 |
||
0 | 29 |
spec.freq = GetDriverParamInt(parm, "hz", 11025); |
30 |
spec.format = AUDIO_S16SYS; |
|
31 |
spec.channels = 2; |
|
32 |
spec.samples = 512; |
|
423 | 33 |
spec.callback = fill_sound_buffer; |
0 | 34 |
SDL_CALL SDL_OpenAudio(&spec, &spec); |
35 |
SDL_CALL SDL_PauseAudio(0); |
|
36 |
return NULL; |
|
37 |
} |
|
38 |
||
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6573
diff
changeset
|
39 |
void SoundDriver_SDL::Stop() |
0 | 40 |
{ |
41 |
SDL_CALL SDL_CloseAudio(); |
|
42 |
SdlClose(SDL_INIT_AUDIO); |
|
43 |
} |
|
44 |
||
6314
f738bcf05ad6
(svn r8691) -Cleanup: Some proper #endif comments for sound/music/video files, and a little elimination of magic numbers in Win32SoundStart
Darkvater
parents:
5835
diff
changeset
|
45 |
#endif /* WITH_SDL */ |