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 or a negative error code on failure; call
360 * SDL_GetError() for more information.
361 *
362 * \since This function is available since SDL 3.0.0.
363 *
364 * \sa SDL_GetNumAudioDevices
365 * \sa SDL_GetDefaultAudioInfo
366 */
367extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
368 int iscapture,
369 SDL_AudioSpec *spec);
370
371
372/**
373 * Get the name and preferred format of the default audio device.
374 *
375 * Some (but not all!) platforms have an isolated mechanism to get information
376 * about the "default" device. This can actually be a completely different
377 * device that's not in the list you get from SDL_GetAudioDeviceSpec(). It can
378 * even be a network address! (This is discussed in SDL_OpenAudioDevice().)
379 *
380 * As a result, this call is not guaranteed to be performant, as it can query
381 * the sound server directly every time, unlike the other query functions. You
382 * should call this function sparingly!
383 *
384 * `spec` will be filled with the sample rate, sample format, and channel
385 * count, if a default device exists on the system. If `name` is provided,
386 * will be filled with either a dynamically-allocated UTF-8 string or NULL.
387 *
388 * \param name A pointer to be filled with the name of the default device (can
389 * be NULL). Please call SDL_free() when you are done with this
390 * pointer!
391 * \param spec The SDL_AudioSpec to be initialized by this function.
392 * \param iscapture non-zero to query the default recording device, zero to
393 * query the default output device.
394 * \returns 0 on success or a negative error code on failure; call
395 * SDL_GetError() for more information.
396 *
397 * \since This function is available since SDL 3.0.0.
398 *
399 * \sa SDL_GetAudioDeviceName
400 * \sa SDL_GetAudioDeviceSpec
401 * \sa SDL_OpenAudioDevice
402 */
403extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
404 SDL_AudioSpec *spec,
405 int iscapture);
406
407
408/**
409 * Open a specific audio device.
410 *
411 * Passing in a `device` name of NULL requests the most reasonable default.
412 * The `device` name is a UTF-8 string reported by SDL_GetAudioDeviceName(),
413 * but some drivers allow arbitrary and driver-specific strings, such as a
414 * hostname/IP address for a remote audio server, or a filename in the
415 * diskaudio driver.
416 *
417 * An opened audio device starts out paused, and should be enabled for playing
418 * by calling SDL_PlayAudioDevice(devid) when you are ready for your audio
419 * callback function to be called. Since the audio driver may modify the
420 * requested size of the audio buffer, you should allocate any local mixing
421 * buffers after you open the audio device.
422 *
423 * The audio callback runs in a separate thread in most cases; you can prevent
424 * race conditions between your callback and other threads without fully
425 * pausing playback with SDL_LockAudioDevice(). For more information about the
426 * callback, see SDL_AudioSpec.
427 *
428 * Managing the audio spec via 'desired' and 'obtained':
429 *
430 * When filling in the desired audio spec structure:
431 *
432 * - `desired->freq` should be the frequency in sample-frames-per-second (Hz).
433 * - `desired->format` should be the audio format (`AUDIO_S16SYS`, etc).
434 * - `desired->samples` is the desired size of the audio buffer, in _sample
435 * frames_ (with stereo output, two samples--left and right--would make a
436 * single sample frame). This number should be a power of two, and may be
437 * adjusted by the audio driver to a value more suitable for the hardware.
438 * Good values seem to range between 512 and 8096 inclusive, depending on
439 * the application and CPU speed. Smaller values reduce latency, but can
440 * lead to underflow if the application is doing heavy processing and cannot
441 * fill the audio buffer in time. Note that the number of sample frames is
442 * directly related to time by the following formula: `ms =
443 * (sampleframes*1000)/freq`
444 * - `desired->size` is the size in _bytes_ of the audio buffer, and is
445 * calculated by SDL_OpenAudioDevice(). You don't initialize this.
446 * - `desired->silence` is the value used to set the buffer to silence, and is
447 * calculated by SDL_OpenAudioDevice(). You don't initialize this.
448 * - `desired->callback` should be set to a function that will be called when
449 * the audio device is ready for more data. It is passed a pointer to the
450 * audio buffer, and the length in bytes of the audio buffer. This function
451 * usually runs in a separate thread, and so you should protect data
452 * structures that it accesses by calling SDL_LockAudioDevice() and
453 * SDL_UnlockAudioDevice() in your code. Alternately, you may pass a NULL
454 * pointer here, and call SDL_QueueAudio() with some frequency, to queue
455 * more audio samples to be played (or for capture devices, call
456 * SDL_DequeueAudio() with some frequency, to obtain audio samples).
457 * - `desired->userdata` is passed as the first parameter to your callback
458 * function. If you passed a NULL callback, this value is ignored.
459 *
460 * `allowed_changes` can have the following flags OR'd together:
461 *
462 * - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE`
463 * - `SDL_AUDIO_ALLOW_FORMAT_CHANGE`
464 * - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE`
465 * - `SDL_AUDIO_ALLOW_SAMPLES_CHANGE`
466 * - `SDL_AUDIO_ALLOW_ANY_CHANGE`
467 *
468 * These flags specify how SDL should behave when a device cannot offer a
469 * specific feature. If the application requests a feature that the hardware
470 * doesn't offer, SDL will always try to get the closest equivalent.
471 *
472 * For example, if you ask for float32 audio format, but the sound card only
473 * supports int16, SDL will set the hardware to int16. If you had set
474 * SDL_AUDIO_ALLOW_FORMAT_CHANGE, SDL will change the format in the `obtained`
475 * structure. If that flag was *not* set, SDL will prepare to convert your
476 * callback's float32 audio to int16 before feeding it to the hardware and
477 * will keep the originally requested format in the `obtained` structure.
478 *
479 * The resulting audio specs, varying depending on hardware and on what
480 * changes were allowed, will then be written back to `obtained`.
481 *
482 * If your application can only handle one specific data format, pass a zero
483 * for `allowed_changes` and let SDL transparently handle any differences.
484 *
485 * \param device a UTF-8 string reported by SDL_GetAudioDeviceName() or a
486 * driver-specific name as appropriate. NULL requests the most
487 * reasonable default device.
488 * \param iscapture non-zero to specify a device should be opened for
489 * recording, not playback
490 * \param desired an SDL_AudioSpec structure representing the desired output
491 * format
492 * \param obtained an SDL_AudioSpec structure filled in with the actual output
493 * format
494 * \param allowed_changes 0, or one or more flags OR'd together
495 * \returns a valid device ID that is > 0 on success or 0 on failure; call
496 * SDL_GetError() for more information.
497 *
498 * For compatibility with SDL 1.2, this will never return 1, since
499 * SDL reserves that ID for the legacy SDL_OpenAudio() function.
500 *
501 * \since This function is available since SDL 3.0.0.
502 *
503 * \sa SDL_CloseAudioDevice
504 * \sa SDL_GetAudioDeviceName
505 * \sa SDL_LockAudioDevice
506 * \sa SDL_PlayAudioDevice
507 * \sa SDL_PauseAudioDevice
508 * \sa SDL_UnlockAudioDevice
509 */
511 const char *device,
512 int iscapture,
513 const SDL_AudioSpec *desired,
514 SDL_AudioSpec *obtained,
515 int allowed_changes);
516
517
518
519/**
520 * \name Audio state
521 *
522 * Get the current audio state.
523 */
524/* @{ */
525typedef enum
526{
531
532/**
533 * Use this function to get the current audio state of an audio device.
534 *
535 * \param dev the ID of an audio device previously opened with
536 * SDL_OpenAudioDevice()
537 * \returns the SDL_AudioStatus of the specified audio device.
538 *
539 * \since This function is available since SDL 3.0.0.
540 *
541 * \sa SDL_PlayAudioDevice
542 * \sa SDL_PauseAudioDevice
543 */
545/* @} *//* Audio State */
546
547/**
548 * Use this function to play audio on a specified device.
549 *
550 * Newly-opened audio devices start in the paused state, so you must call this
551 * function after opening the specified audio device to start playing sound.
552 * This allows you to safely initialize data for your callback function after
553 * opening the audio device. Silence will be written to the audio device while
554 * paused, and the audio callback is guaranteed to not be called. Pausing one
555 * device does not prevent other unpaused devices from running their
556 * callbacks.
557 *
558 * \param dev a device opened by SDL_OpenAudioDevice()
559 * \returns 0 on success or a negative error code on failure; call
560 * SDL_GetError() for more information.
561 *
562 * \since This function is available since SDL 3.0.0.
563 *
564 * \sa SDL_LockAudioDevice
565 * \sa SDL_PauseAudioDevice
566 */
567extern DECLSPEC int SDLCALL SDL_PlayAudioDevice(SDL_AudioDeviceID dev);
568
569
570
571/**
572 * Use this function to pause audio playback on a specified device.
573 *
574 * This function pauses the audio callback processing for a given device.
575 * Silence will be written to the audio device while paused, and the audio
576 * callback is guaranteed to not be called. Pausing one device does not
577 * prevent other unpaused devices from running their callbacks.
578 *
579 * If you just need to protect a few variables from race conditions vs your
580 * callback, you shouldn't pause the audio device, as it will lead to dropouts
581 * in the audio playback. Instead, you should use SDL_LockAudioDevice().
582 *
583 * \param dev a device opened by SDL_OpenAudioDevice()
584 * \returns 0 on success or a negative error code on failure; call
585 * SDL_GetError() for more information.
586 *
587 * \since This function is available since SDL 3.0.0.
588 *
589 * \sa SDL_LockAudioDevice
590 * \sa SDL_PlayAudioDevice
591 */
592extern DECLSPEC int SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev);
593
594
595/**
596 * Load the audio data of a WAVE file into memory.
597 *
598 * Loading a WAVE file requires `src`, `spec`, `audio_buf` and `audio_len` to
599 * be valid pointers. The entire data portion of the file is then loaded into
600 * memory and decoded if necessary.
601 *
602 * If `freesrc` is non-zero, the data source gets automatically closed and
603 * freed before the function returns.
604 *
605 * Supported formats are RIFF WAVE files with the formats PCM (8, 16, 24, and
606 * 32 bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and
607 * A-law and mu-law (8 bits). Other formats are currently unsupported and
608 * cause an error.
609 *
610 * If this function succeeds, the pointer returned by it is equal to `spec`
611 * and the pointer to the audio data allocated by the function is written to
612 * `audio_buf` and its length in bytes to `audio_len`. The SDL_AudioSpec
613 * members `freq`, `channels`, and `format` are set to the values of the audio
614 * data in the buffer. The `samples` member is set to a sane default and all
615 * others are set to zero.
616 *
617 * It's necessary to use SDL_free() to free the audio data returned in
618 * `audio_buf` when it is no longer used.
619 *
620 * Because of the underspecification of the .WAV format, there are many
621 * problematic files in the wild that cause issues with strict decoders. To
622 * provide compatibility with these files, this decoder is lenient in regards
623 * to the truncation of the file, the fact chunk, and the size of the RIFF
624 * chunk. The hints `SDL_HINT_WAVE_RIFF_CHUNK_SIZE`,
625 * `SDL_HINT_WAVE_TRUNCATION`, and `SDL_HINT_WAVE_FACT_CHUNK` can be used to
626 * tune the behavior of the loading process.
627 *
628 * Any file that is invalid (due to truncation, corruption, or wrong values in
629 * the headers), too big, or unsupported causes an error. Additionally, any
630 * critical I/O error from the data source will terminate the loading process
631 * with an error. The function returns NULL on error and in all cases (with
632 * the exception of `src` being NULL), an appropriate error message will be
633 * set.
634 *
635 * It is required that the data source supports seeking.
636 *
637 * Example:
638 *
639 * ```c
640 * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, &spec, &buf, &len);
641 * ```
642 *
643 * Note that the SDL_LoadWAV macro does this same thing for you, but in a less
644 * messy way:
645 *
646 * ```c
647 * SDL_LoadWAV("sample.wav", &spec, &buf, &len);
648 * ```
649 *
650 * \param src The data source for the WAVE data
651 * \param freesrc If non-zero, SDL will _always_ free the data source
652 * \param spec An SDL_AudioSpec that will be filled in with the wave file's
653 * format details
654 * \param audio_buf A pointer filled with the audio data, allocated by the
655 * function.
656 * \param audio_len A pointer filled with the length of the audio data buffer
657 * in bytes
658 * \returns This function, if successfully called, returns `spec`, which will
659 * be filled with the audio data format of the wave source data.
660 * `audio_buf` will be filled with a pointer to an allocated buffer
661 * containing the audio data, and `audio_len` is filled with the
662 * length of that audio buffer in bytes.
663 *
664 * This function returns NULL if the .WAV file cannot be opened, uses
665 * an unknown data format, or is corrupt; call SDL_GetError() for
666 * more information.
667 *
668 * When the application is done with the data returned in
669 * `audio_buf`, it should call SDL_free() to dispose of it.
670 *
671 * \since This function is available since SDL 3.0.0.
672 *
673 * \sa SDL_free
674 * \sa SDL_LoadWAV
675 */
676extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
677 int freesrc,
678 SDL_AudioSpec * spec,
679 Uint8 ** audio_buf,
680 Uint32 * audio_len);
681
682/**
683 * Loads a WAV from a file.
684 * Compatibility convenience function.
685 */
686#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
687 SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
688
689
690/* SDL_AudioStream is a new audio conversion interface.
691 The benefits vs SDL_AudioCVT:
692 - it can handle resampling data in chunks without generating
693 artifacts, when it doesn't have the complete buffer available.
694 - it can handle incoming data in any variable size.
695 - You push data as you have it, and pull it when you need it
696 */
697/* this is opaque to the outside world. */
698struct SDL_AudioStream;
700
701/**
702 * Create a new audio stream.
703 *
704 * \param src_format The format of the source audio
705 * \param src_channels The number of channels of the source audio
706 * \param src_rate The sampling rate of the source audio
707 * \param dst_format The format of the desired audio output
708 * \param dst_channels The number of channels of the desired audio output
709 * \param dst_rate The sampling rate of the desired audio output
710 * \returns 0 on success, or -1 on error.
711 *
712 * \since This function is available since SDL 3.0.0.
713 *
714 * \sa SDL_PutAudioStreamData
715 * \sa SDL_GetAudioStreamData
716 * \sa SDL_GetAudioStreamAvailable
717 * \sa SDL_FlushAudioStream
718 * \sa SDL_ClearAudioStream
719 * \sa SDL_DestroyAudioStream
720 */
721extern DECLSPEC SDL_AudioStream *SDLCALL SDL_CreateAudioStream(SDL_AudioFormat src_format,
722 Uint8 src_channels,
723 int src_rate,
724 SDL_AudioFormat dst_format,
725 Uint8 dst_channels,
726 int dst_rate);
727
728/**
729 * Add data to be converted/resampled to the stream.
730 *
731 * \param stream The stream the audio data is being added to
732 * \param buf A pointer to the audio data to add
733 * \param len The number of bytes to write to the stream
734 * \returns 0 on success or a negative error code on failure; call
735 * SDL_GetError() for more information.
736 *
737 * \since This function is available since SDL 3.0.0.
738 *
739 * \sa SDL_CreateAudioStream
740 * \sa SDL_GetAudioStreamData
741 * \sa SDL_GetAudioStreamAvailable
742 * \sa SDL_FlushAudioStream
743 * \sa SDL_ClearAudioStream
744 * \sa SDL_DestroyAudioStream
745 */
746extern DECLSPEC int SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len);
747
748/**
749 * Get converted/resampled data from the stream
750 *
751 * \param stream The stream the audio is being requested from
752 * \param buf A buffer to fill with audio data
753 * \param len The maximum number of bytes to fill
754 * \returns the number of bytes read from the stream, or -1 on error
755 *
756 * \since This function is available since SDL 3.0.0.
757 *
758 * \sa SDL_CreateAudioStream
759 * \sa SDL_PutAudioStreamData
760 * \sa SDL_GetAudioStreamAvailable
761 * \sa SDL_FlushAudioStream
762 * \sa SDL_ClearAudioStream
763 * \sa SDL_DestroyAudioStream
764 */
765extern DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len);
766
767/**
768 * Get the number of converted/resampled bytes available.
769 *
770 * The stream may be buffering data behind the scenes until it has enough to
771 * resample correctly, so this number might be lower than what you expect, or
772 * even be zero. Add more data or flush the stream if you need the data now.
773 *
774 * \param stream The audio stream to query
775 * \returns the number of converted/resampled bytes available.
776 *
777 * \since This function is available since SDL 3.0.0.
778 *
779 * \sa SDL_CreateAudioStream
780 * \sa SDL_PutAudioStreamData
781 * \sa SDL_GetAudioStreamData
782 * \sa SDL_FlushAudioStream
783 * \sa SDL_ClearAudioStream
784 * \sa SDL_DestroyAudioStream
785 */
787
788/**
789 * Tell the stream that you're done sending data, and anything being buffered
790 * should be converted/resampled and made available immediately.
791 *
792 * It is legal to add more data to a stream after flushing, but there will be
793 * audio gaps in the output. Generally this is intended to signal the end of
794 * input, so the complete output becomes available.
795 *
796 * \param stream The audio stream to flush
797 * \returns 0 on success or a negative error code on failure; call
798 * SDL_GetError() for more information.
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_ClearAudioStream
807 * \sa SDL_DestroyAudioStream
808 */
809extern DECLSPEC int SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream);
810
811/**
812 * Clear any pending data in the stream without converting it
813 *
814 * \param stream The audio stream to clear
815 * \returns 0 on success or a negative error code on failure; call
816 * SDL_GetError() for more information.
817 *
818 * \since This function is available since SDL 3.0.0.
819 *
820 * \sa SDL_CreateAudioStream
821 * \sa SDL_PutAudioStreamData
822 * \sa SDL_GetAudioStreamData
823 * \sa SDL_GetAudioStreamAvailable
824 * \sa SDL_FlushAudioStream
825 * \sa SDL_DestroyAudioStream
826 */
827extern DECLSPEC int SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
828
829/**
830 * Free an audio stream
831 *
832 * \param stream The audio stream to free
833 * \since This function is available since SDL 3.0.0.
834 *
835 * \sa SDL_CreateAudioStream
836 * \sa SDL_PutAudioStreamData
837 * \sa SDL_GetAudioStreamData
838 * \sa SDL_GetAudioStreamAvailable
839 * \sa SDL_FlushAudioStream
840 * \sa SDL_ClearAudioStream
841 */
842extern DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream);
843
844#define SDL_MIX_MAXVOLUME 128
845
846/**
847 * Mix audio data in a specified format.
848 *
849 * This takes an audio buffer `src` of `len` bytes of `format` data and mixes
850 * it into `dst`, performing addition, volume adjustment, and overflow
851 * clipping. The buffer pointed to by `dst` must also be `len` bytes of
852 * `format` data.
853 *
854 * This is provided for convenience -- you can mix your own audio data.
855 *
856 * Do not use this function for mixing together more than two streams of
857 * sample data. The output from repeated application of this function may be
858 * distorted by clipping, because there is no accumulator with greater range
859 * than the input (not to mention this being an inefficient way of doing it).
860 *
861 * It is a common misconception that this function is required to write audio
862 * data to an output stream in an audio callback. While you can do that,
863 * SDL_MixAudioFormat() is really only needed when you're mixing a single
864 * audio stream with a volume adjustment.
865 *
866 * \param dst the destination for the mixed audio
867 * \param src the source audio buffer to be mixed
868 * \param format the SDL_AudioFormat structure representing the desired audio
869 * format
870 * \param len the length of the audio buffer in bytes
871 * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
872 * for full audio volume
873 * \returns 0 on success or a negative error code on failure; call
874 * SDL_GetError() for more information.
875 *
876 * \since This function is available since SDL 3.0.0.
877 */
878extern DECLSPEC int SDLCALL SDL_MixAudioFormat(Uint8 * dst,
879 const Uint8 * src,
881 Uint32 len, int volume);
882
883/**
884 * Queue more audio on non-callback devices.
885 *
886 * If you are looking to retrieve queued audio from a non-callback capture
887 * device, you want SDL_DequeueAudio() instead. SDL_QueueAudio() will return
888 * -1 to signify an error if you use it with capture devices.
889 *
890 * SDL offers two ways to feed audio to the device: you can either supply a
891 * callback that SDL triggers with some frequency to obtain more audio (pull
892 * method), or you can supply no callback, and then SDL will expect you to
893 * supply data at regular intervals (push method) with this function.
894 *
895 * There are no limits on the amount of data you can queue, short of
896 * exhaustion of address space. Queued data will drain to the device as
897 * necessary without further intervention from you. If the device needs audio
898 * but there is not enough queued, it will play silence to make up the
899 * difference. This means you will have skips in your audio playback if you
900 * aren't routinely queueing sufficient data.
901 *
902 * This function copies the supplied data, so you are safe to free it when the
903 * function returns. This function is thread-safe, but queueing to the same
904 * device from two threads at once does not promise which buffer will be
905 * queued first.
906 *
907 * You may not queue audio on a device that is using an application-supplied
908 * callback; doing so returns an error. You have to use the audio callback or
909 * queue audio with this function, but not both.
910 *
911 * You should not call SDL_LockAudio() on the device before queueing; SDL
912 * handles locking internally for this function.
913 *
914 * Note that SDL does not support planar audio. You will need to resample from
915 * planar audio formats into a non-planar one (see SDL_AudioFormat) before
916 * queuing audio.
917 *
918 * \param dev the device ID to which we will queue audio
919 * \param data the data to queue to the device for later playback
920 * \param len the number of bytes (not samples!) to which `data` points
921 * \returns 0 on success or a negative error code on failure; call
922 * SDL_GetError() for more information.
923 *
924 * \since This function is available since SDL 3.0.0.
925 *
926 * \sa SDL_ClearQueuedAudio
927 * \sa SDL_GetQueuedAudioSize
928 */
929extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len);
930
931/**
932 * Dequeue more audio on non-callback devices.
933 *
934 * If you are looking to queue audio for output on a non-callback playback
935 * device, you want SDL_QueueAudio() instead. SDL_DequeueAudio() will always
936 * return 0 if you use it with playback devices.
937 *
938 * SDL offers two ways to retrieve audio from a capture device: you can either
939 * supply a callback that SDL triggers with some frequency as the device
940 * records more audio data, (push method), or you can supply no callback, and
941 * then SDL will expect you to retrieve data at regular intervals (pull
942 * method) with this function.
943 *
944 * There are no limits on the amount of data you can queue, short of
945 * exhaustion of address space. Data from the device will keep queuing as
946 * necessary without further intervention from you. This means you will
947 * eventually run out of memory if you aren't routinely dequeueing data.
948 *
949 * Capture devices will not queue data when paused; if you are expecting to
950 * not need captured audio for some length of time, use SDL_PauseAudioDevice()
951 * to stop the capture device from queueing more data. This can be useful
952 * during, say, level loading times. When unpaused, capture devices will start
953 * queueing data from that point, having flushed any capturable data available
954 * while paused.
955 *
956 * This function is thread-safe, but dequeueing from the same device from two
957 * threads at once does not promise which thread will dequeue data first.
958 *
959 * You may not dequeue audio from a device that is using an
960 * application-supplied callback; doing so returns an error. You have to use
961 * the audio callback, or dequeue audio with this function, but not both.
962 *
963 * You should not call SDL_LockAudio() on the device before dequeueing; SDL
964 * handles locking internally for this function.
965 *
966 * \param dev the device ID from which we will dequeue audio
967 * \param data a pointer into where audio data should be copied
968 * \param len the number of bytes (not samples!) to which (data) points
969 * \returns the number of bytes dequeued, which could be less than requested;
970 * call SDL_GetError() for more information.
971 *
972 * \since This function is available since SDL 3.0.0.
973 *
974 * \sa SDL_ClearQueuedAudio
975 * \sa SDL_GetQueuedAudioSize
976 */
977extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len);
978
979/**
980 * Get the number of bytes of still-queued audio.
981 *
982 * For playback devices: this is the number of bytes that have been queued for
983 * playback with SDL_QueueAudio(), but have not yet been sent to the hardware.
984 *
985 * Once we've sent it to the hardware, this function can not decide the exact
986 * byte boundary of what has been played. It's possible that we just gave the
987 * hardware several kilobytes right before you called this function, but it
988 * hasn't played any of it yet, or maybe half of it, etc.
989 *
990 * For capture devices, this is the number of bytes that have been captured by
991 * the device and are waiting for you to dequeue. This number may grow at any
992 * time, so this only informs of the lower-bound of available data.
993 *
994 * You may not queue or dequeue audio on a device that is using an
995 * application-supplied callback; calling this function on such a device
996 * always returns 0. You have to use the audio callback or queue audio, but
997 * not both.
998 *
999 * You should not call SDL_LockAudio() on the device before querying; SDL
1000 * handles locking internally for this function.
1001 *
1002 * \param dev the device ID of which we will query queued audio size
1003 * \returns the number of bytes (not samples!) of queued audio.
1004 *
1005 * \since This function is available since SDL 3.0.0.
1006 *
1007 * \sa SDL_ClearQueuedAudio
1008 * \sa SDL_QueueAudio
1009 * \sa SDL_DequeueAudio
1010 */
1012
1013/**
1014 * Drop any queued audio data waiting to be sent to the hardware.
1015 *
1016 * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For
1017 * output devices, the hardware will start playing silence if more audio isn't
1018 * queued. For capture devices, the hardware will start filling the empty
1019 * queue with new data if the capture device isn't paused.
1020 *
1021 * This will not prevent playback of queued audio that's already been sent to
1022 * the hardware, as we can not undo that, so expect there to be some fraction
1023 * of a second of audio that might still be heard. This can be useful if you
1024 * want to, say, drop any pending music or any unprocessed microphone input
1025 * during a level change in your game.
1026 *
1027 * You may not queue or dequeue audio on a device that is using an
1028 * application-supplied callback; calling this function on such a device
1029 * always returns 0. You have to use the audio callback or queue audio, but
1030 * not both.
1031 *
1032 * You should not call SDL_LockAudio() on the device before clearing the
1033 * queue; SDL handles locking internally for this function.
1034 *
1035 * This function always succeeds and thus returns void.
1036 *
1037 * \param dev the device ID of which to clear the audio queue
1038 * \returns 0 on success or a negative error code on failure; call
1039 * SDL_GetError() for more information.
1040 *
1041 * \since This function is available since SDL 3.0.0.
1042 *
1043 * \sa SDL_GetQueuedAudioSize
1044 * \sa SDL_QueueAudio
1045 * \sa SDL_DequeueAudio
1046 */
1047extern DECLSPEC int SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev);
1048
1049
1050/**
1051 * \name Audio lock functions
1052 *
1053 * The lock manipulated by these functions protects the callback function.
1054 * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that
1055 * the callback function is not running. Do not call these from the callback
1056 * function or you will cause deadlock.
1057 */
1058/* @{ */
1059
1060/**
1061 * Use this function to lock out the audio callback function for a specified
1062 * device.
1063 *
1064 * The lock manipulated by these functions protects the audio callback
1065 * function specified in SDL_OpenAudioDevice(). During a
1066 * SDL_LockAudioDevice()/SDL_UnlockAudioDevice() pair, you can be guaranteed
1067 * that the callback function for that device is not running, even if the
1068 * device is not paused. While a device is locked, any other unpaused,
1069 * unlocked devices may still run their callbacks.
1070 *
1071 * Calling this function from inside your audio callback is unnecessary. SDL
1072 * obtains this lock before calling your function, and releases it when the
1073 * function returns.
1074 *
1075 * You should not hold the lock longer than absolutely necessary. If you hold
1076 * it too long, you'll experience dropouts in your audio playback. Ideally,
1077 * your application locks the device, sets a few variables and unlocks again.
1078 * Do not do heavy work while holding the lock for a device.
1079 *
1080 * It is safe to lock the audio device multiple times, as long as you unlock
1081 * it an equivalent number of times. The callback will not run until the
1082 * device has been unlocked completely in this way. If your application fails
1083 * to unlock the device appropriately, your callback will never run, you might
1084 * hear repeating bursts of audio, and SDL_CloseAudioDevice() will probably
1085 * deadlock.
1086 *
1087 * Internally, the audio device lock is a mutex; if you lock from two threads
1088 * at once, not only will you block the audio callback, you'll block the other
1089 * thread.
1090 *
1091 * \param dev the ID of the device to be locked
1092 * \returns 0 on success or a negative error code on failure; call
1093 * SDL_GetError() for more information.
1094 *
1095 * \since This function is available since SDL 3.0.0.
1096 *
1097 * \sa SDL_UnlockAudioDevice
1098 */
1099extern DECLSPEC int SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
1100
1101/**
1102 * Use this function to unlock the audio callback function for a specified
1103 * device.
1104 *
1105 * This function should be paired with a previous SDL_LockAudioDevice() call.
1106 *
1107 * \param dev the ID of the device to be unlocked
1108 *
1109 * \since This function is available since SDL 3.0.0.
1110 *
1111 * \sa SDL_LockAudioDevice
1112 */
1113extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
1114/* @} *//* Audio lock functions */
1115
1116/**
1117 * Use this function to shut down audio processing and close the audio device.
1118 *
1119 * The application should close open audio devices once they are no longer
1120 * needed. Calling this function will wait until the device's audio callback
1121 * is not running, release the audio hardware and then clean up internal
1122 * state. No further audio will play from this device once this function
1123 * returns.
1124 *
1125 * This function may block briefly while pending audio data is played by the
1126 * hardware, so that applications don't drop the last buffer of data they
1127 * supplied.
1128 *
1129 * The device ID is invalid as soon as the device is closed, and is eligible
1130 * for reuse in a new SDL_OpenAudioDevice() call immediately.
1131 *
1132 * \param dev an audio device previously opened with SDL_OpenAudioDevice()
1133 *
1134 * \since This function is available since SDL 3.0.0.
1135 *
1136 * \sa SDL_OpenAudioDevice
1137 */
1138extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
1139
1140/**
1141 * Convert some audio data of one format to another format.
1142 *
1143 * \param src_format The format of the source audio
1144 * \param src_channels The number of channels of the source audio
1145 * \param src_rate The sampling rate of the source audio
1146 * \param src_data The audio data to be converted
1147 * \param src_len The len of src_data
1148 * \param dst_format The format of the desired audio output
1149 * \param dst_channels The number of channels of the desired audio output
1150 * \param dst_rate The sampling rate of the desired audio output
1151 * \param dst_data Will be filled with a pointer to converted audio data,
1152 * which should be freed with SDL_free(). On error, it will be NULL.
1153 * \param dst_len Will be filled with the len of dst_data
1154 * \returns 0 on success or a negative error code on failure; call
1155 * SDL_GetError() for more information.
1156 *
1157 * \since This function is available since SDL 3.0.0.
1158 *
1159 * \sa SDL_CreateAudioStream
1160 */
1161extern DECLSPEC int SDLCALL SDL_ConvertAudioSamples(SDL_AudioFormat src_format,
1162 Uint8 src_channels,
1163 int src_rate,
1164 const Uint8 *src_data,
1165 int src_len,
1166 SDL_AudioFormat dst_format,
1167 Uint8 dst_channels,
1168 int dst_rate,
1169 Uint8 **dst_data,
1170 int *dst_len);
1171
1172/* Ends C function definitions when using C++ */
1173#ifdef __cplusplus
1174}
1175#endif
1176#include <SDL3/SDL_close_code.h>
1177
1178#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:526
@ SDL_AUDIO_STOPPED
Definition: SDL_audio.h:527
@ SDL_AUDIO_PLAYING
Definition: SDL_audio.h:528
@ SDL_AUDIO_PAUSED
Definition: SDL_audio.h:529
int SDL_PlayAudioDevice(SDL_AudioDeviceID dev)
struct SDL_AudioStream SDL_AudioStream
Definition: SDL_audio.h:699
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)
Uint32 SDL_AudioDeviceID
Definition: SDL_audio.h:267
const char * SDL_GetCurrentAudioDriver(void)
int SDL_PauseAudioDevice(SDL_AudioDeviceID dev)
int SDL_GetAudioStreamAvailable(SDL_AudioStream *stream)
int SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len)
int SDL_ConvertAudioSamples(SDL_AudioFormat src_format, Uint8 src_channels, int src_rate, const Uint8 *src_data, int src_len, SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate, Uint8 **dst_data, int *dst_len)
int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
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
Uint32 SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev)
int SDL_ClearAudioStream(SDL_AudioStream *stream)
int SDL_ClearQueuedAudio(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)
int 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