SDL 3.0
SDL_audio.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2023 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
22/* !!! FIXME: several functions in here need Doxygen comments. */
23
24/**
25 * \file SDL_audio.h
26 *
27 * Access to the raw audio mixing buffer for the SDL library.
28 */
29
30#ifndef SDL_audio_h_
31#define SDL_audio_h_
32
33#include <SDL3/SDL_stdinc.h>
34#include <SDL3/SDL_error.h>
35#include <SDL3/SDL_endian.h>
36#include <SDL3/SDL_mutex.h>
37#include <SDL3/SDL_thread.h>
38#include <SDL3/SDL_rwops.h>
39
40#include <SDL3/SDL_begin_code.h>
41/* Set up for C function definitions, even when using C++ */
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/**
47 * \brief Audio format flags.
48 *
49 * These are what the 16 bits in SDL_AudioFormat currently mean...
50 * (Unspecified bits are always zero).
51 *
52 * \verbatim
53 ++-----------------------sample is signed if set
54 ||
55 || ++-----------sample is bigendian if set
56 || ||
57 || || ++---sample is float if set
58 || || ||
59 || || || +---sample bit size---+
60 || || || | |
61 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
62 \endverbatim
63 *
64 * There are macros in SDL 2.0 and later to query these bits.
65 */
67
68/**
69 * \name Audio flags
70 */
71/* @{ */
72
73#define SDL_AUDIO_MASK_BITSIZE (0xFF)
74#define SDL_AUDIO_MASK_DATATYPE (1<<8)
75#define SDL_AUDIO_MASK_ENDIAN (1<<12)
76#define SDL_AUDIO_MASK_SIGNED (1<<15)
77#define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE)
78#define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE)
79#define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN)
80#define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED)
81#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x))
82#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x))
83#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x))
84
85/**
86 * \name Audio format flags
87 *
88 * Defaults to LSB byte order.
89 */
90/* @{ */
91#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */
92#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */
93#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */
94#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */
95#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */
96#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */
97#define AUDIO_U16 AUDIO_U16LSB
98#define AUDIO_S16 AUDIO_S16LSB
99/* @} */
100
101/**
102 * \name int32 support
103 */
104/* @{ */
105#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */
106#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */
107#define AUDIO_S32 AUDIO_S32LSB
108/* @} */
109
110/**
111 * \name float32 support
112 */
113/* @{ */
114#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */
115#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */
116#define AUDIO_F32 AUDIO_F32LSB
117/* @} */
118
119/**
120 * \name Native audio byte ordering
121 */
122/* @{ */
123#if SDL_BYTEORDER == SDL_LIL_ENDIAN
124#define AUDIO_U16SYS AUDIO_U16LSB
125#define AUDIO_S16SYS AUDIO_S16LSB
126#define AUDIO_S32SYS AUDIO_S32LSB
127#define AUDIO_F32SYS AUDIO_F32LSB
128#else
129#define AUDIO_U16SYS AUDIO_U16MSB
130#define AUDIO_S16SYS AUDIO_S16MSB
131#define AUDIO_S32SYS AUDIO_S32MSB
132#define AUDIO_F32SYS AUDIO_F32MSB
133#endif
134/* @} */
135
136/**
137 * \name Allow change flags
138 *
139 * Which audio format changes are allowed when opening a device.
140 */
141/* @{ */
142#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001
143#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002
144#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004
145#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE 0x00000008
146#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE)
147/* @} */
148
149/* @} *//* Audio flags */
150
151/**
152 * This function is called when the audio device needs more data.
153 *
154 * \param userdata An application-specific parameter saved in
155 * the SDL_AudioSpec structure
156 * \param stream A pointer to the audio data buffer.
157 * \param len The length of that buffer in bytes.
158 *
159 * Once the callback returns, the buffer will no longer be valid.
160 * Stereo samples are stored in a LRLRLR ordering.
161 *
162 * You can choose to avoid callbacks and use SDL_QueueAudio() instead, if
163 * you like. Just open your audio device with a NULL callback.
164 */
165typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
166 int len);
167
168/**
169 * The calculated values in this structure are calculated by SDL_OpenAudioDevice().
170 *
171 * For multi-channel audio, the default SDL channel mapping is:
172 * 2: FL FR (stereo)
173 * 3: FL FR LFE (2.1 surround)
174 * 4: FL FR BL BR (quad)
175 * 5: FL FR LFE BL BR (4.1 surround)
176 * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
177 * 7: FL FR FC LFE BC SL SR (6.1 surround)
178 * 8: FL FR FC LFE BL BR SL SR (7.1 surround)
179 */
180typedef struct SDL_AudioSpec
181{
182 int freq; /**< DSP frequency -- samples per second */
183 SDL_AudioFormat format; /**< Audio data format */
184 Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */
185 Uint8 silence; /**< Audio buffer silence value (calculated) */
186 Uint16 samples; /**< Audio buffer size in sample FRAMES (total samples divided by channel count) */
187 Uint16 padding; /**< Necessary for some compile environments */
188 Uint32 size; /**< Audio buffer size in bytes (calculated) */
189 SDL_AudioCallback callback; /**< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). */
190 void *userdata; /**< Userdata passed to callback (ignored for NULL callbacks). */
192
193
194/* Function prototypes */
195
196/**
197 * \name Driver discovery functions
198 *
199 * These functions return the list of built in audio drivers, in the
200 * order that they are normally initialized by default.
201 */
202/* @{ */
203
204/**
205 * Use this function to get the number of built-in audio drivers.
206 *
207 * This function returns a hardcoded number. This never returns a negative
208 * value; if there are no drivers compiled into this build of SDL, this
209 * function returns zero. The presence of a driver in this list does not mean
210 * it will function, it just means SDL is capable of interacting with that
211 * interface. For example, a build of SDL might have esound support, but if
212 * there's no esound server available, SDL's esound driver would fail if used.
213 *
214 * By default, SDL tries all drivers, in its preferred order, until one is
215 * found to be usable.
216 *
217 * \returns the number of built-in audio drivers.
218 *
219 * \since This function is available since SDL 3.0.0.
220 *
221 * \sa SDL_GetAudioDriver
222 */
223extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
224
225/**
226 * Use this function to get the name of a built in audio driver.
227 *
228 * The list of audio drivers is given in the order that they are normally
229 * initialized by default; the drivers that seem more reasonable to choose
230 * first (as far as the SDL developers believe) are earlier in the list.
231 *
232 * The names of drivers are all simple, low-ASCII identifiers, like "alsa",
233 * "coreaudio" or "xaudio2". These never have Unicode characters, and are not
234 * meant to be proper names.
235 *
236 * \param index the index of the audio driver; the value ranges from 0 to
237 * SDL_GetNumAudioDrivers() - 1
238 * \returns the name of the audio driver at the requested index, or NULL if an
239 * invalid index was specified.
240 *
241 * \since This function is available since SDL 3.0.0.
242 *
243 * \sa SDL_GetNumAudioDrivers
244 */
245extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
246/* @} */
247
248/**
249 * Get the name of the current audio driver.
250 *
251 * The returned string points to internal static memory and thus never becomes
252 * invalid, even if you quit the audio subsystem and initialize a new driver
253 * (although such a case would return a different static string from another
254 * call to this function, of course). As such, you should not modify or free
255 * the returned string.
256 *
257 * \returns the name of the current audio driver or NULL if no driver has been
258 * initialized.
259 *
260 * \since This function is available since SDL 3.0.0.
261 */
262extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
263
264/**
265 * SDL Audio Device IDs.
266 */
268
269/**
270 * Get the number of built-in audio devices.
271 *
272 * This function is only valid after successfully initializing the audio
273 * subsystem.
274 *
275 * Note that audio capture support is not implemented as of SDL 2.0.4, so the
276 * `iscapture` parameter is for future expansion and should always be zero for
277 * now.
278 *
279 * This function will return -1 if an explicit list of devices can't be
280 * determined. Returning -1 is not an error. For example, if SDL is set up to
281 * talk to a remote audio server, it can't list every one available on the
282 * Internet, but it will still allow a specific host to be specified in
283 * SDL_OpenAudioDevice().
284 *
285 * In many common cases, when this function returns a value <= 0, it can still
286 * successfully open the default device (NULL for first argument of
287 * SDL_OpenAudioDevice()).
288 *
289 * This function may trigger a complete redetect of available hardware. It
290 * should not be called for each iteration of a loop, but rather once at the
291 * start of a loop:
292 *
293 * ```c
294 * // Don't do this:
295 * for (int i = 0; i < SDL_GetNumAudioDevices(0); i++)
296 *
297 * // do this instead:
298 * const int count = SDL_GetNumAudioDevices(0);
299 * for (int i = 0; i < count; ++i) { do_something_here(); }
300 * ```
301 *
302 * \param iscapture zero to request playback devices, non-zero to request
303 * recording devices
304 * \returns the number of available devices exposed by the current driver or
305 * -1 if an explicit list of devices can't be determined. A return
306 * value of -1 does not necessarily mean an error condition.
307 *
308 * \since This function is available since SDL 3.0.0.
309 *
310 * \sa SDL_GetAudioDeviceName
311 * \sa SDL_OpenAudioDevice
312 */
313extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
314
315/**
316 * Get the human-readable name of a specific audio device.
317 *
318 * This function is only valid after successfully initializing the audio
319 * subsystem. The values returned by this function reflect the latest call to
320 * SDL_GetNumAudioDevices(); re-call that function to redetect available
321 * hardware.
322 *
323 * The string returned by this function is UTF-8 encoded, read-only, and
324 * managed internally. You are not to free it. If you need to keep the string
325 * for any length of time, you should make your own copy of it, as it will be
326 * invalid next time any of several other SDL functions are called.
327 *
328 * \param index the index of the audio device; valid values range from 0 to
329 * SDL_GetNumAudioDevices() - 1
330 * \param iscapture non-zero to query the list of recording devices, zero to
331 * query the list of output devices.
332 * \returns the name of the audio device at the requested index, or NULL on
333 * error.
334 *
335 * \since This function is available since SDL 3.0.0.
336 *
337 * \sa SDL_GetNumAudioDevices
338 * \sa SDL_GetDefaultAudioInfo
339 */
340extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
341 int iscapture);
342
343/**
344 * Get the preferred audio format of a specific audio device.
345 *
346 * This function is only valid after a successfully initializing the audio
347 * subsystem. The values returned by this function reflect the latest call to
348 * SDL_GetNumAudioDevices(); re-call that function to redetect available
349 * hardware.
350 *
351 * `spec` will be filled with the sample rate, sample format, and channel
352 * count.
353 *
354 * \param index the index of the audio device; valid values range from 0 to
355 * SDL_GetNumAudioDevices() - 1
356 * \param iscapture non-zero to query the list of recording devices, zero to
357 * query the list of output devices.
358 * \param spec The SDL_AudioSpec to be initialized by this function.
359 * \returns 0 on success, nonzero on error
360 *
361 * \since This function is available since SDL 3.0.0.
362 *
363 * \sa SDL_GetNumAudioDevices
364 * \sa SDL_GetDefaultAudioInfo
365 */
366extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
367 int iscapture,
368 SDL_AudioSpec *spec);
369
370
371/**
372 * Get the name and preferred format of the default audio device.
373 *
374 * Some (but not all!) platforms have an isolated mechanism to get information
375 * about the "default" device. This can actually be a completely different
376 * device that's not in the list you get from SDL_GetAudioDeviceSpec(). It can
377 * even be a network address! (This is discussed in SDL_OpenAudioDevice().)
378 *
379 * As a result, this call is not guaranteed to be performant, as it can query
380 * the sound server directly every time, unlike the other query functions. You
381 * should call this function sparingly!
382 *
383 * `spec` will be filled with the sample rate, sample format, and channel
384 * count, if a default device exists on the system. If `name` is provided,
385 * will be filled with either a dynamically-allocated UTF-8 string or NULL.
386 *
387 * \param name A pointer to be filled with the name of the default device (can
388 * be NULL). Please call SDL_free() when you are done with this
389 * pointer!
390 * \param spec The SDL_AudioSpec to be initialized by this function.
391 * \param iscapture non-zero to query the default recording device, zero to
392 * query the default output device.
393 * \returns 0 on success, nonzero on error
394 *
395 * \since This function is available since SDL 3.0.0.
396 *
397 * \sa SDL_GetAudioDeviceName
398 * \sa SDL_GetAudioDeviceSpec
399 * \sa SDL_OpenAudioDevice
400 */
401extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
402 SDL_AudioSpec *spec,
403 int iscapture);
404
405
406/**
407 * Open a specific audio device.
408 *
409 * Passing in a `device` name of NULL requests the most reasonable default.
410 * The `device` name is a UTF-8 string reported by SDL_GetAudioDeviceName(),
411 * but some drivers allow arbitrary and driver-specific strings, such as a
412 * hostname/IP address for a remote audio server, or a filename in the
413 * diskaudio driver.
414 *
415 * An opened audio device starts out paused, and should be enabled for playing
416 * by calling SDL_PlayAudioDevice(devid) when you are ready for your audio
417 * callback function to be called. Since the audio driver may modify the
418 * requested size of the audio buffer, you should allocate any local mixing
419 * buffers after you open the audio device.
420 *
421 * The audio callback runs in a separate thread in most cases; you can prevent
422 * race conditions between your callback and other threads without fully
423 * pausing playback with SDL_LockAudioDevice(). For more information about the
424 * callback, see SDL_AudioSpec.
425 *
426 * Managing the audio spec via 'desired' and 'obtained':
427 *
428 * When filling in the desired audio spec structure:
429 *
430 * - `desired->freq` should be the frequency in sample-frames-per-second (Hz).
431 * - `desired->format` should be the audio format (`AUDIO_S16SYS`, etc).
432 * - `desired->samples` is the desired size of the audio buffer, in _sample
433 * frames_ (with stereo output, two samples--left and right--would make a
434 * single sample frame). This number should be a power of two, and may be
435 * adjusted by the audio driver to a value more suitable for the hardware.
436 * Good values seem to range between 512 and 8096 inclusive, depending on
437 * the application and CPU speed. Smaller values reduce latency, but can
438 * lead to underflow if the application is doing heavy processing and cannot
439 * fill the audio buffer in time. Note that the number of sample frames is
440 * directly related to time by the following formula: `ms =
441 * (sampleframes*1000)/freq`
442 * - `desired->size` is the size in _bytes_ of the audio buffer, and is
443 * calculated by SDL_OpenAudioDevice(). You don't initialize this.
444 * - `desired->silence` is the value used to set the buffer to silence, and is
445 * calculated by SDL_OpenAudioDevice(). You don't initialize this.
446 * - `desired->callback` should be set to a function that will be called when
447 * the audio device is ready for more data. It is passed a pointer to the
448 * audio buffer, and the length in bytes of the audio buffer. This function
449 * usually runs in a separate thread, and so you should protect data
450 * structures that it accesses by calling SDL_LockAudioDevice() and
451 * SDL_UnlockAudioDevice() in your code. Alternately, you may pass a NULL
452 * pointer here, and call SDL_QueueAudio() with some frequency, to queue
453 * more audio samples to be played (or for capture devices, call
454 * SDL_DequeueAudio() with some frequency, to obtain audio samples).
455 * - `desired->userdata` is passed as the first parameter to your callback
456 * function. If you passed a NULL callback, this value is ignored.
457 *
458 * `allowed_changes` can have the following flags OR'd together:
459 *
460 * - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE`
461 * - `SDL_AUDIO_ALLOW_FORMAT_CHANGE`
462 * - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE`
463 * - `SDL_AUDIO_ALLOW_SAMPLES_CHANGE`
464 * - `SDL_AUDIO_ALLOW_ANY_CHANGE`
465 *
466 * These flags specify how SDL should behave when a device cannot offer a
467 * specific feature. If the application requests a feature that the hardware
468 * doesn't offer, SDL will always try to get the closest equivalent.
469 *
470 * For example, if you ask for float32 audio format, but the sound card only
471 * supports int16, SDL will set the hardware to int16. If you had set
472 * SDL_AUDIO_ALLOW_FORMAT_CHANGE, SDL will change the format in the `obtained`
473 * structure. If that flag was *not* set, SDL will prepare to convert your
474 * callback's float32 audio to int16 before feeding it to the hardware and
475 * will keep the originally requested format in the `obtained` structure.
476 *
477 * The resulting audio specs, varying depending on hardware and on what
478 * changes were allowed, will then be written back to `obtained`.
479 *
480 * If your application can only handle one specific data format, pass a zero
481 * for `allowed_changes` and let SDL transparently handle any differences.
482 *
483 * \param device a UTF-8 string reported by SDL_GetAudioDeviceName() or a
484 * driver-specific name as appropriate. NULL requests the most
485 * reasonable default device.
486 * \param iscapture non-zero to specify a device should be opened for
487 * recording, not playback
488 * \param desired an SDL_AudioSpec structure representing the desired output
489 * format
490 * \param obtained an SDL_AudioSpec structure filled in with the actual output
491 * format
492 * \param allowed_changes 0, or one or more flags OR'd together
493 * \returns a valid device ID that is > 0 on success or 0 on failure; call
494 * SDL_GetError() for more information.
495 *
496 * For compatibility with SDL 1.2, this will never return 1, since
497 * SDL reserves that ID for the legacy SDL_OpenAudio() function.
498 *
499 * \since This function is available since SDL 3.0.0.
500 *
501 * \sa SDL_CloseAudioDevice
502 * \sa SDL_GetAudioDeviceName
503 * \sa SDL_LockAudioDevice
504 * \sa SDL_PlayAudioDevice
505 * \sa SDL_PauseAudioDevice
506 * \sa SDL_UnlockAudioDevice
507 */
509 const char *device,
510 int iscapture,
511 const SDL_AudioSpec *desired,
512 SDL_AudioSpec *obtained,
513 int allowed_changes);
514
515
516
517/**
518 * \name Audio state
519 *
520 * Get the current audio state.
521 */
522/* @{ */
523typedef enum
524{
529
530/**
531 * Use this function to get the current audio state of an audio device.
532 *
533 * \param dev the ID of an audio device previously opened with
534 * SDL_OpenAudioDevice()
535 * \returns the SDL_AudioStatus of the specified audio device.
536 *
537 * \since This function is available since SDL 3.0.0.
538 *
539 * \sa SDL_PlayAudioDevice
540 * \sa SDL_PauseAudioDevice
541 */
543/* @} *//* Audio State */
544
545/**
546 * Use this function to play audio on a specified device.
547 *
548 * Newly-opened audio devices start in the paused state, so you must call this
549 * function after opening the specified audio device to start playing sound.
550 * This allows you to safely initialize data for your callback function after
551 * opening the audio device. Silence will be written to the audio device while
552 * paused, and the audio callback is guaranteed to not be called. Pausing one
553 * device does not prevent other unpaused devices from running their
554 * callbacks.
555 *
556 * \param dev a device opened by SDL_OpenAudioDevice()
557 *
558 * \since This function is available since SDL 3.0.0.
559 *
560 * \sa SDL_LockAudioDevice
561 * \sa SDL_PauseAudioDevice
562 */
563extern DECLSPEC void SDLCALL SDL_PlayAudioDevice(SDL_AudioDeviceID dev);
564
565
566
567/**
568 * Use this function to pause audio playback on a specified device.
569 *
570 * This function pauses the audio callback processing for a given device.
571 * Silence will be written to the audio device while paused, and the audio
572 * callback is guaranteed to not be called. Pausing one device does not
573 * prevent other unpaused devices from running their callbacks.
574 *
575 * If you just need to protect a few variables from race conditions vs your
576 * callback, you shouldn't pause the audio device, as it will lead to dropouts
577 * in the audio playback. Instead, you should use SDL_LockAudioDevice().
578 *
579 * \param dev a device opened by SDL_OpenAudioDevice()
580 *
581 * \since This function is available since SDL 3.0.0.
582 *
583 * \sa SDL_LockAudioDevice
584 * \sa SDL_PlayAudioDevice
585 */
586extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev);
587
588
589/**
590 * Load the audio data of a WAVE file into memory.
591 *
592 * Loading a WAVE file requires `src`, `spec`, `audio_buf` and `audio_len` to
593 * be valid pointers. The entire data portion of the file is then loaded into
594 * memory and decoded if necessary.
595 *
596 * If `freesrc` is non-zero, the data source gets automatically closed and
597 * freed before the function returns.
598 *
599 * Supported formats are RIFF WAVE files with the formats PCM (8, 16, 24, and
600 * 32 bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and
601 * A-law and mu-law (8 bits). Other formats are currently unsupported and
602 * cause an error.
603 *
604 * If this function succeeds, the pointer returned by it is equal to `spec`
605 * and the pointer to the audio data allocated by the function is written to
606 * `audio_buf` and its length in bytes to `audio_len`. The SDL_AudioSpec
607 * members `freq`, `channels`, and `format` are set to the values of the audio
608 * data in the buffer. The `samples` member is set to a sane default and all
609 * others are set to zero.
610 *
611 * It's necessary to use SDL_free() to free the audio data returned in
612 * `audio_buf` when it is no longer used.
613 *
614 * Because of the underspecification of the .WAV format, there are many
615 * problematic files in the wild that cause issues with strict decoders. To
616 * provide compatibility with these files, this decoder is lenient in regards
617 * to the truncation of the file, the fact chunk, and the size of the RIFF
618 * chunk. The hints `SDL_HINT_WAVE_RIFF_CHUNK_SIZE`,
619 * `SDL_HINT_WAVE_TRUNCATION`, and `SDL_HINT_WAVE_FACT_CHUNK` can be used to
620 * tune the behavior of the loading process.
621 *
622 * Any file that is invalid (due to truncation, corruption, or wrong values in
623 * the headers), too big, or unsupported causes an error. Additionally, any
624 * critical I/O error from the data source will terminate the loading process
625 * with an error. The function returns NULL on error and in all cases (with
626 * the exception of `src` being NULL), an appropriate error message will be
627 * set.
628 *
629 * It is required that the data source supports seeking.
630 *
631 * Example:
632 *
633 * ```c
634 * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, &spec, &buf, &len);
635 * ```
636 *
637 * Note that the SDL_LoadWAV macro does this same thing for you, but in a less
638 * messy way:
639 *
640 * ```c
641 * SDL_LoadWAV("sample.wav", &spec, &buf, &len);
642 * ```
643 *
644 * \param src The data source for the WAVE data
645 * \param freesrc If non-zero, SDL will _always_ free the data source
646 * \param spec An SDL_AudioSpec that will be filled in with the wave file's
647 * format details
648 * \param audio_buf A pointer filled with the audio data, allocated by the
649 * function.
650 * \param audio_len A pointer filled with the length of the audio data buffer
651 * in bytes
652 * \returns This function, if successfully called, returns `spec`, which will
653 * be filled with the audio data format of the wave source data.
654 * `audio_buf` will be filled with a pointer to an allocated buffer
655 * containing the audio data, and `audio_len` is filled with the
656 * length of that audio buffer in bytes.
657 *
658 * This function returns NULL if the .WAV file cannot be opened, uses
659 * an unknown data format, or is corrupt; call SDL_GetError() for
660 * more information.
661 *
662 * When the application is done with the data returned in
663 * `audio_buf`, it should call SDL_free() to dispose of it.
664 *
665 * \since This function is available since SDL 3.0.0.
666 *
667 * \sa SDL_free
668 * \sa SDL_LoadWAV
669 */
670extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
671 int freesrc,
672 SDL_AudioSpec * spec,
673 Uint8 ** audio_buf,
674 Uint32 * audio_len);
675
676/**
677 * Loads a WAV from a file.
678 * Compatibility convenience function.
679 */
680#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
681 SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
682
683
684/* SDL_AudioStream is a new audio conversion interface.
685 The benefits vs SDL_AudioCVT:
686 - it can handle resampling data in chunks without generating
687 artifacts, when it doesn't have the complete buffer available.
688 - it can handle incoming data in any variable size.
689 - You push data as you have it, and pull it when you need it
690 */
691/* this is opaque to the outside world. */
692struct SDL_AudioStream;
694
695/**
696 * Create a new audio stream.
697 *
698 * \param src_format The format of the source audio
699 * \param src_channels The number of channels of the source audio
700 * \param src_rate The sampling rate of the source audio
701 * \param dst_format The format of the desired audio output
702 * \param dst_channels The number of channels of the desired audio output
703 * \param dst_rate The sampling rate of the desired audio output
704 * \returns 0 on success, or -1 on error.
705 *
706 * \since This function is available since SDL 3.0.0.
707 *
708 * \sa SDL_PutAudioStreamData
709 * \sa SDL_GetAudioStreamData
710 * \sa SDL_GetAudioStreamAvailable
711 * \sa SDL_FlushAudioStream
712 * \sa SDL_ClearAudioStream
713 * \sa SDL_DestroyAudioStream
714 */
715extern DECLSPEC SDL_AudioStream *SDLCALL SDL_CreateAudioStream(SDL_AudioFormat src_format,
716 Uint8 src_channels,
717 int src_rate,
718 SDL_AudioFormat dst_format,
719 Uint8 dst_channels,
720 int dst_rate);
721
722/**
723 * Add data to be converted/resampled to the stream.
724 *
725 * \param stream The stream the audio data is being added to
726 * \param buf A pointer to the audio data to add
727 * \param len The number of bytes to write to the stream
728 * \returns 0 on success, or -1 on error.
729 *
730 * \since This function is available since SDL 3.0.0.
731 *
732 * \sa SDL_CreateAudioStream
733 * \sa SDL_GetAudioStreamData
734 * \sa SDL_GetAudioStreamAvailable
735 * \sa SDL_FlushAudioStream
736 * \sa SDL_ClearAudioStream
737 * \sa SDL_DestroyAudioStream
738 */
739extern DECLSPEC int SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len);
740
741/**
742 * Get converted/resampled data from the stream
743 *
744 * \param stream The stream the audio is being requested from
745 * \param buf A buffer to fill with audio data
746 * \param len The maximum number of bytes to fill
747 * \returns the number of bytes read from the stream, or -1 on error
748 *
749 * \since This function is available since SDL 3.0.0.
750 *
751 * \sa SDL_CreateAudioStream
752 * \sa SDL_PutAudioStreamData
753 * \sa SDL_GetAudioStreamAvailable
754 * \sa SDL_FlushAudioStream
755 * \sa SDL_ClearAudioStream
756 * \sa SDL_DestroyAudioStream
757 */
758extern DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len);
759
760/**
761 * Get the number of converted/resampled bytes available.
762 *
763 * The stream may be buffering data behind the scenes until it has enough to
764 * resample correctly, so this number might be lower than what you expect, or
765 * even be zero. Add more data or flush the stream if you need the data now.
766 *
767 * \since This function is available since SDL 3.0.0.
768 *
769 * \sa SDL_CreateAudioStream
770 * \sa SDL_PutAudioStreamData
771 * \sa SDL_GetAudioStreamData
772 * \sa SDL_FlushAudioStream
773 * \sa SDL_ClearAudioStream
774 * \sa SDL_DestroyAudioStream
775 */
777
778/**
779 * Tell the stream that you're done sending data, and anything being buffered
780 * should be converted/resampled and made available immediately.
781 *
782 * It is legal to add more data to a stream after flushing, but there will be
783 * audio gaps in the output. Generally this is intended to signal the end of
784 * input, so the complete output becomes available.
785 *
786 * \since This function is available since SDL 3.0.0.
787 *
788 * \sa SDL_CreateAudioStream
789 * \sa SDL_PutAudioStreamData
790 * \sa SDL_GetAudioStreamData
791 * \sa SDL_GetAudioStreamAvailable
792 * \sa SDL_ClearAudioStream
793 * \sa SDL_DestroyAudioStream
794 */
795extern DECLSPEC int SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream);
796
797/**
798 * Clear any pending data in the stream without converting it
799 *
800 * \since This function is available since SDL 3.0.0.
801 *
802 * \sa SDL_CreateAudioStream
803 * \sa SDL_PutAudioStreamData
804 * \sa SDL_GetAudioStreamData
805 * \sa SDL_GetAudioStreamAvailable
806 * \sa SDL_FlushAudioStream
807 * \sa SDL_DestroyAudioStream
808 */
809extern DECLSPEC void SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
810
811/**
812 * Free an audio stream
813 *
814 * \since This function is available since SDL 3.0.0.
815 *
816 * \sa SDL_CreateAudioStream
817 * \sa SDL_PutAudioStreamData
818 * \sa SDL_GetAudioStreamData
819 * \sa SDL_GetAudioStreamAvailable
820 * \sa SDL_FlushAudioStream
821 * \sa SDL_ClearAudioStream
822 */
823extern DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream);
824
825#define SDL_MIX_MAXVOLUME 128
826
827/**
828 * Mix audio data in a specified format.
829 *
830 * This takes an audio buffer `src` of `len` bytes of `format` data and mixes
831 * it into `dst`, performing addition, volume adjustment, and overflow
832 * clipping. The buffer pointed to by `dst` must also be `len` bytes of
833 * `format` data.
834 *
835 * This is provided for convenience -- you can mix your own audio data.
836 *
837 * Do not use this function for mixing together more than two streams of
838 * sample data. The output from repeated application of this function may be
839 * distorted by clipping, because there is no accumulator with greater range
840 * than the input (not to mention this being an inefficient way of doing it).
841 *
842 * It is a common misconception that this function is required to write audio
843 * data to an output stream in an audio callback. While you can do that,
844 * SDL_MixAudioFormat() is really only needed when you're mixing a single
845 * audio stream with a volume adjustment.
846 *
847 * \param dst the destination for the mixed audio
848 * \param src the source audio buffer to be mixed
849 * \param format the SDL_AudioFormat structure representing the desired audio
850 * format
851 * \param len the length of the audio buffer in bytes
852 * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
853 * for full audio volume
854 * \returns 0 on success or a negative error code on failure; call
855 * SDL_GetError() for more information.
856 *
857 * \since This function is available since SDL 3.0.0.
858 */
859extern DECLSPEC int SDLCALL SDL_MixAudioFormat(Uint8 * dst,
860 const Uint8 * src,
862 Uint32 len, int volume);
863
864/**
865 * Queue more audio on non-callback devices.
866 *
867 * If you are looking to retrieve queued audio from a non-callback capture
868 * device, you want SDL_DequeueAudio() instead. SDL_QueueAudio() will return
869 * -1 to signify an error if you use it with capture devices.
870 *
871 * SDL offers two ways to feed audio to the device: you can either supply a
872 * callback that SDL triggers with some frequency to obtain more audio (pull
873 * method), or you can supply no callback, and then SDL will expect you to
874 * supply data at regular intervals (push method) with this function.
875 *
876 * There are no limits on the amount of data you can queue, short of
877 * exhaustion of address space. Queued data will drain to the device as
878 * necessary without further intervention from you. If the device needs audio
879 * but there is not enough queued, it will play silence to make up the
880 * difference. This means you will have skips in your audio playback if you
881 * aren't routinely queueing sufficient data.
882 *
883 * This function copies the supplied data, so you are safe to free it when the
884 * function returns. This function is thread-safe, but queueing to the same
885 * device from two threads at once does not promise which buffer will be
886 * queued first.
887 *
888 * You may not queue audio on a device that is using an application-supplied
889 * callback; doing so returns an error. You have to use the audio callback or
890 * queue audio with this function, but not both.
891 *
892 * You should not call SDL_LockAudio() on the device before queueing; SDL
893 * handles locking internally for this function.
894 *
895 * Note that SDL does not support planar audio. You will need to resample from
896 * planar audio formats into a non-planar one (see SDL_AudioFormat) before
897 * queuing audio.
898 *
899 * \param dev the device ID to which we will queue audio
900 * \param data the data to queue to the device for later playback
901 * \param len the number of bytes (not samples!) to which `data` points
902 * \returns 0 on success or a negative error code on failure; call
903 * SDL_GetError() for more information.
904 *
905 * \since This function is available since SDL 3.0.0.
906 *
907 * \sa SDL_ClearQueuedAudio
908 * \sa SDL_GetQueuedAudioSize
909 */
910extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len);
911
912/**
913 * Dequeue more audio on non-callback devices.
914 *
915 * If you are looking to queue audio for output on a non-callback playback
916 * device, you want SDL_QueueAudio() instead. SDL_DequeueAudio() will always
917 * return 0 if you use it with playback devices.
918 *
919 * SDL offers two ways to retrieve audio from a capture device: you can either
920 * supply a callback that SDL triggers with some frequency as the device
921 * records more audio data, (push method), or you can supply no callback, and
922 * then SDL will expect you to retrieve data at regular intervals (pull
923 * method) with this function.
924 *
925 * There are no limits on the amount of data you can queue, short of
926 * exhaustion of address space. Data from the device will keep queuing as
927 * necessary without further intervention from you. This means you will
928 * eventually run out of memory if you aren't routinely dequeueing data.
929 *
930 * Capture devices will not queue data when paused; if you are expecting to
931 * not need captured audio for some length of time, use SDL_PauseAudioDevice()
932 * to stop the capture device from queueing more data. This can be useful
933 * during, say, level loading times. When unpaused, capture devices will start
934 * queueing data from that point, having flushed any capturable data available
935 * while paused.
936 *
937 * This function is thread-safe, but dequeueing from the same device from two
938 * threads at once does not promise which thread will dequeue data first.
939 *
940 * You may not dequeue audio from a device that is using an
941 * application-supplied callback; doing so returns an error. You have to use
942 * the audio callback, or dequeue audio with this function, but not both.
943 *
944 * You should not call SDL_LockAudio() on the device before dequeueing; SDL
945 * handles locking internally for this function.
946 *
947 * \param dev the device ID from which we will dequeue audio
948 * \param data a pointer into where audio data should be copied
949 * \param len the number of bytes (not samples!) to which (data) points
950 * \returns the number of bytes dequeued, which could be less than requested;
951 * call SDL_GetError() for more information.
952 *
953 * \since This function is available since SDL 3.0.0.
954 *
955 * \sa SDL_ClearQueuedAudio
956 * \sa SDL_GetQueuedAudioSize
957 */
958extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len);
959
960/**
961 * Get the number of bytes of still-queued audio.
962 *
963 * For playback devices: this is the number of bytes that have been queued for
964 * playback with SDL_QueueAudio(), but have not yet been sent to the hardware.
965 *
966 * Once we've sent it to the hardware, this function can not decide the exact
967 * byte boundary of what has been played. It's possible that we just gave the
968 * hardware several kilobytes right before you called this function, but it
969 * hasn't played any of it yet, or maybe half of it, etc.
970 *
971 * For capture devices, this is the number of bytes that have been captured by
972 * the device and are waiting for you to dequeue. This number may grow at any
973 * time, so this only informs of the lower-bound of available data.
974 *
975 * You may not queue or dequeue audio on a device that is using an
976 * application-supplied callback; calling this function on such a device
977 * always returns 0. You have to use the audio callback or queue audio, but
978 * not both.
979 *
980 * You should not call SDL_LockAudio() on the device before querying; SDL
981 * handles locking internally for this function.
982 *
983 * \param dev the device ID of which we will query queued audio size
984 * \returns the number of bytes (not samples!) of queued audio.
985 *
986 * \since This function is available since SDL 3.0.0.
987 *
988 * \sa SDL_ClearQueuedAudio
989 * \sa SDL_QueueAudio
990 * \sa SDL_DequeueAudio
991 */
993
994/**
995 * Drop any queued audio data waiting to be sent to the hardware.
996 *
997 * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For
998 * output devices, the hardware will start playing silence if more audio isn't
999 * queued. For capture devices, the hardware will start filling the empty
1000 * queue with new data if the capture device isn't paused.
1001 *
1002 * This will not prevent playback of queued audio that's already been sent to
1003 * the hardware, as we can not undo that, so expect there to be some fraction
1004 * of a second of audio that might still be heard. This can be useful if you
1005 * want to, say, drop any pending music or any unprocessed microphone input
1006 * during a level change in your game.
1007 *
1008 * You may not queue or dequeue audio on a device that is using an
1009 * application-supplied callback; calling this function on such a device
1010 * always returns 0. You have to use the audio callback or queue audio, but
1011 * not both.
1012 *
1013 * You should not call SDL_LockAudio() on the device before clearing the
1014 * queue; SDL handles locking internally for this function.
1015 *
1016 * This function always succeeds and thus returns void.
1017 *
1018 * \param dev the device ID of which to clear the audio queue
1019 *
1020 * \since This function is available since SDL 3.0.0.
1021 *
1022 * \sa SDL_GetQueuedAudioSize
1023 * \sa SDL_QueueAudio
1024 * \sa SDL_DequeueAudio
1025 */
1026extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev);
1027
1028
1029/**
1030 * \name Audio lock functions
1031 *
1032 * The lock manipulated by these functions protects the callback function.
1033 * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that
1034 * the callback function is not running. Do not call these from the callback
1035 * function or you will cause deadlock.
1036 */
1037/* @{ */
1038
1039/**
1040 * Use this function to lock out the audio callback function for a specified
1041 * device.
1042 *
1043 * The lock manipulated by these functions protects the audio callback
1044 * function specified in SDL_OpenAudioDevice(). During a
1045 * SDL_LockAudioDevice()/SDL_UnlockAudioDevice() pair, you can be guaranteed
1046 * that the callback function for that device is not running, even if the
1047 * device is not paused. While a device is locked, any other unpaused,
1048 * unlocked devices may still run their callbacks.
1049 *
1050 * Calling this function from inside your audio callback is unnecessary. SDL
1051 * obtains this lock before calling your function, and releases it when the
1052 * function returns.
1053 *
1054 * You should not hold the lock longer than absolutely necessary. If you hold
1055 * it too long, you'll experience dropouts in your audio playback. Ideally,
1056 * your application locks the device, sets a few variables and unlocks again.
1057 * Do not do heavy work while holding the lock for a device.
1058 *
1059 * It is safe to lock the audio device multiple times, as long as you unlock
1060 * it an equivalent number of times. The callback will not run until the
1061 * device has been unlocked completely in this way. If your application fails
1062 * to unlock the device appropriately, your callback will never run, you might
1063 * hear repeating bursts of audio, and SDL_CloseAudioDevice() will probably
1064 * deadlock.
1065 *
1066 * Internally, the audio device lock is a mutex; if you lock from two threads
1067 * at once, not only will you block the audio callback, you'll block the other
1068 * thread.
1069 *
1070 * \param dev the ID of the device to be locked
1071 *
1072 * \since This function is available since SDL 3.0.0.
1073 *
1074 * \sa SDL_UnlockAudioDevice
1075 */
1076extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
1077
1078/**
1079 * Use this function to unlock the audio callback function for a specified
1080 * device.
1081 *
1082 * This function should be paired with a previous SDL_LockAudioDevice() call.
1083 *
1084 * \param dev the ID of the device to be unlocked
1085 *
1086 * \since This function is available since SDL 3.0.0.
1087 *
1088 * \sa SDL_LockAudioDevice
1089 */
1090extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
1091/* @} *//* Audio lock functions */
1092
1093/**
1094 * Use this function to shut down audio processing and close the audio device.
1095 *
1096 * The application should close open audio devices once they are no longer
1097 * needed. Calling this function will wait until the device's audio callback
1098 * is not running, release the audio hardware and then clean up internal
1099 * state. No further audio will play from this device once this function
1100 * returns.
1101 *
1102 * This function may block briefly while pending audio data is played by the
1103 * hardware, so that applications don't drop the last buffer of data they
1104 * supplied.
1105 *
1106 * The device ID is invalid as soon as the device is closed, and is eligible
1107 * for reuse in a new SDL_OpenAudioDevice() call immediately.
1108 *
1109 * \param dev an audio device previously opened with SDL_OpenAudioDevice()
1110 *
1111 * \since This function is available since SDL 3.0.0.
1112 *
1113 * \sa SDL_OpenAudioDevice
1114 */
1115extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
1116
1117/**
1118 * Convert some audio data of one format to another format.
1119 *
1120 * \param src_format The format of the source audio
1121 * \param src_channels The number of channels of the source audio
1122 * \param src_rate The sampling rate of the source audio
1123 * \param src_len The len of src_data
1124 * \param src_data The audio data to be converted
1125 * \param dst_format The format of the desired audio output
1126 * \param dst_channels The number of channels of the desired audio output
1127 * \param dst_rate The sampling rate of the desired audio output
1128 * \param dst_len Will be filled with the len of dst_data
1129 * \param dst_data Will be filled with a pointer to converted audio data,
1130 * which should be freed with SDL_free().
1131 * \returns 0 on success or a negative error code on failure. On error,
1132 * *dst_data will be NULL and so not allocated.
1133 *
1134 * \since This function is available since SDL 3.0.0.
1135 *
1136 * \sa SDL_CreateAudioStream
1137 */
1138extern DECLSPEC int SDLCALL SDL_ConvertAudioSamples(SDL_AudioFormat src_format,
1139 Uint8 src_channels,
1140 int src_rate,
1141 int src_len,
1142 Uint8 *src_data,
1143 SDL_AudioFormat dst_format,
1144 Uint8 dst_channels,
1145 int dst_rate,
1146 int *dst_len,
1147 Uint8 **dst_data);
1148
1149/* Ends C function definitions when using C++ */
1150#ifdef __cplusplus
1151}
1152#endif
1153#include <SDL3/SDL_close_code.h>
1154
1155#endif /* SDL_audio_h_ */
void SDL_CloseAudioDevice(SDL_AudioDeviceID dev)
SDL_AudioSpec * SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
SDL_AudioDeviceID SDL_OpenAudioDevice(const char *device, int iscapture, const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, int allowed_changes)
int SDL_GetNumAudioDevices(int iscapture)
const char * SDL_GetAudioDriver(int index)
SDL_AudioStatus
Definition: SDL_audio.h:524
@ SDL_AUDIO_STOPPED
Definition: SDL_audio.h:525
@ SDL_AUDIO_PLAYING
Definition: SDL_audio.h:526
@ SDL_AUDIO_PAUSED
Definition: SDL_audio.h:527
struct SDL_AudioStream SDL_AudioStream
Definition: SDL_audio.h:693
const char * SDL_GetAudioDeviceName(int index, int iscapture)
Uint16 SDL_AudioFormat
Audio format flags.
Definition: SDL_audio.h:66
int SDL_FlushAudioStream(SDL_AudioStream *stream)
Uint32 SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len)
int SDL_GetNumAudioDrivers(void)
void SDL_PauseAudioDevice(SDL_AudioDeviceID dev)
Uint32 SDL_AudioDeviceID
Definition: SDL_audio.h:267
const char * SDL_GetCurrentAudioDriver(void)
int SDL_ConvertAudioSamples(SDL_AudioFormat src_format, Uint8 src_channels, int src_rate, int src_len, Uint8 *src_data, SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate, int *dst_len, Uint8 **dst_data)
int SDL_GetAudioStreamAvailable(SDL_AudioStream *stream)
int SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len)
int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
void SDL_PlayAudioDevice(SDL_AudioDeviceID dev)
void SDL_ClearQueuedAudio(SDL_AudioDeviceID dev)
int SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
void SDL_DestroyAudioStream(SDL_AudioStream *stream)
int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len)
void(* SDL_AudioCallback)(void *userdata, Uint8 *stream, int len)
Definition: SDL_audio.h:165
void SDL_ClearAudioStream(SDL_AudioStream *stream)
Uint32 SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev)
int SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, Uint32 len, int volume)
SDL_AudioStream * SDL_CreateAudioStream(SDL_AudioFormat src_format, Uint8 src_channels, int src_rate, SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate)
int SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec)
SDL_AudioStatus SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev)
void SDL_LockAudioDevice(SDL_AudioDeviceID dev)
void SDL_UnlockAudioDevice(SDL_AudioDeviceID dev)
typedef void(APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1565
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
GLuint GLuint stream
GLenum src
GLuint index
GLenum GLsizei len
GLenum GLenum dst
GLuint const GLchar * name
GLenum GLuint GLenum GLsizei const GLchar * buf
uint8_t Uint8
Definition: SDL_stdinc.h:147
uint16_t Uint16
Definition: SDL_stdinc.h:159
uint32_t Uint32
Definition: SDL_stdinc.h:171
Uint32 size
Definition: SDL_audio.h:188
SDL_AudioCallback callback
Definition: SDL_audio.h:189
Uint16 samples
Definition: SDL_audio.h:186
Uint8 channels
Definition: SDL_audio.h:184
Uint16 padding
Definition: SDL_audio.h:187
Uint8 silence
Definition: SDL_audio.h:185
SDL_AudioFormat format
Definition: SDL_audio.h:183
void * userdata
Definition: SDL_audio.h:190