zenilib
0.5.3.0
|
#include "SDL_config.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 | CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x |
#define | DEFAULT_INPUT_DEVNAME "System audio capture device" |
#define | DEFAULT_OUTPUT_DEVNAME "System audio output device" |
#define | FILL_STUB(x) |
#define | NUM_FORMATS 10 |
#define _THIS SDL_AudioDevice *_this |
Definition at line 31 of file SDL_audio.c.
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_GetAudioDeviceName().
#define DEFAULT_OUTPUT_DEVNAME "System audio output device" |
Definition at line 37 of file SDL_audio.c.
Referenced by open_audio_device(), and SDL_GetAudioDeviceName().
#define FILL_STUB | ( | x | ) |
Referenced by finalize_audio_entry_points().
#define NUM_FORMATS 10 |
Definition at line 1199 of file SDL_audio.c.
Referenced by SDL_FirstAudioFormat(), and SDL_NextAudioFormat().
|
static |
Definition at line 751 of file SDL_audio.c.
References SDL_AudioCVT::buf, SDL_AudioDriverImpl::CloseDevice, SDL_AudioDevice::convert, SDL_AudioDevice::enabled, SDL_AudioDevice::fake_stream, SDL_AudioDriver::impl, SDL_AudioDevice::mixer_lock, SDL_AudioCVT::needed, NULL, SDL_AudioDevice::opened, SDL_DestroyMutex(), SDL_FreeAudioMem, SDL_WaitThread(), and SDL_AudioDevice::thread.
Referenced by open_audio_device(), and SDL_CloseAudioDevice().
Definition at line 624 of file SDL_audio.c.
References i, NULL, and SDL_free().
Referenced by SDL_AudioQuit(), and SDL_GetNumAudioDevices().
|
static |
Definition at line 141 of file SDL_audio.c.
References NULL, SDL_arraysize, and SDL_SetError().
Referenced by SDL_CloseAudioDevice(), SDL_GetAudioDeviceStatus(), SDL_LockAudioDevice(), SDL_MixAudio(), SDL_PauseAudioDevice(), and SDL_UnlockAudioDevice().
|
static |
Definition at line 841 of file SDL_audio.c.
References SDL_AudioCVT::buf, SDL_AudioSpec::channels, close_audio_device(), SDL_AudioDevice::convert, DEFAULT_INPUT_DEVNAME, DEFAULT_OUTPUT_DEVNAME, SDL_AudioDevice::enabled, SDL_AudioDevice::fake_stream, SDL_AudioSpec::format, SDL_AudioSpec::freq, SDL_AudioDriverImpl::HasCaptureSupport, i, SDL_AudioDriver::impl, SDL_AudioDriver::inputDevices, int, SDL_AudioDevice::iscapture, SDL_AudioCVT::len, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, SDL_AudioDevice::mixer_lock, SDL_AudioCVT::needed, 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_AUDIO_ALLOW_CHANNELS_CHANGE, SDL_AUDIO_ALLOW_FORMAT_CHANGE, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE, SDL_BuildAudioCVT(), SDL_CalculateAudioSpec(), SDL_CloseAudioDevice(), SDL_CreateMutex(), SDL_CreateThread(), SDL_FALSE, SDL_getenv(), SDL_GetNumAudioDevices(), SDL_INIT_AUDIO, SDL_memset(), SDL_OutOfMemory, SDL_RunAudio(), SDL_SetError(), SDL_snprintf(), SDL_strcmp(), SDL_TRUE, SDL_WasInit(), SDL_AudioSpec::size, SDL_AudioDriverImpl::SkipMixerLock, SDL_AudioDevice::spec, and SDL_AudioDevice::thread.
Referenced by SDL_OpenAudio(), and SDL_OpenAudioDevice().
|
static |
Definition at line 778 of file SDL_audio.c.
References AUDIO_S16, SDL_AudioSpec::callback, SDL_AudioSpec::channels, env, SDL_AudioSpec::format, SDL_AudioSpec::freq, NULL, SDL_AudioSpec::samples, SDL_atoi(), SDL_CalculateAudioSpec(), SDL_getenv(), SDL_memcpy(), SDL_ParseAudioFormat(), and SDL_SetError().
Referenced by open_audio_device().
Definition at line 640 of file SDL_audio.c.
References SDL_AudioDriver::inputDeviceCount, SDL_AudioDriver::inputDevices, NULL, SDL_realloc(), and SDL_strdup().
Referenced by SDL_GetNumAudioDevices().
Definition at line 655 of file SDL_audio.c.
References NULL, SDL_AudioDriver::outputDeviceCount, SDL_AudioDriver::outputDevices, SDL_realloc(), and SDL_strdup().
Referenced by SDL_GetNumAudioDevices().
Definition at line 186 of file SDL_audio.c.
Definition at line 191 of file SDL_audio.c.
|
static |
Definition at line 155 of file SDL_audio.c.
Definition at line 175 of file SDL_audio.c.
References NULL.
Definition at line 562 of file SDL_audio.c.
References AudioBootStrap::demand_only, SDL_AudioDriver::desc, AudioBootStrap::desc, finalize_audio_entry_points(), i, SDL_AudioDriver::impl, AudioBootStrap::init, SDL_AudioDriver::name, AudioBootStrap::name, NULL, SDL_AudioQuit(), SDL_getenv(), SDL_INIT_AUDIO, SDL_memset(), SDL_SetError(), SDL_strlen(), SDL_strncasecmp(), and SDL_WasInit().
Referenced by SDL_InitSubSystem(), and SDLTest_CommonInit().
|
static |
Definition at line 202 of file SDL_audio.c.
References SDL_AudioDevice::mixer_lock, SDL_LockMutex(), SDL_ThreadID(), SDL_AudioDevice::thread, and SDL_AudioDevice::threadid.
Definition at line 196 of file SDL_audio.c.
Definition at line 170 of file SDL_audio.c.
Definition at line 1175 of file SDL_audio.c.
References SDL_AudioDriverImpl::Deinitialize, 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(), and SDL_memset().
Referenced by SDL_AudioInit(), SDL_QuitSubSystem(), and SDLTest_CommonQuit().
Definition at line 160 of file SDL_audio.c.
|
static |
Definition at line 211 of file SDL_audio.c.
References SDL_AudioDevice::mixer_lock, SDL_ThreadID(), SDL_UnlockMutex(), SDL_AudioDevice::thread, and SDL_AudioDevice::threadid.
Definition at line 165 of file SDL_audio.c.
Definition at line 181 of file SDL_audio.c.
void SDL_CalculateAudioSpec | ( | SDL_AudioSpec * | spec | ) |
Definition at line 1247 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(), prepare_audiospec(), and prepare_audiounit().
This function shuts down audio processing and closes the audio device.
Definition at line 1169 of file SDL_audio.c.
References SDL_CloseAudioDevice().
void SDL_CloseAudioDevice | ( | SDL_AudioDeviceID | devid | ) |
Definition at line 1159 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 1226 of file SDL_audio.c.
References format_idx, NUM_FORMATS, and SDL_NextAudioFormat().
Referenced by COREAUDIO_OpenDevice().
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 708 of file SDL_audio.c.
References DEFAULT_INPUT_DEVNAME, DEFAULT_OUTPUT_DEVNAME, SDL_AudioDriverImpl::HasCaptureSupport, SDL_AudioDriver::impl, SDL_AudioDriver::inputDeviceCount, SDL_AudioDriver::inputDevices, NULL, SDL_AudioDriverImpl::OnlyHasDefaultInputDevice, SDL_AudioDriverImpl::OnlyHasDefaultOutputDevice, SDL_AudioDriver::outputDeviceCount, SDL_AudioDriver::outputDevices, SDL_INIT_AUDIO, SDL_SetError(), and SDL_WasInit().
SDL_AudioStatus SDL_GetAudioDeviceStatus | ( | SDL_AudioDeviceID | devid | ) |
Definition at line 1087 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().
Definition at line 553 of file SDL_audio.c.
References NULL, and SDL_GetNumAudioDrivers().
Referenced by SDLTest_CommonInit().
SDL_AudioStatus SDL_GetAudioStatus | ( | void | ) |
Definition at line 1103 of file SDL_audio.c.
References SDL_GetAudioDeviceStatus().
This function returns the name of the current audio driver, or NULL if no driver has been initialized.
Definition at line 618 of file SDL_audio.c.
References SDL_AudioDriver::name.
Referenced by SDLTest_CommonInit().
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 671 of file SDL_audio.c.
References SDL_AudioDriverImpl::DetectDevices, free_device_list(), SDL_AudioDriverImpl::HasCaptureSupport, SDL_AudioDriver::impl, SDL_AudioDriver::inputDeviceCount, SDL_AudioDriver::inputDevices, SDL_AudioDriverImpl::OnlyHasDefaultInputDevice, SDL_AudioDriverImpl::OnlyHasDefaultOutputDevice, SDL_AudioDriver::outputDeviceCount, SDL_AudioDriver::outputDevices, SDL_AddCaptureAudioDevice(), SDL_AddOutputAudioDevice(), SDL_INIT_AUDIO, and SDL_WasInit().
Referenced by open_audio_device().
Definition at line 547 of file SDL_audio.c.
References SDL_arraysize.
Referenced by SDL_GetAudioDriver(), and SDLTest_CommonInit().
Definition at line 1137 of file SDL_audio.c.
References SDL_LockAudioDevice().
void SDL_LockAudioDevice | ( | SDL_AudioDeviceID | devid | ) |
Definition at line 1127 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 1268 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 1238 of file SDL_audio.c.
References 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.desired->userdata
is passed as the first parameter to your callback function.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 1049 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().
Referenced by SDLTest_CommonInit().
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 1078 of file SDL_audio.c.
References open_audio_device().
|
static |
Definition at line 521 of file SDL_audio.c.
References CHECK_FMT_STRING, and S32.
Referenced by prepare_audiospec().
Definition at line 1120 of file SDL_audio.c.
References SDL_PauseAudioDevice().
void SDL_PauseAudioDevice | ( | SDL_AudioDeviceID | devid, |
int | pause_on | ||
) |
Definition at line 1109 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().
Definition at line 312 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, int, SDL_AudioCVT::len, SDL_AudioCVT::len_cvt, SDL_AudioCVT::len_mult, 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_StreamDeinit(), SDL_StreamLength(), SDL_StreamRead(), SDL_StreamWrite(), SDL_THREAD_PRIORITY_HIGH, SDL_ThreadID(), SDL_UnlockMutex(), SDLCALL, SDL_AudioSpec::silence, SDL_AudioSpec::size, SDL_AudioDevice::spec, SDL_AudioDevice::streamer, SDL_AudioDevice::threadid, SDL_AudioDriverImpl::ThreadInit, SDL_AudioDevice::use_streamer, SDL_AudioSpec::userdata, SDL_AudioDriverImpl::WaitDevice, SDL_AudioDriverImpl::WaitDone, and while().
Referenced by open_audio_device().
|
static |
Definition at line 301 of file SDL_audio.c.
References SDL_AudioStreamer::buffer, and SDL_free().
Referenced by SDL_RunAudio().
|
static |
Definition at line 272 of file SDL_audio.c.
References SDL_AudioStreamer::max_len, SDL_AudioStreamer::read_pos, and SDL_AudioStreamer::write_pos.
Referenced by SDL_RunAudio().
|
static |
Definition at line 261 of file SDL_audio.c.
References SDL_AudioStreamer::buffer, i, and SDL_AudioStreamer::read_pos.
Referenced by SDL_RunAudio().
|
static |
Definition at line 249 of file SDL_audio.c.
References SDL_AudioStreamer::buffer, i, and SDL_AudioStreamer::write_pos.
Referenced by SDL_RunAudio().
Definition at line 1153 of file SDL_audio.c.
References SDL_UnlockAudioDevice().
void SDL_UnlockAudioDevice | ( | SDL_AudioDeviceID | devid | ) |
Definition at line 1143 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 |
AudioBootStrap BEOSAUDIO_bootstrap |
|
static |
Definition at line 73 of file SDL_audio.c.
AudioBootStrap BSD_AUDIO_bootstrap |
AudioBootStrap COREAUDIO_bootstrap |
Definition at line 555 of file SDL_coreaudio.c.
|
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 ESD_bootstrap |
|
static |
Definition at line 1200 of file SDL_audio.c.
Referenced by SDL_FirstAudioFormat().
|
static |
Definition at line 1201 of file SDL_audio.c.
|
static |
Definition at line 1202 of file SDL_audio.c.
AudioBootStrap FUSIONSOUND_bootstrap |
AudioBootStrap NAS_bootstrap |
AudioBootStrap NDSAUD_bootstrap |
|
static |
Definition at line 34 of file SDL_audio.c.
AudioBootStrap PAUDIO_bootstrap |
AudioBootStrap PSPAUD_bootstrap |
Definition at line 188 of file SDL_pspaudio.c.
AudioBootStrap PULSEAUDIO_bootstrap |
AudioBootStrap QSAAUDIO_bootstrap |
AudioBootStrap SNDIO_bootstrap |
AudioBootStrap SNDMGR_bootstrap |
AudioBootStrap SUNAUDIO_bootstrap |
AudioBootStrap WINMM_bootstrap |
AudioBootStrap XAUDIO2_bootstrap |