31 #define _THIS SDL_AudioDevice *_this
37 #define DEFAULT_OUTPUT_DEVNAME "System audio output device"
38 #define DEFAULT_INPUT_DEVNAME "System audio capture device"
74 #if SDL_AUDIO_DRIVER_PULSEAUDIO
77 #if SDL_AUDIO_DRIVER_ALSA
80 #if SDL_AUDIO_DRIVER_SNDIO
83 #if SDL_AUDIO_DRIVER_BSD
86 #if SDL_AUDIO_DRIVER_OSS
89 #if SDL_AUDIO_DRIVER_QSA
92 #if SDL_AUDIO_DRIVER_SUNAUDIO
95 #if SDL_AUDIO_DRIVER_ARTS
98 #if SDL_AUDIO_DRIVER_ESD
101 #if SDL_AUDIO_DRIVER_NAS
104 #if SDL_AUDIO_DRIVER_XAUDIO2
107 #if SDL_AUDIO_DRIVER_DSOUND
110 #if SDL_AUDIO_DRIVER_WINMM
113 #if SDL_AUDIO_DRIVER_PAUDIO
116 #if SDL_AUDIO_DRIVER_BEOSAUDIO
119 #if SDL_AUDIO_DRIVER_COREAUDIO
122 #if SDL_AUDIO_DRIVER_DISK
125 #if SDL_AUDIO_DRIVER_DUMMY
128 #if SDL_AUDIO_DRIVER_FUSIONSOUND
131 #if SDL_AUDIO_DRIVER_ANDROID
134 #if SDL_AUDIO_DRIVER_PSP
149 return open_devices[
id];
228 #define FILL_STUB(x) \
229 if (current_audio.impl.x == NULL) { \
230 current_audio.impl.x = SDL_Audio##x##_Default; \
307 #include <android/log.h>
343 stream_max_len = 2 * device->
spec.
size;
346 stream_max_len /= device->
convert.len_div;
348 if (SDL_StreamInit(&device->
streamer, stream_max_len, silence) <
404 if (istream ==
NULL) {
411 (*fill) (udata, istream, istream_len);
417 if (istream ==
NULL) {
439 if (stream ==
NULL) {
474 if (stream ==
NULL) {
483 (*fill) (udata,
stream, stream_len);
491 if (stream ==
NULL) {
523 #define CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x
542 #undef CHECK_FMT_STRING
556 return (bootstrap[index]->
name);
566 int tried_to_init = 0;
572 SDL_memset(¤t_audio,
'\0',
sizeof(current_audio));
573 SDL_memset(open_devices,
'\0',
sizeof(open_devices));
576 if (driver_name ==
NULL) {
580 for (i = 0; (!initialized) && (bootstrap[i]); ++
i) {
589 SDL_memset(¤t_audio, 0,
sizeof(current_audio));
592 initialized = backend->
init(¤t_audio.
impl);
597 if (!tried_to_init) {
599 SDL_SetError(
"Audio target '%s' not available", driver_name);
605 SDL_memset(¤t_audio, 0,
sizeof(current_audio));
620 return current_audio.
name;
627 if ((i > 0) && (*devices !=
NULL)) {
787 if (orig->
freq == 0) {
789 if ((!env) || ((prepared->
freq =
SDL_atoi(env)) == 0)) {
790 prepared->
freq = 22050;
826 while (power2 < samples) {
843 int allowed_changes,
int min_id)
862 obtained = &_obtained;
869 if (devname ==
NULL) {
870 devname =
SDL_getenv(
"SDL_AUDIO_DEVICE_NAME");
891 if ((open_devices[i]) && (open_devices[
i]->
iscapture)) {
906 if ((open_devices[i]) && (!open_devices[
i]->
iscapture)) {
914 if (device ==
NULL) {
919 device->
spec = *obtained;
939 if (current_audio.
impl.
OpenDevice(device, devname, iscapture) < 0) {
1012 for (
id = min_id - 1;
id <
SDL_arraysize(open_devices);
id++) {
1013 if (open_devices[
id] ==
NULL) {
1014 open_devices[
id] = device;
1029 SDL_snprintf(name,
sizeof (name),
"SDLAudioDev%d", (
int) (
id + 1));
1031 #if defined(__WIN32__) && !defined(HAVE_LIBC)
1032 #undef SDL_CreateThread
1061 if (open_devices[0] !=
NULL) {
1074 return ((
id == 0) ? -1 : 0);
1080 int allowed_changes)
1083 allowed_changes, 2);
1091 if (device && device->
enabled) {
1114 device->
paused = pause_on;
1164 open_devices[devid - 1] =
NULL;
1179 if (!current_audio.
name) {
1184 if (open_devices[i] !=
NULL) {
1195 SDL_memset(¤t_audio,
'\0',
sizeof(current_audio));
1196 SDL_memset(open_devices,
'\0',
sizeof(open_devices));
1199 #define NUM_FORMATS 10
1229 if (format_list[format_idx][0] == format) {
1243 return (format_list[format_idx][format_idx_sub++]);
1272 if (device !=
NULL) {
static SDL_AudioDevice * open_devices[16]
static int format_idx_sub
AudioBootStrap DISKAUD_bootstrap
void(* CloseDevice)(_THIS)
DECLSPEC void SDLCALL SDL_CloseAudio(void)
#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE
AudioBootStrap SUNAUDIO_bootstrap
SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format)
AudioBootStrap PSPAUD_bootstrap
DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void)
AudioBootStrap PULSEAUDIO_bootstrap
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
void(* SDL_AddAudioDevice)(const char *name)
void(* WaitDevice)(_THIS)
DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt,...)
DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex *mutex)
AudioBootStrap NDSAUD_bootstrap
AudioBootStrap QSAAUDIO_bootstrap
Uint8 *(* GetDeviceBuf)(_THIS)
DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void)
static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS]
DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size)
DECLSPEC void SDLCALL SDL_free(void *mem)
#define DEFAULT_INPUT_DEVNAME
int ProvidesOwnCallbackThread
AudioBootStrap DCAUD_bootstrap
DECLSPEC void SDLCALL SDL_UnlockAudio(void)
DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on)
EGLImageKHR EGLint * name
Uint16 SDL_AudioFormat
Audio format flags.
static void SDL_StreamRead(SDL_AudioStreamer *stream, Uint8 *buf, int length)
static Uint8 * SDL_AudioGetDeviceBuf_Default(_THIS)
AudioBootStrap DSOUND_bootstrap
static void SDL_AudioUnlockDevice_Default(SDL_AudioDevice *device)
DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void)
static SDL_AudioDriver current_audio
AudioBootStrap ARTS_bootstrap
static void finalize_audio_entry_points(void)
AudioBootStrap WINMM_bootstrap
int(* OpenDevice)(_THIS, const char *devname, int iscapture)
AudioBootStrap BSD_AUDIO_bootstrap
DECLSPEC void SDLCALL SDL_LockAudio(void)
DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex *mutex)
SDL_AudioFormat SDL_NextAudioFormat(void)
#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE
AudioBootStrap DART_bootstrap
DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev)
DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_AudioFormat src_format, Uint8 src_channels, int src_rate, SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate)
uint32_t Uint32
An unsigned 32-bit integer type.
#define DEFAULT_OUTPUT_DEVNAME
void(* PlayDevice)(_THIS)
DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status)
void(* DetectDevices)(int iscapture, SDL_AddAudioDevice addfn)
AudioBootStrap DUMMYAUD_bootstrap
static void SDL_AudioDeinitialize_Default(void)
DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags)
static void SDL_AddCaptureAudioDevice(const char *_name)
int OnlyHasDefaultOutputDevice
DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, int iscapture)
static void SDL_StreamDeinit(SDL_AudioStreamer *stream)
DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void)
DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev)
static void SDL_AddOutputAudioDevice(const char *_name)
DECLSPEC char *SDLCALL SDL_strdup(const char *str)
static void SDL_AudioWaitDevice_Default(_THIS)
DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index)
static void SDL_StreamWrite(SDL_AudioStreamer *stream, Uint8 *buf, int length)
#define SDL_AUDIO_BITSIZE(x)
DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags)
AudioBootStrap PAUDIO_bootstrap
DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void)
#define SDL_AUDIO_ALLOW_ANY_CHANGE
DECLSPEC void SDLCALL SDL_Delay(Uint32 ms)
Wait a specified number of milliseconds before returning.
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2)
DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on)
AudioBootStrap ALSA_bootstrap
void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
void(* Deinitialize)(void)
AudioBootStrap BEOSAUDIO_bootstrap
#define SDL_AllocAudioMem
SDL_AudioCallback callback
SDL_AudioFormat src_format
static void SDL_AudioThreadInit_Default(_THIS)
static int SDL_StreamLength(SDL_AudioStreamer *stream)
static void SDL_AudioDetectDevices_Default(int iscapture, SDL_AddAudioDevice addfn)
DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture)
DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev)
AudioBootStrap NAS_bootstrap
DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data)
AudioBootStrap COREAUDIO_bootstrap
#define SDL_assert(condition)
DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char *device, int iscapture, const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, int allowed_changes)
static const AudioBootStrap *const bootstrap[]
DECLSPEC size_t SDLCALL SDL_strlen(const char *str)
AudioBootStrap SNDMGR_bootstrap
static void SDL_AudioPlayDevice_Default(_THIS)
DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, Uint32 len, int volume)
#define SDL_OutOfMemory()
SDL_AudioStreamer streamer
#define SDL_arraysize(array)
AudioBootStrap DSP_bootstrap
static int SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture)
static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, int allowed_changes, int min_id)
void(* ThreadInit)(_THIS)
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
GLenum GLuint GLsizei const GLchar * buf
void(* LockDevice)(_THIS)
static void SDL_AudioLockDevice_Default(SDL_AudioDevice *device)
uint8_t Uint8
An unsigned 8-bit integer type.
int(* init)(SDL_AudioDriverImpl *impl)
DECLSPEC int SDLCALL SDL_atoi(const char *str)
AudioBootStrap XAUDIO2_bootstrap
DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev)
DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name)
int SDLCALL SDL_RunAudio(void *devicep)
#define SDL_AUDIO_ALLOW_FORMAT_CHANGE
static SDL_AudioFormat SDL_ParseAudioFormat(const char *string)
uint16_t Uint16
An unsigned 16-bit integer type.
static void free_device_list(char ***devices, int *devCount)
DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len)
DECLSPEC char *SDLCALL SDL_getenv(const char *name)
static void SDL_AudioCloseDevice_Default(_THIS)
DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex)
AudioBootStrap ESD_bootstrap
int OnlyHasDefaultInputDevice
DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority)
DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
static void SDL_AudioWaitDone_Default(_THIS)
DECLSPEC void SDLCALL SDL_AudioQuit(void)
AudioBootStrap ANDROIDAUD_bootstrap
void(* UnlockDevice)(_THIS)
#define CHECK_FMT_STRING(x)
static SDL_AudioDevice * get_audio_device(SDL_AudioDeviceID id)
DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt)
DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
AudioBootStrap SNDIO_bootstrap
static void close_audio_device(SDL_AudioDevice *device)
AudioBootStrap FUSIONSOUND_bootstrap