author | glx |
Mon, 26 May 2008 17:40:33 +0000 | |
branch | noai |
changeset 10718 | 7e9d9e40e16f |
parent 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9631
diff
changeset
|
3 |
/** @file sdl_s.cpp Playing sound via SDL. */ |
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9631
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 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
6573
diff
changeset
|
15 |
static FSoundDriver_SDL iFSoundDriver_SDL; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
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 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
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 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
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 */ |