Mercurial > sdl-ios-xcode
comparison include/SDL_audio.h @ 337:9154ec9ca3d2
Explicitly specify the SDL API calling convention (C by default)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 11 Apr 2002 14:35:16 +0000 |
parents | f6ffac90895c |
children | b8d311d90021 |
comparison
equal
deleted
inserted
replaced
336:745873ea091f | 337:9154ec9ca3d2 |
---|---|
103 | 103 |
104 /* These functions are used internally, and should not be used unless you | 104 /* These functions are used internally, and should not be used unless you |
105 * have a specific need to specify the audio driver you want to use. | 105 * have a specific need to specify the audio driver you want to use. |
106 * You should normally use SDL_Init() or SDL_InitSubSystem(). | 106 * You should normally use SDL_Init() or SDL_InitSubSystem(). |
107 */ | 107 */ |
108 extern DECLSPEC int SDL_AudioInit(const char *driver_name); | 108 extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); |
109 extern DECLSPEC void SDL_AudioQuit(void); | 109 extern DECLSPEC void SDLCALL SDL_AudioQuit(void); |
110 | 110 |
111 /* This function fills the given character buffer with the name of the | 111 /* This function fills the given character buffer with the name of the |
112 * current audio driver, and returns a pointer to it if the audio driver has | 112 * current audio driver, and returns a pointer to it if the audio driver has |
113 * been initialized. It returns NULL if no driver has been initialized. | 113 * been initialized. It returns NULL if no driver has been initialized. |
114 */ | 114 */ |
115 extern DECLSPEC char *SDL_AudioDriverName(char *namebuf, int maxlen); | 115 extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); |
116 | 116 |
117 /* | 117 /* |
118 * This function opens the audio device with the desired parameters, and | 118 * This function opens the audio device with the desired parameters, and |
119 * returns 0 if successful, placing the actual hardware parameters in the | 119 * returns 0 if successful, placing the actual hardware parameters in the |
120 * structure pointed to by 'obtained'. If 'obtained' is NULL, the audio | 120 * structure pointed to by 'obtained'. If 'obtained' is NULL, the audio |
153 * be enabled for playing by calling SDL_PauseAudio(0) when you are ready | 153 * be enabled for playing by calling SDL_PauseAudio(0) when you are ready |
154 * for your audio callback function to be called. Since the audio driver | 154 * for your audio callback function to be called. Since the audio driver |
155 * may modify the requested size of the audio buffer, you should allocate | 155 * may modify the requested size of the audio buffer, you should allocate |
156 * any local mixing buffers after you open the audio device. | 156 * any local mixing buffers after you open the audio device. |
157 */ | 157 */ |
158 extern DECLSPEC int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained); | 158 extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained); |
159 | 159 |
160 /* | 160 /* |
161 * Get the current audio state: | 161 * Get the current audio state: |
162 */ | 162 */ |
163 typedef enum { | 163 typedef enum { |
164 SDL_AUDIO_STOPPED = 0, | 164 SDL_AUDIO_STOPPED = 0, |
165 SDL_AUDIO_PLAYING, | 165 SDL_AUDIO_PLAYING, |
166 SDL_AUDIO_PAUSED | 166 SDL_AUDIO_PAUSED |
167 } SDL_audiostatus; | 167 } SDL_audiostatus; |
168 extern DECLSPEC SDL_audiostatus SDL_GetAudioStatus(void); | 168 extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void); |
169 | 169 |
170 /* | 170 /* |
171 * This function pauses and unpauses the audio callback processing. | 171 * This function pauses and unpauses the audio callback processing. |
172 * It should be called with a parameter of 0 after opening the audio | 172 * It should be called with a parameter of 0 after opening the audio |
173 * device to start playing sound. This is so you can safely initialize | 173 * device to start playing sound. This is so you can safely initialize |
174 * data for your callback function after opening the audio device. | 174 * data for your callback function after opening the audio device. |
175 * Silence will be written to the audio device during the pause. | 175 * Silence will be written to the audio device during the pause. |
176 */ | 176 */ |
177 extern DECLSPEC void SDL_PauseAudio(int pause_on); | 177 extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); |
178 | 178 |
179 /* | 179 /* |
180 * This function loads a WAVE from the data source, automatically freeing | 180 * This function loads a WAVE from the data source, automatically freeing |
181 * that source if 'freesrc' is non-zero. For example, to load a WAVE file, | 181 * that source if 'freesrc' is non-zero. For example, to load a WAVE file, |
182 * you could do: | 182 * you could do: |
191 * | 191 * |
192 * This function returns NULL and sets the SDL error message if the | 192 * This function returns NULL and sets the SDL error message if the |
193 * wave file cannot be opened, uses an unknown data format, or is | 193 * wave file cannot be opened, uses an unknown data format, or is |
194 * corrupt. Currently raw and MS-ADPCM WAVE files are supported. | 194 * corrupt. Currently raw and MS-ADPCM WAVE files are supported. |
195 */ | 195 */ |
196 extern DECLSPEC SDL_AudioSpec *SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, | 196 extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); |
197 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); | |
198 | 197 |
199 /* Compatibility convenience function -- loads a WAV from a file */ | 198 /* Compatibility convenience function -- loads a WAV from a file */ |
200 #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ | 199 #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ |
201 SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) | 200 SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) |
202 | 201 |
203 /* | 202 /* |
204 * This function frees data previously allocated with SDL_LoadWAV_RW() | 203 * This function frees data previously allocated with SDL_LoadWAV_RW() |
205 */ | 204 */ |
206 extern DECLSPEC void SDL_FreeWAV(Uint8 *audio_buf); | 205 extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf); |
207 | 206 |
208 /* | 207 /* |
209 * This function takes a source format and rate and a destination format | 208 * This function takes a source format and rate and a destination format |
210 * and rate, and initializes the 'cvt' structure with information needed | 209 * and rate, and initializes the 'cvt' structure with information needed |
211 * by SDL_ConvertAudio() to convert a buffer of audio data from one format | 210 * by SDL_ConvertAudio() to convert a buffer of audio data from one format |
212 * to the other. | 211 * to the other. |
213 * This function returns 0, or -1 if there was an error. | 212 * This function returns 0, or -1 if there was an error. |
214 */ | 213 */ |
215 extern DECLSPEC int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, | 214 extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, |
216 Uint16 src_format, Uint8 src_channels, int src_rate, | 215 Uint16 src_format, Uint8 src_channels, int src_rate, |
217 Uint16 dst_format, Uint8 dst_channels, int dst_rate); | 216 Uint16 dst_format, Uint8 dst_channels, int dst_rate); |
218 | 217 |
219 /* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), | 218 /* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), |
220 * created an audio buffer cvt->buf, and filled it with cvt->len bytes of | 219 * created an audio buffer cvt->buf, and filled it with cvt->len bytes of |
222 * to the desired format. | 221 * to the desired format. |
223 * The data conversion may expand the size of the audio data, so the buffer | 222 * The data conversion may expand the size of the audio data, so the buffer |
224 * cvt->buf should be allocated after the cvt structure is initialized by | 223 * cvt->buf should be allocated after the cvt structure is initialized by |
225 * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. | 224 * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. |
226 */ | 225 */ |
227 extern DECLSPEC int SDL_ConvertAudio(SDL_AudioCVT *cvt); | 226 extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt); |
228 | 227 |
229 /* | 228 /* |
230 * This takes two audio buffers of the playing audio format and mixes | 229 * This takes two audio buffers of the playing audio format and mixes |
231 * them, performing addition, volume adjustment, and overflow clipping. | 230 * them, performing addition, volume adjustment, and overflow clipping. |
232 * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME | 231 * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME |
233 * for full audio volume. Note this does not change hardware volume. | 232 * for full audio volume. Note this does not change hardware volume. |
234 * This is provided for convenience -- you can mix your own audio data. | 233 * This is provided for convenience -- you can mix your own audio data. |
235 */ | 234 */ |
236 #define SDL_MIX_MAXVOLUME 128 | 235 #define SDL_MIX_MAXVOLUME 128 |
237 extern DECLSPEC void SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); | 236 extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); |
238 | 237 |
239 /* | 238 /* |
240 * The lock manipulated by these functions protects the callback function. | 239 * The lock manipulated by these functions protects the callback function. |
241 * During a LockAudio/UnlockAudio pair, you can be guaranteed that the | 240 * During a LockAudio/UnlockAudio pair, you can be guaranteed that the |
242 * callback function is not running. Do not call these from the callback | 241 * callback function is not running. Do not call these from the callback |
243 * function or you will cause deadlock. | 242 * function or you will cause deadlock. |
244 */ | 243 */ |
245 extern DECLSPEC void SDL_LockAudio(void); | 244 extern DECLSPEC void SDLCALL SDL_LockAudio(void); |
246 extern DECLSPEC void SDL_UnlockAudio(void); | 245 extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); |
247 | 246 |
248 /* | 247 /* |
249 * This function shuts down audio processing and closes the audio device. | 248 * This function shuts down audio processing and closes the audio device. |
250 */ | 249 */ |
251 extern DECLSPEC void SDL_CloseAudio(void); | 250 extern DECLSPEC void SDLCALL SDL_CloseAudio(void); |
252 | 251 |
253 | 252 |
254 /* Ends C function definitions when using C++ */ | 253 /* Ends C function definitions when using C++ */ |
255 #ifdef __cplusplus | 254 #ifdef __cplusplus |
256 } | 255 } |