SDL
2.0
|
#include "../SDL_internal.h"
#include "SDL.h"
#include "SDL_audio.h"
#include "SDL_audio_c.h"
#include "SDL_audiomem.h"
#include "SDL_sysaudio.h"
Go to the source code of this file.
Macros | |
#define | _THIS SDL_AudioDevice *_this |
#define | DEFAULT_OUTPUT_DEVNAME "System audio output device" |
#define | DEFAULT_INPUT_DEVNAME "System audio capture device" |
#define | FILL_STUB(x) |
#define | CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x |
#define | NUM_FORMATS 10 |
#define _THIS SDL_AudioDevice *_this |
Definition at line 31 of file SDL_audio.c.
#define CHECK_FMT_STRING | ( | x | ) | if (SDL_strcmp(string, #x) == 0) return AUDIO_##x |
Referenced by SDL_ParseAudioFormat().
#define DEFAULT_INPUT_DEVNAME "System audio capture device" |
Definition at line 38 of file SDL_audio.c.
Referenced by open_audio_device(), and SDL_AudioDetectDevices_Default().
#define DEFAULT_OUTPUT_DEVNAME "System audio output device" |
Definition at line 37 of file SDL_audio.c.
Referenced by open_audio_device(), and SDL_AudioDetectDevices_Default().
#define FILL_STUB | ( | x | ) |
Referenced by finalize_audio_entry_points().
#define NUM_FORMATS 10 |
Definition at line 1371 of file SDL_audio.c.
Referenced by SDL_FirstAudioFormat(), and SDL_NextAudioFormat().
|
static |
Definition at line 293 of file SDL_audio.c.
References SDL_AudioDriver::detectionLock, SDL_AudioDeviceItem::handle, SDL_AudioDeviceItem::name, SDL_AudioDeviceItem::next, NULL, retval, SDL_assert, SDL_INLINE, SDL_LockMutex, SDL_malloc, SDL_strlcpy, SDL_strlen, and SDL_UnlockMutex.
Referenced by add_capture_device(), and add_output_device().
|
static |
Definition at line 317 of file SDL_audio.c.
References add_audio_device(), SDL_AudioDriver::inputDeviceCount, SDL_AudioDriver::inputDevices, and SDL_INLINE.
Referenced by SDL_AddAudioDevice().
|
static |
Definition at line 324 of file SDL_audio.c.
References add_audio_device(), SDL_AudioDriver::outputDeviceCount, and SDL_AudioDriver::outputDevices.
Referenced by SDL_AddAudioDevice().
|
static |
Definition at line 779 of file SDL_audio.c.
References SDL_AudioDeviceItem::handle, SDL_AudioDeviceItem::next, NULL, SDL_FALSE, and SDL_free().
Referenced by SDL_GetNumAudioDevices().
|
static |
Definition at line 873 of file SDL_audio.c.
References SDL_AudioCVT::buf, SDL_AudioDevice::buffer_queue_head, SDL_AudioDevice::buffer_queue_pool, SDL_AudioDriverImpl::CloseDevice, SDL_AudioDevice::convert, SDL_AudioDevice::enabled, SDL_AudioDevice::fake_stream, free_audio_queue(), SDL_AudioDriver::impl, SDL_AudioDevice::mixer_lock, SDL_AudioCVT::needed, NULL, SDL_AudioDevice::opened, SDL_DestroyMutex, SDL_FreeAudioMem, SDL_WaitThread, SDL_AudioDevice::shutdown, and SDL_AudioDevice::thread.
Referenced by open_audio_device(), and SDL_CloseAudioDevice().
Definition at line 262 of file SDL_audio.c.
References FILL_STUB.
Referenced by SDL_AudioInit().
|
static |
Definition at line 423 of file SDL_audio.c.
References SDL_AudioBufferQueue::next, SDL_free(), and SDLCALL.
Referenced by close_audio_device(), SDL_ClearQueuedAudio(), and SDL_QueueAudio().
|
static |
Definition at line 330 of file SDL_audio.c.
References SDL_AudioDriverImpl::FreeDeviceHandle, SDL_AudioDeviceItem::handle, SDL_AudioDriver::impl, SDL_AudioDeviceItem::next, NULL, and SDL_free().
Referenced by SDL_AudioQuit().
|
static |
Definition at line 150 of file SDL_audio.c.
References NULL, SDL_arraysize, and SDL_SetError.
Referenced by SDL_ClearQueuedAudio(), SDL_CloseAudioDevice(), SDL_GetAudioDeviceStatus(), SDL_GetQueuedAudioSize(), SDL_LockAudioDevice(), SDL_MixAudio(), SDL_OpenedAudioDeviceDisconnected(), SDL_PauseAudioDevice(), SDL_QueueAudio(), and SDL_UnlockAudioDevice().
|
static |
Definition at line 231 of file SDL_audio.c.
References SDL_FALSE, SDL_ThreadID, SDL_TRUE, SDL_AudioDevice::thread, and SDL_AudioDevice::threadid.
Referenced by SDL_AudioLockDevice_Default(), and SDL_AudioUnlockDevice_Default().
|
static |
Definition at line 390 of file SDL_audio.c.
References SDL_AudioDeviceItem::handle, SDL_AudioDeviceItem::next, NULL, SDL_assert, and SDL_TRUE.
Referenced by SDL_RemoveAudioDevice().
|
static |
Definition at line 962 of file SDL_audio.c.
References SDL_AudioDriverImpl::AllowsArbitraryDeviceNames, SDL_AudioCVT::buf, SDL_AudioDevice::buffer_queue_pool, SDL_AudioSpec::callback, SDL_AudioSpec::channels, close_audio_device(), SDL_AudioDevice::convert, SDL_AudioBufferQueue::datalen, DEFAULT_INPUT_DEVNAME, DEFAULT_OUTPUT_DEVNAME, SDL_AudioDriver::detectionLock, SDL_AudioDevice::enabled, SDL_AudioDevice::fake_stream, SDL_AudioSpec::format, SDL_AudioSpec::freq, SDL_AudioDeviceItem::handle, SDL_AudioDriverImpl::HasCaptureSupport, i, SDL_AudioDevice::id, SDL_AudioDriver::impl, SDL_AudioDriver::inputDevices, SDL_AudioDevice::iscapture, SDL_AudioCVT::len, SDL_AudioCVT::len_cvt, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, SDL_AudioDevice::mixer_lock, SDL_AudioDeviceItem::name, SDL_AudioCVT::needed, SDL_AudioBufferQueue::next, SDL_AudioDeviceItem::next, NULL, SDL_AudioDriverImpl::OnlyHasDefaultInputDevice, SDL_AudioDriverImpl::OnlyHasDefaultOutputDevice, SDL_AudioDriverImpl::OpenDevice, SDL_AudioDevice::opened, SDL_AudioDriver::outputDevices, SDL_AudioDevice::paused, prepare_audiospec(), SDL_AudioDriverImpl::ProvidesOwnCallbackThread, SDL_AudioSpec::samples, SDL_AllocAudioMem, SDL_arraysize, SDL_assert, SDL_AUDIO_ALLOW_CHANNELS_CHANGE, SDL_AUDIO_ALLOW_FORMAT_CHANGE, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE, SDL_AUDIOBUFFERQUEUE_PACKETLEN, SDL_BufferQueueDrainCallback(), SDL_BuildAudioCVT, SDL_CalculateAudioSpec(), SDL_CloseAudioDevice(), SDL_CreateMutex, SDL_CreateThread, SDL_FALSE, SDL_getenv, SDL_INIT_AUDIO, SDL_LockMutex, SDL_malloc, SDL_OutOfMemory, SDL_RunAudio(), SDL_SetError, SDL_snprintf, SDL_strcmp, SDL_TRUE, SDL_UnlockMutex, SDL_WasInit, SDL_zerop, SDL_AudioSpec::size, SDL_AudioDriverImpl::SkipMixerLock, SDL_AudioDevice::spec, SDL_AudioBufferQueue::startpos, SDL_AudioDevice::thread, and SDL_AudioSpec::userdata.
Referenced by SDL_OpenAudio(), and SDL_OpenAudioDevice().
|
static |
Definition at line 905 of file SDL_audio.c.
References AUDIO_S16, SDL_AudioSpec::channels, SDL_AudioSpec::format, SDL_AudioSpec::freq, SDL_AudioSpec::samples, SDL_atoi, SDL_CalculateAudioSpec(), SDL_getenv, SDL_memcpy, SDL_ParseAudioFormat(), and SDL_SetError.
Referenced by open_audio_device().
Definition at line 347 of file SDL_audio.c.
References add_capture_device(), add_output_device(), SDL_AUDIODEVICEADDED, SDL_ENABLE, SDL_GetEventState, SDL_PushEvent, and SDL_zero.
Referenced by SDL_AudioDetectDevices_Default().
Definition at line 209 of file SDL_audio.c.
Definition at line 214 of file SDL_audio.c.
Definition at line 164 of file SDL_audio.c.
References DEFAULT_INPUT_DEVNAME, DEFAULT_OUTPUT_DEVNAME, SDL_AudioDriverImpl::HasCaptureSupport, SDL_AudioDriver::impl, SDL_AudioDriverImpl::OnlyHasDefaultInputDevice, SDL_AudioDriverImpl::OnlyHasDefaultOutputDevice, SDL_AddAudioDevice(), SDL_assert, SDL_FALSE, and SDL_TRUE.
Definition at line 219 of file SDL_audio.c.
Definition at line 198 of file SDL_audio.c.
References NULL.
|
static |
Definition at line 192 of file SDL_audio.c.
int SDL_AudioInit | ( | const char * | driver_name | ) |
Definition at line 711 of file SDL_audio.c.
References AudioBootStrap::demand_only, SDL_AudioDriver::desc, AudioBootStrap::desc, SDL_AudioDriverImpl::DetectDevices, SDL_AudioDriver::detectionLock, finalize_audio_entry_points(), i, SDL_AudioDriver::impl, AudioBootStrap::init, SDL_AudioDriver::name, AudioBootStrap::name, NULL, SDL_AudioQuit(), SDL_CreateMutex, SDL_getenv, SDL_INIT_AUDIO, SDL_SetError, SDL_strlen, SDL_strncasecmp, SDL_WasInit, and SDL_zero.
|
static |
Definition at line 245 of file SDL_audio.c.
References is_in_audio_device_thread(), SDL_AudioDevice::mixer_lock, and SDL_LockMutex.
|
static |
Definition at line 187 of file SDL_audio.c.
Definition at line 1345 of file SDL_audio.c.
References SDL_AudioDriverImpl::Deinitialize, SDL_AudioDriver::detectionLock, free_device_list(), i, SDL_AudioDriver::impl, SDL_AudioDriver::inputDeviceCount, SDL_AudioDriver::inputDevices, SDL_AudioDriver::name, NULL, SDL_AudioDriver::outputDeviceCount, SDL_AudioDriver::outputDevices, SDL_arraysize, SDL_CloseAudioDevice(), SDL_DestroyMutex, and SDL_zero.
Referenced by SDL_AudioInit().
Definition at line 177 of file SDL_audio.c.
|
static |
Definition at line 253 of file SDL_audio.c.
References is_in_audio_device_thread(), SDL_AudioDevice::mixer_lock, and SDL_UnlockMutex.
Definition at line 182 of file SDL_audio.c.
Definition at line 204 of file SDL_audio.c.
Definition at line 433 of file SDL_audio.c.
References SDL_AudioDevice::buffer_queue_head, SDL_AudioDevice::buffer_queue_pool, SDL_AudioDevice::buffer_queue_tail, SDL_AudioBufferQueue::data, SDL_AudioBufferQueue::datalen, SDL_AudioBufferQueue::next, NULL, SDL_AudioDevice::queued_bytes, SDL_assert, SDL_memcpy, SDL_memset, SDL_min, SDL_AudioSpec::silence, SDL_AudioDevice::spec, and SDL_AudioBufferQueue::startpos.
Referenced by open_audio_device(), SDL_GetQueuedAudioSize(), and SDL_QueueAudio().
void SDL_CalculateAudioSpec | ( | SDL_AudioSpec * | spec | ) |
Definition at line 1419 of file SDL_audio.c.
References AUDIO_U8, SDL_AudioSpec::channels, SDL_AudioSpec::format, SDL_AudioSpec::samples, SDL_AUDIO_BITSIZE, SDL_AudioSpec::silence, and SDL_AudioSpec::size.
Referenced by open_audio_device(), and prepare_audiospec().
void SDL_ClearQueuedAudio | ( | SDL_AudioDeviceID | dev | ) |
Drop any queued audio data waiting to be sent to the hardware.
Immediately after this call, SDL_GetQueuedAudioSize() will return 0 and the hardware will start playing silence if more audio isn't queued.
This will not prevent playback of queued audio that's already been sent to the hardware, as we can not undo that, so expect there to be some fraction of a second of audio that might still be heard. This can be useful if you want to, say, drop any pending music during a level change in your game.
You may not queue audio on a device that is using an application-supplied callback; calling this function on such a device is always a no-op. You have to use the audio callback or queue audio with SDL_QueueAudio(), but not both.
You should not call SDL_LockAudio() on the device before clearing the queue; SDL handles locking internally for this function.
This function always succeeds and thus returns void.
dev | The device ID of which to clear the audio queue. |
Definition at line 573 of file SDL_audio.c.
References SDL_AudioDevice::buffer_queue_head, SDL_AudioDevice::buffer_queue_tail, free_audio_queue(), get_audio_device(), SDL_AudioDriver::impl, SDL_AudioDriverImpl::LockDevice, NULL, SDL_AudioDevice::queued_bytes, SDLCALL, and SDL_AudioDriverImpl::UnlockDevice.
This function shuts down audio processing and closes the audio device.
Definition at line 1339 of file SDL_audio.c.
References SDL_CloseAudioDevice().
void SDL_CloseAudioDevice | ( | SDL_AudioDeviceID | devid | ) |
Definition at line 1329 of file SDL_audio.c.
References close_audio_device(), get_audio_device(), and NULL.
Referenced by open_audio_device(), SDL_AudioQuit(), and SDL_CloseAudio().
SDL_AudioFormat SDL_FirstAudioFormat | ( | SDL_AudioFormat | format | ) |
Definition at line 1398 of file SDL_audio.c.
References format_idx, format_idx_sub, format_list, NUM_FORMATS, and SDL_NextAudioFormat().
const char* SDL_GetAudioDeviceName | ( | int | index, |
int | iscapture | ||
) |
Get the human-readable name of a specific audio device. Must be a value between 0 and (number of audio devices-1). Only valid after a successfully initializing the audio subsystem. The values returned by this function reflect the latest call to SDL_GetNumAudioDevices(); recall that function to redetect available hardware.
The string returned by this function is UTF-8 encoded, read-only, and managed internally. You are not to free it. If you need to keep the string for any length of time, you should make your own copy of it, as it will be invalid next time any of several other SDL functions is called.
Definition at line 833 of file SDL_audio.c.
References SDL_AudioDriver::detectionLock, SDL_AudioDriverImpl::HasCaptureSupport, i, SDL_AudioDriver::impl, SDL_AudioDriver::inputDeviceCount, SDL_AudioDriver::inputDevices, SDL_AudioDeviceItem::next, NULL, SDL_AudioDriver::outputDeviceCount, SDL_AudioDriver::outputDevices, retval, SDL_assert, SDL_INIT_AUDIO, SDL_LockMutex, SDL_SetError, SDL_UnlockMutex, and SDL_WasInit.
SDL_AudioStatus SDL_GetAudioDeviceStatus | ( | SDL_AudioDeviceID | devid | ) |
Definition at line 1257 of file SDL_audio.c.
References SDL_AudioDevice::enabled, get_audio_device(), SDL_AudioDevice::paused, SDL_AUDIO_PAUSED, SDL_AUDIO_PLAYING, and SDL_AUDIO_STOPPED.
Referenced by SDL_GetAudioStatus().
const char* SDL_GetAudioDriver | ( | int | index | ) |
Definition at line 702 of file SDL_audio.c.
References AudioBootStrap::name, NULL, and SDL_GetNumAudioDrivers().
SDL_AudioStatus SDL_GetAudioStatus | ( | void | ) |
Definition at line 1273 of file SDL_audio.c.
References SDL_GetAudioDeviceStatus().
const char* SDL_GetCurrentAudioDriver | ( | void | ) |
This function returns the name of the current audio driver, or NULL if no driver has been initialized.
Definition at line 772 of file SDL_audio.c.
References SDL_AudioDriver::name.
int SDL_GetNumAudioDevices | ( | int | iscapture | ) |
Get the number of available devices exposed by the current driver. Only valid after a successfully initializing the audio subsystem. Returns -1 if an explicit list of devices can't be determined; this is not an error. For example, if SDL is set up to talk to a remote audio server, it can't list every one available on the Internet, but it will still allow a specific host to be specified to SDL_OpenAudioDevice().
In many common cases, when this function returns a value <= 0, it can still successfully open the default device (NULL for first argument of SDL_OpenAudioDevice()).
Definition at line 807 of file SDL_audio.c.
References SDL_AudioDriver::captureDevicesRemoved, clean_out_device_list(), SDL_AudioDriver::detectionLock, SDL_AudioDriver::inputDeviceCount, SDL_AudioDriver::inputDevices, SDL_AudioDriver::outputDeviceCount, SDL_AudioDriver::outputDevices, SDL_AudioDriver::outputDevicesRemoved, retval, SDL_FALSE, SDL_INIT_AUDIO, SDL_LockMutex, SDL_UnlockMutex, and SDL_WasInit.
int SDL_GetNumAudioDrivers | ( | void | ) |
Definition at line 696 of file SDL_audio.c.
References SDL_arraysize.
Referenced by SDL_GetAudioDriver().
Uint32 SDL_GetQueuedAudioSize | ( | SDL_AudioDeviceID | dev | ) |
Get the number of bytes of still-queued audio.
This is the number of bytes that have been queued for playback with SDL_QueueAudio(), but have not yet been sent to the hardware.
Once we've sent it to the hardware, this function can not decide the exact byte boundary of what has been played. It's possible that we just gave the hardware several kilobytes right before you called this function, but it hasn't played any of it yet, or maybe half of it, etc.
You may not queue audio on a device that is using an application-supplied callback; calling this function on such a device always returns 0. You have to use the audio callback or queue audio with SDL_QueueAudio(), but not both.
You should not call SDL_LockAudio() on the device before querying; SDL handles locking internally for this function.
dev | The device ID of which we will query queued audio size. |
Definition at line 557 of file SDL_audio.c.
References SDL_AudioSpec::callback, get_audio_device(), SDL_AudioDriverImpl::GetPendingBytes, SDL_AudioDriver::impl, SDL_AudioDriverImpl::LockDevice, SDL_AudioDevice::queued_bytes, retval, SDL_BufferQueueDrainCallback(), SDL_AudioDevice::spec, and SDL_AudioDriverImpl::UnlockDevice.
void SDL_LockAudioDevice | ( | SDL_AudioDeviceID | devid | ) |
Definition at line 1297 of file SDL_audio.c.
References get_audio_device(), SDL_AudioDriver::impl, and SDL_AudioDriverImpl::LockDevice.
Referenced by SDL_LockAudio().
This takes two audio buffers of the playing audio format and mixes them, performing addition, volume adjustment, and overflow clipping. The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME for full audio volume. Note this does not change hardware volume. This is provided for convenience – you can mix your own audio data.
Definition at line 1440 of file SDL_audio.c.
References SDL_AudioDevice::convert, SDL_AudioSpec::format, get_audio_device(), SDL_AudioCVT::needed, NULL, SDL_MixAudioFormat, SDL_AudioDevice::spec, and SDL_AudioCVT::src_format.
SDL_AudioFormat SDL_NextAudioFormat | ( | void | ) |
Definition at line 1410 of file SDL_audio.c.
References format_idx, format_idx_sub, format_list, and NUM_FORMATS.
Referenced by SDL_FirstAudioFormat().
int SDL_OpenAudio | ( | SDL_AudioSpec * | desired, |
SDL_AudioSpec * | obtained | ||
) |
This function opens the audio device with the desired parameters, and returns 0 if successful, placing the actual hardware parameters in the structure pointed to by obtained
. If obtained
is NULL, the audio data passed to the callback function will be guaranteed to be in the requested format, and will be automatically converted to the hardware audio format if necessary. This function returns -1 if it failed to open the audio device, or couldn't set up the audio thread.
When filling in the desired audio spec structure,
desired->freq
should be the desired audio frequency in samples-per- second.desired->format
should be the desired audio format.desired->samples
is the desired size of the audio buffer, in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware. Good values seem to range between 512 and 8096 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula:desired->size
is the size in bytes of the audio buffer, and is calculated by SDL_OpenAudio().desired->silence
is the value used to set the buffer to silence, and is calculated by SDL_OpenAudio().desired->callback
should be set to a function that will be called when the audio device is ready for more data. It is passed a pointer to the audio buffer, and the length in bytes of the audio buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling SDL_LockAudio() and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL pointer here, and call SDL_QueueAudio() with some frequency, to queue more audio samples to be played.desired->userdata
is passed as the first parameter to your callback function. If you passed a NULL callback, this value is ignored.The audio device starts out playing silence when it's opened, and should be enabled for playing by calling SDL_PauseAudio(0)
when you are ready for your audio callback function to be called. Since the audio driver may modify the requested size of the audio buffer, you should allocate any local mixing buffers after you open the audio device.
Definition at line 1219 of file SDL_audio.c.
References NULL, open_audio_device(), SDL_assert, SDL_AUDIO_ALLOW_ANY_CHANGE, SDL_INIT_AUDIO, SDL_InitSubSystem, SDL_SetError, and SDL_WasInit.
SDL_AudioDeviceID SDL_OpenAudioDevice | ( | const char * | device, |
int | iscapture, | ||
const SDL_AudioSpec * | desired, | ||
SDL_AudioSpec * | obtained, | ||
int | allowed_changes | ||
) |
Open a specific audio device. Passing in a device name of NULL requests the most reasonable default (and is equivalent to calling SDL_OpenAudio()).
The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but some drivers allow arbitrary and driver-specific strings, such as a hostname/IP address for a remote audio server, or a filename in the diskaudio driver.
SDL_OpenAudio(), unlike this function, always acts on device ID 1.
Definition at line 1248 of file SDL_audio.c.
References open_audio_device().
void SDL_OpenedAudioDeviceDisconnected | ( | SDL_AudioDevice * | device | ) |
Definition at line 364 of file SDL_audio.c.
References SDL_AudioDevice::enabled, get_audio_device(), SDL_AudioDevice::id, SDL_AudioDriver::impl, SDL_AudioDevice::iscapture, SDL_AudioDriverImpl::LockDevice, SDL_assert, SDL_AUDIODEVICEREMOVED, SDL_ENABLE, SDL_GetEventState, SDL_PushEvent, SDL_zero, and SDL_AudioDriverImpl::UnlockDevice.
|
static |
Definition at line 670 of file SDL_audio.c.
References CHECK_FMT_STRING, and S32.
Referenced by prepare_audiospec().
void SDL_PauseAudio | ( | int | pause_on | ) |
Definition at line 1290 of file SDL_audio.c.
References SDL_PauseAudioDevice().
void SDL_PauseAudioDevice | ( | SDL_AudioDeviceID | devid, |
int | pause_on | ||
) |
Definition at line 1279 of file SDL_audio.c.
References get_audio_device(), SDL_AudioDriver::impl, SDL_AudioDriverImpl::LockDevice, SDL_AudioDevice::paused, and SDL_AudioDriverImpl::UnlockDevice.
Referenced by SDL_PauseAudio().
int SDL_QueueAudio | ( | SDL_AudioDeviceID | dev, |
const void * | data, | ||
Uint32 | len | ||
) |
Queue more audio on non-callback devices.
SDL offers two ways to feed audio to the device: you can either supply a callback that SDL triggers with some frequency to obtain more audio (pull method), or you can supply no callback, and then SDL will expect you to supply data at regular intervals (push method) with this function.
There are no limits on the amount of data you can queue, short of exhaustion of address space. Queued data will drain to the device as necessary without further intervention from you. If the device needs audio but there is not enough queued, it will play silence to make up the difference. This means you will have skips in your audio playback if you aren't routinely queueing sufficient data.
This function copies the supplied data, so you are safe to free it when the function returns. This function is thread-safe, but queueing to the same device from two threads at once does not promise which buffer will be queued first.
You may not queue audio on a device that is using an application-supplied callback; doing so returns an error. You have to use the audio callback or queue audio with this function, but not both.
You should not call SDL_LockAudio() on the device before queueing; SDL handles locking internally for this function.
dev | The device ID to which we will queue audio. |
data | The data to queue to the device for later playback. |
len | The number of bytes (not samples!) to which (data) points. |
Definition at line 475 of file SDL_audio.c.
References SDL_AudioDevice::buffer_queue_head, SDL_AudioDevice::buffer_queue_pool, SDL_AudioDevice::buffer_queue_tail, SDL_AudioSpec::callback, SDL_AudioBufferQueue::data, SDL_AudioBufferQueue::datalen, free_audio_queue(), get_audio_device(), SDL_AudioDriver::impl, SDL_AudioDriverImpl::LockDevice, SDL_AudioBufferQueue::next, NULL, SDL_AudioDevice::queued_bytes, SDL_assert, SDL_AUDIOBUFFERQUEUE_PACKETLEN, SDL_BufferQueueDrainCallback(), SDL_malloc, SDL_memcpy, SDL_min, SDL_OutOfMemory, SDL_SetError, SDL_AudioDevice::spec, SDL_AudioBufferQueue::startpos, and SDL_AudioDriverImpl::UnlockDevice.
Definition at line 405 of file SDL_audio.c.
References SDL_AudioDriver::captureDevicesRemoved, SDL_AudioDriver::detectionLock, SDL_AudioDriverImpl::FreeDeviceHandle, SDL_AudioDriver::impl, SDL_AudioDriver::inputDevices, mark_device_removed(), SDL_AudioDriver::outputDevices, SDL_AudioDriver::outputDevicesRemoved, SDL_LockMutex, and SDL_UnlockMutex.
int SDL_RunAudio | ( | void * | devicep | ) |
Definition at line 595 of file SDL_audio.c.
References SDL_AudioCVT::buf, SDL_AudioSpec::callback, SDL_AudioDevice::convert, SDL_AudioDevice::enabled, SDL_AudioDevice::fake_stream, SDL_AudioSpec::freq, SDL_AudioDriverImpl::GetDeviceBuf, SDL_AudioDriver::impl, SDL_AudioCVT::len, SDL_AudioCVT::len_cvt, SDL_AudioDevice::mixer_lock, SDL_AudioCVT::needed, NULL, SDL_AudioDevice::paused, SDL_AudioDriverImpl::PlayDevice, SDL_AudioSpec::samples, SDL_ConvertAudio, SDL_Delay, SDL_LockMutex, SDL_memcpy, SDL_memset, SDL_SetThreadPriority, SDL_THREAD_PRIORITY_HIGH, SDL_ThreadID, SDL_UnlockMutex, SDLCALL, SDL_AudioDevice::shutdown, SDL_AudioSpec::silence, SDL_AudioSpec::size, SDL_AudioDevice::spec, SDL_AudioDevice::threadid, SDL_AudioDriverImpl::ThreadInit, SDL_AudioSpec::userdata, void, SDL_AudioDriverImpl::WaitDevice, and SDL_AudioDriverImpl::WaitDone.
Referenced by open_audio_device().
Definition at line 1323 of file SDL_audio.c.
References SDL_UnlockAudioDevice().
void SDL_UnlockAudioDevice | ( | SDL_AudioDeviceID | devid | ) |
Definition at line 1313 of file SDL_audio.c.
References get_audio_device(), SDL_AudioDriver::impl, and SDL_AudioDriverImpl::UnlockDevice.
Referenced by SDL_UnlockAudio().
AudioBootStrap ALSA_bootstrap |
AudioBootStrap ANDROIDAUD_bootstrap |
AudioBootStrap ARTS_bootstrap |
|
static |
Definition at line 76 of file SDL_audio.c.
AudioBootStrap BSD_AUDIO_bootstrap |
AudioBootStrap COREAUDIO_bootstrap |
|
static |
Definition at line 33 of file SDL_audio.c.
AudioBootStrap DART_bootstrap |
AudioBootStrap DCAUD_bootstrap |
AudioBootStrap DISKAUD_bootstrap |
AudioBootStrap DSOUND_bootstrap |
AudioBootStrap DSP_bootstrap |
AudioBootStrap DUMMYAUD_bootstrap |
Definition at line 44 of file SDL_dummyaudio.c.
AudioBootStrap EmscriptenAudio_bootstrap |
AudioBootStrap ESD_bootstrap |
|
static |
Definition at line 1372 of file SDL_audio.c.
Referenced by SDL_FirstAudioFormat(), and SDL_NextAudioFormat().
|
static |
Definition at line 1373 of file SDL_audio.c.
Referenced by SDL_FirstAudioFormat(), and SDL_NextAudioFormat().
|
static |
Definition at line 1374 of file SDL_audio.c.
Referenced by SDL_FirstAudioFormat(), and SDL_NextAudioFormat().
AudioBootStrap FUSIONSOUND_bootstrap |
AudioBootStrap HAIKUAUDIO_bootstrap |
AudioBootStrap NACLAUD_bootstrap |
AudioBootStrap NAS_bootstrap |
AudioBootStrap NDSAUD_bootstrap |
|
static |
Definition at line 34 of file SDL_audio.c.
AudioBootStrap PAUDIO_bootstrap |
AudioBootStrap PSPAUD_bootstrap |
AudioBootStrap PULSEAUDIO_bootstrap |
AudioBootStrap QSAAUDIO_bootstrap |
AudioBootStrap SNDIO_bootstrap |
AudioBootStrap SNDMGR_bootstrap |
AudioBootStrap SUNAUDIO_bootstrap |
AudioBootStrap WINMM_bootstrap |
AudioBootStrap XAUDIO2_bootstrap |