zenilib: zenilib/jni/external/sdl/SDL/SDL_audio.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_audio.h
Go to the documentation of this file.
1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21
28 #ifndef _SDL_audio_h
29 #define _SDL_audio_h
30
31 #include "SDL_stdinc.h"
32 #include "SDL_error.h"
33 #include "SDL_endian.h"
34 #include "SDL_mutex.h"
35 #include "SDL_thread.h"
36 #include "SDL_rwops.h"
37
38 #include "begin_code.h"
39 /* Set up for C function definitions, even when using C++ */
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
64 typedef Uint16 SDL_AudioFormat;
65
69 /* @{ */
70
71 #define SDL_AUDIO_MASK_BITSIZE (0xFF)
72 #define SDL_AUDIO_MASK_DATATYPE (1<<8)
73 #define SDL_AUDIO_MASK_ENDIAN (1<<12)
74 #define SDL_AUDIO_MASK_SIGNED (1<<15)
75 #define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE)
76 #define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE)
77 #define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN)
78 #define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED)
79 #define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x))
80 #define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x))
81 #define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x))
82
88 /* @{ */
89 #define AUDIO_U8 0x0008
90 #define AUDIO_S8 0x8008
91 #define AUDIO_U16LSB 0x0010
92 #define AUDIO_S16LSB 0x8010
93 #define AUDIO_U16MSB 0x1010
94 #define AUDIO_S16MSB 0x9010
95 #define AUDIO_U16 AUDIO_U16LSB
96 #define AUDIO_S16 AUDIO_S16LSB
97 /* @} */
98
102 /* @{ */
103 #define AUDIO_S32LSB 0x8020
104 #define AUDIO_S32MSB 0x9020
105 #define AUDIO_S32 AUDIO_S32LSB
106 /* @} */
107
111 /* @{ */
112 #define AUDIO_F32LSB 0x8120
113 #define AUDIO_F32MSB 0x9120
114 #define AUDIO_F32 AUDIO_F32LSB
115 /* @} */
116
120 /* @{ */
121 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
122 #define AUDIO_U16SYS AUDIO_U16LSB
123 #define AUDIO_S16SYS AUDIO_S16LSB
124 #define AUDIO_S32SYS AUDIO_S32LSB
125 #define AUDIO_F32SYS AUDIO_F32LSB
126 #else
127 #define AUDIO_U16SYS AUDIO_U16MSB
128 #define AUDIO_S16SYS AUDIO_S16MSB
129 #define AUDIO_S32SYS AUDIO_S32MSB
130 #define AUDIO_F32SYS AUDIO_F32MSB
131 #endif
132 /* @} */
133
139 /* @{ */
140 #define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001
141 #define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002
142 #define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004
143 #define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
144 /* @} */
145
146 /* @} *//* Audio flags */
147
159 typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
160 int len);
161
165 typedef struct SDL_AudioSpec
166 {
167 int freq;
168 SDL_AudioFormat format;
169 Uint8 channels;
170 Uint8 silence;
171 Uint16 samples;
172 Uint16 padding;
173 Uint32 size;
174 SDL_AudioCallback callback;
175 void *userdata;
176 } SDL_AudioSpec;
177
178
179 struct SDL_AudioCVT;
180 typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt,
181 SDL_AudioFormat format);
182
186 #ifdef __GNUC__
187 /* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't
188 pad it out to 88 bytes to guarantee ABI compatibility between compilers.
189 vvv
190 The next time we rev the ABI, make sure to size the ints and add padding.
191 */
192 #define SDL_AUDIOCVT_PACKED __attribute__((packed))
193 #else
194 #define SDL_AUDIOCVT_PACKED
195 #endif
196 /* */
197 typedef struct SDL_AudioCVT
198 {
199 int needed;
200 SDL_AudioFormat src_format;
201 SDL_AudioFormat dst_format;
202 double rate_incr;
203 Uint8 *buf;
204 int len;
205 int len_cvt;
206 int len_mult;
207 double len_ratio;
208 SDL_AudioFilter filters[10];
209 int filter_index;
210 } SDL_AUDIOCVT_PACKED SDL_AudioCVT;
211
212
213 /* Function prototypes */
214
221 /* @{ */
222 extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
223 extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
224 /* @} */
225
233 /* @{ */
234 extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
235 extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
236 /* @} */
237
242 extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
243
286 extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
287 SDL_AudioSpec * obtained);
288
298 typedef Uint32 SDL_AudioDeviceID;
299
312 extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
313
327 extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
328 int iscapture);
329
330
344 extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char
345 *device,
346 int iscapture,
347 const
348 SDL_AudioSpec *
349 desired,
350 SDL_AudioSpec *
351 obtained,
352 int
353 allowed_changes);
354
355
356
362 /* @{ */
363 typedef enum
364 {
365 SDL_AUDIO_STOPPED = 0,
366 SDL_AUDIO_PLAYING,
367 SDL_AUDIO_PAUSED
368 } SDL_AudioStatus;
369 extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
370
371 extern DECLSPEC SDL_AudioStatus SDLCALL
372 SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev);
373 /* @} *//* Audio State */
374
384 /* @{ */
385 extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
386 extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
387 int pause_on);
388 /* @} *//* Pause audio functions */
389
409 extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
410 int freesrc,
411 SDL_AudioSpec * spec,
412 Uint8 ** audio_buf,
413 Uint32 * audio_len);
414
419 #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
420 SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
421
425 extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf);
426
436 extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
437 SDL_AudioFormat src_format,
438 Uint8 src_channels,
439 int src_rate,
440 SDL_AudioFormat dst_format,
441 Uint8 dst_channels,
442 int dst_rate);
443
454 extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt);
455
456 #define SDL_MIX_MAXVOLUME 128
457
464 extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
465 Uint32 len, int volume);
466
472 extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
473 const Uint8 * src,
474 SDL_AudioFormat format,
475 Uint32 len, int volume);
476
485 /* @{ */
486 extern DECLSPEC void SDLCALL SDL_LockAudio(void);
487 extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
488 extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
489 extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
490 /* @} *//* Audio lock functions */
491
495 extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
496 extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
497
498 /* Ends C function definitions when using C++ */
499 #ifdef __cplusplus
500 }
501 #endif
502 #include "close_code.h"
503
504 #endif /* _SDL_audio_h */
505
506 /* vi: set ts=4 sw=4 expandtab: */
SDL_AUDIOCVT_PACKED
#define SDL_AUDIOCVT_PACKED
Definition: SDL_audio.h:194
SDL_CloseAudio
DECLSPEC void SDLCALL SDL_CloseAudio(void)
Definition: SDL_audio.c:1169
SDL_AudioSpec
struct SDL_AudioSpec SDL_AudioSpec
SDL_AudioCVT::len
int len
Definition: SDL_audio.h:204
void
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1824
SDL_AudioSpec::silence
Uint8 silence
Definition: SDL_audio.h:170
SDL_FreeWAV
DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf)
Definition: SDL_wave.c:601
SDL_AudioCVT::buf
Uint8 * buf
Definition: SDL_audio.h:203
SDL_RWops
Definition: SDL_rwops.h:52
stream
GLuint GLuint stream
Definition: glew.h:6573
SDL_AudioCVT::filter_index
int filter_index
Definition: SDL_audio.h:209
SDL_AudioCVT::len_ratio
double len_ratio
Definition: SDL_audio.h:207
SDL_AudioStatus
SDL_AudioStatus
Definition: SDL_audio.h:363
SDL_UnlockAudio
DECLSPEC void SDLCALL SDL_UnlockAudio(void)
Definition: SDL_audio.c:1153
SDL_AudioSpec
Definition: SDL_audio.h:165
SDL_PauseAudioDevice
DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on)
Definition: SDL_audio.c:1109
SDL_AudioSpec::samples
Uint16 samples
Definition: SDL_audio.h:171
DECLSPEC
#define DECLSPEC
Definition: begin_code.h:62
SDL_AUDIO_PAUSED
Definition: SDL_audio.h:367
SDL_AudioFormat
Uint16 SDL_AudioFormat
Audio format flags.
Definition: SDL_audio.h:64
len
GLenum GLsizei len
Definition: glew.h:7035
SDL_AudioCVT::len_mult
int len_mult
Definition: SDL_audio.h:206
SDL_GetNumAudioDrivers
DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void)
Definition: SDL_audio.c:547
SDLCALL
#define SDLCALL
Definition: begin_code.h:72
begin_code.h
SDL_LockAudio
DECLSPEC void SDLCALL SDL_LockAudio(void)
Definition: SDL_audio.c:1137
SDL_AudioCVT
Definition: SDL_audio.h:197
SDL_GetAudioDeviceStatus
DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev)
Definition: SDL_audio.c:1087
SDL_BuildAudioCVT
DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_AudioFormat src_format, Uint8 src_channels, int src_rate, SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate)
Definition: SDL_audiocvt.c:958
Uint32
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:145
SDL_GetAudioDeviceName
DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, int iscapture)
Definition: SDL_audio.c:708
SDL_AudioSpec::freq
int freq
Definition: SDL_audio.h:167
SDL_mutex.h
dst
GLenum GLenum dst
Definition: glew.h:2396
SDL_GetCurrentAudioDriver
DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void)
Definition: SDL_audio.c:618
close_code.h
SDL_AudioCVT::filters
SDL_AudioFilter filters[10]
Definition: SDL_audio.h:208
SDL_AudioSpec::channels
Uint8 channels
Definition: SDL_audio.h:169
SDL_LockAudioDevice
DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev)
Definition: SDL_audio.c:1127
SDL_GetAudioDriver
DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index)
Definition: SDL_audio.c:553
SDL_GetAudioStatus
DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void)
Definition: SDL_audio.c:1103
SDL_stdinc.h
format
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl2ext.h:845
SDL_AUDIO_STOPPED
Definition: SDL_audio.h:365
index
GLuint index
Definition: glew.h:1800
SDL_AudioCVT::needed
int needed
Definition: SDL_audio.h:199
SDL_AudioCVT
struct SDL_AudioCVT SDL_AudioCVT
SDL_PauseAudio
DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on)
Definition: SDL_audio.c:1120
SDL_AudioSpec::callback
SDL_AudioCallback callback
Definition: SDL_audio.h:174
SDL_AudioCVT::src_format
SDL_AudioFormat src_format
Definition: SDL_audio.h:200
SDL_GetNumAudioDevices
DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture)
Definition: SDL_audio.c:671
SDL_UnlockAudioDevice
DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev)
Definition: SDL_audio.c:1143
SDL_endian.h
SDL_AudioDeviceID
Uint32 SDL_AudioDeviceID
Definition: SDL_audio.h:298
SDL_AudioSpec::padding
Uint16 padding
Definition: SDL_audio.h:172
SDL_AudioSpec::size
Uint32 size
Definition: SDL_audio.h:173
SDL_OpenAudioDevice
DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char *device, int iscapture, const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, int allowed_changes)
Definition: SDL_audio.c:1078
SDL_AudioCVT::len_cvt
int len_cvt
Definition: SDL_audio.h:205
SDL_MixAudioFormat
DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, Uint32 len, int volume)
Definition: SDL_mixer.c:90
SDL_thread.h
SDL_AudioCVT::dst_format
SDL_AudioFormat dst_format
Definition: SDL_audio.h:201
SDL_rwops.h
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:129
SDL_AudioSpec::format
SDL_AudioFormat format
Definition: SDL_audio.h:168
SDL_AudioCVT::rate_incr
double rate_incr
Definition: SDL_audio.h:202
SDL_CloseAudioDevice
DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev)
Definition: SDL_audio.c:1159
SDL_LoadWAV_RW
DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
Definition: SDL_wave.c:405
SDL_AudioInit
DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name)
Definition: SDL_audio.c:562
SDL_AudioSpec::userdata
void * userdata
Definition: SDL_audio.h:175
Uint16
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:137
src
GLenum src
Definition: glew.h:2396
SDL_AUDIO_PLAYING
Definition: SDL_audio.h:366
SDL_MixAudio
DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
Definition: SDL_audio.c:1268
SDL_AudioQuit
DECLSPEC void SDLCALL SDL_AudioQuit(void)
Definition: SDL_audio.c:1175
SDL_error.h
SDL_ConvertAudio
DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt)
Definition: SDL_audiocvt.c:774
SDL_OpenAudio
DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
Definition: SDL_audio.c:1049