SDL_sysaudio.h File Reference
`#include "../SDL_internal.h"`
`#include "SDL_mutex.h"`
`#include "SDL_thread.h"`
`#include "../SDL_dataqueue.h"`
`#include "./SDL_audio_c.h"`
Include dependency graph for SDL_sysaudio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | SDL_AudioDriverImpl
struct | SDL_AudioDeviceItem
struct | SDL_AudioDriver
struct | SDL_AudioDevice
struct | AudioBootStrap

## Macros

#define | DEFAULT_OUTPUT_DEVNAME "System audio output device"
#define | DEFAULT_INPUT_DEVNAME "System audio capture device"
#define | _THIS SDL_AudioDevice *_this
#define | SDL_AUDIOBUFFERQUEUE_PACKETLEN (8 * 1024)

## Functions

void | SDL_AddAudioDevice (const int iscapture, const char *name, void *handle)
void | SDL_RemoveAudioDevice (const int iscapture, void *handle)
void | SDL_OpenedAudioDeviceDisconnected (SDL_AudioDevice *device)

## Variables

AudioBootStrap | PULSEAUDIO_bootstrap
AudioBootStrap | ALSA_bootstrap
AudioBootStrap | JACK_bootstrap
AudioBootStrap | SNDIO_bootstrap
AudioBootStrap | NETBSDAUDIO_bootstrap
AudioBootStrap | DSP_bootstrap
AudioBootStrap | QSAAUDIO_bootstrap
AudioBootStrap | SUNAUDIO_bootstrap
AudioBootStrap | ARTS_bootstrap
AudioBootStrap | ESD_bootstrap
AudioBootStrap | NACLAUDIO_bootstrap
AudioBootStrap | NAS_bootstrap
AudioBootStrap | WASAPI_bootstrap
AudioBootStrap | DSOUND_bootstrap
AudioBootStrap | WINMM_bootstrap
AudioBootStrap | PAUDIO_bootstrap
AudioBootStrap | HAIKUAUDIO_bootstrap
AudioBootStrap | COREAUDIO_bootstrap
AudioBootStrap | DISKAUDIO_bootstrap
AudioBootStrap | DUMMYAUDIO_bootstrap
AudioBootStrap | FUSIONSOUND_bootstrap
AudioBootStrap | ANDROIDAUDIO_bootstrap
AudioBootStrap | PSPAUDIO_bootstrap
AudioBootStrap | EMSCRIPTENAUDIO_bootstrap

## Macro Definition Documentation

## _THIS

#define _THIS SDL_AudioDevice *_this

Definition at line 37 of file SDL_sysaudio.h.

## DEFAULT_INPUT_DEVNAME

#define DEFAULT_INPUT_DEVNAME "System audio capture device"

Definition at line 33 of file SDL_sysaudio.h.

Referenced by open_audio_device(), and SDL_AudioDetectDevices_Default().

## DEFAULT_OUTPUT_DEVNAME

#define DEFAULT_OUTPUT_DEVNAME "System audio output device"

Definition at line 32 of file SDL_sysaudio.h.

Referenced by open_audio_device(), and SDL_AudioDetectDevices_Default().

## SDL_AUDIOBUFFERQUEUE_PACKETLEN

#define SDL_AUDIOBUFFERQUEUE_PACKETLEN (8 * 1024)

Definition at line 63 of file SDL_sysaudio.h.

Referenced by open_audio_device(), and SDL_ClearQueuedAudio().

## Function Documentation

## SDL_AddAudioDevice()

void SDL_AddAudioDevice | ( | const int | iscapture,
|  | const char * | name,
|  | void * | handle
| ) |  |

Definition at line 432 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().

{
const int device_index = iscapture ? add_capture_device(name, handle) : add_output_device(name, handle);
if (device_index != -1) {
/* Post the event, if desired */
if (SDL_GetEventState(SDL_AUDIODEVICEADDED) == SDL_ENABLE) {
SDL_Event event;
SDL_zero(event);
event.adevice.type = SDL_AUDIODEVICEADDED;
event.adevice.which = device_index;
event.adevice.iscapture = iscapture;
SDL_PushEvent(&event);
}
}
}
add_output_device
static SDL_INLINE int add_output_device(const char *name, void *handle)
Definition: SDL_audio.c:409
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:722
name
GLuint const GLchar * name
Definition: SDL_opengl_glext.h:660
SDL_AUDIODEVICEADDED
Definition: SDL_events.h:144
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
handle
EGLImageKHR EGLint EGLint * handle
Definition: eglext.h:937
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:125
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
add_capture_device
static SDL_INLINE int add_capture_device(const char *name, void *handle)
Definition: SDL_audio.c:402
SDL_Event
General event structure.
Definition: SDL_events.h:525

## SDL_OpenedAudioDeviceDisconnected()

void SDL_OpenedAudioDeviceDisconnected | ( | SDL_AudioDevice * | device | ) |

Definition at line 449 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_AtomicGet, SDL_AtomicSet, SDL_AUDIODEVICEREMOVED, SDL_ENABLE, SDL_GetEventState, SDL_PushEvent, SDL_zero, and SDL_AudioDriverImpl::UnlockDevice.

Referenced by SDL_CaptureAudio(), and SDL_RemoveAudioDevice().

{
SDL_assert(get_audio_device(device->id) == device);
if (!SDL_AtomicGet(&device->enabled)) {
return;
}
/* Ends the audio callback and mark the device as STOPPED, but the
app still needs to close the device to free resources. */
current_audio.impl.LockDevice(device);
SDL_AtomicSet(&device->enabled, 0);
current_audio.impl.UnlockDevice(device);
/* Post the event, if desired */
if (SDL_GetEventState(SDL_AUDIODEVICEREMOVED) == SDL_ENABLE) {
SDL_Event event;
SDL_zero(event);
event.adevice.type = SDL_AUDIODEVICEREMOVED;
event.adevice.which = device->id;
event.adevice.iscapture = device->iscapture ? 1 : 0;
SDL_PushEvent(&event);
}
}
SDL_AudioDevice::id
SDL_AudioDeviceID id
Definition: SDL_sysaudio.h:134
SDL_AudioDevice::enabled
SDL_atomic_t enabled
Definition: SDL_sysaudio.h:147
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:722
current_audio
static SDL_AudioDriver current_audio
Definition: SDL_audio.c:33
SDL_AudioDriverImpl::UnlockDevice
void(* UnlockDevice)(_THIS)
Definition: SDL_sysaudio.h:81
SDL_AUDIODEVICEREMOVED
Definition: SDL_events.h:145
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_AudioDevice::iscapture
SDL_bool iscapture
Definition: SDL_sysaudio.h:149
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:125
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
SDL_AudioDriverImpl::LockDevice
void(* LockDevice)(_THIS)
Definition: SDL_sysaudio.h:80
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_AudioDriver::impl
SDL_AudioDriverImpl impl
Definition: SDL_sysaudio.h:116
SDL_AtomicSet
#define SDL_AtomicSet
Definition: SDL_dynapi_overrides.h:67
SDL_AtomicGet
#define SDL_AtomicGet
Definition: SDL_dynapi_overrides.h:68
SDL_Event
General event structure.
Definition: SDL_events.h:525
get_audio_device
static SDL_AudioDevice * get_audio_device(SDL_AudioDeviceID id)
Definition: SDL_audio.c:197

## SDL_RemoveAudioDevice()

void SDL_RemoveAudioDevice | ( | const int | iscapture,
|  | void * | handle
| ) |  |

Definition at line 490 of file SDL_audio.c.

References SDL_AudioDriver::captureDevicesRemoved, SDL_AudioDriver::detectionLock, device, SDL_AudioDriverImpl::FreeDeviceHandle, SDL_AudioDevice::handle, SDL_AudioDriver::impl, SDL_AudioDriver::inputDevices, mark_device_removed(), NULL, SDL_AudioDriver::outputDevices, SDL_AudioDriver::outputDevicesRemoved, SDL_arraysize, SDL_LockMutex, SDL_OpenedAudioDeviceDisconnected(), SDL_UnlockMutex, and SDLCALL.

{
int device_index;
SDL_AudioDevice *device = NULL;
SDL_LockMutex(current_audio.detectionLock);
if (iscapture) {
mark_device_removed(handle, current_audio.inputDevices, &current_audio.captureDevicesRemoved);
} else {
mark_device_removed(handle, current_audio.outputDevices, &current_audio.outputDevicesRemoved);
}
for (device_index = 0; device_index < SDL_arraysize(open_devices); device_index++)
{
device = open_devices[device_index];
if (device != NULL && device->handle == handle)
{
SDL_OpenedAudioDeviceDisconnected(device);
break;
}
}
SDL_UnlockMutex(current_audio.detectionLock);
current_audio.impl.FreeDeviceHandle(handle);
}
open_devices
static SDL_AudioDevice * open_devices[16]
Definition: SDL_audio.c:34
SDL_LockMutex
#define SDL_LockMutex
Definition: SDL_dynapi_overrides.h:260
SDL_AudioDriver::captureDevicesRemoved
SDL_bool captureDevicesRemoved
Definition: SDL_sysaudio.h:120
mark_device_removed
static void mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag)
Definition: SDL_audio.c:475
SDL_OpenedAudioDeviceDisconnected
void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
Definition: SDL_audio.c:449
current_audio
static SDL_AudioDriver current_audio
Definition: SDL_audio.c:33
SDL_AudioDevice::handle
void * handle
Definition: SDL_sysaudio.h:171
SDL_AudioDriver::detectionLock
SDL_mutex * detectionLock
Definition: SDL_sysaudio.h:119
device
static SDL_AudioDeviceID device
Definition: loopwave.c:37
handle
EGLImageKHR EGLint EGLint * handle
Definition: eglext.h:937
SDL_AudioDriver::outputDevices
SDL_AudioDeviceItem * outputDevices
Definition: SDL_sysaudio.h:124
NULL
#define NULL
Definition: begin_code.h:164
SDL_AudioDriver::outputDevicesRemoved
SDL_bool outputDevicesRemoved
Definition: SDL_sysaudio.h:121
SDL_AudioDriver::impl
SDL_AudioDriverImpl impl
Definition: SDL_sysaudio.h:116
SDL_AudioDriverImpl::FreeDeviceHandle
void(* FreeDeviceHandle)(void *handle)
Definition: SDL_sysaudio.h:82
SDL_AudioDevice
Definition: SDL_sysaudio.h:130
SDL_UnlockMutex
#define SDL_UnlockMutex
Definition: SDL_dynapi_overrides.h:262
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93
SDL_AudioDriver::inputDevices
SDL_AudioDeviceItem * inputDevices
Definition: SDL_sysaudio.h:125

## Variable Documentation

## ALSA_bootstrap

AudioBootStrap ALSA_bootstrap

## ANDROIDAUDIO_bootstrap

AudioBootStrap ANDROIDAUDIO_bootstrap

## ARTS_bootstrap

AudioBootStrap ARTS_bootstrap

## COREAUDIO_bootstrap

AudioBootStrap COREAUDIO_bootstrap

## DISKAUDIO_bootstrap

AudioBootStrap DISKAUDIO_bootstrap

## DSOUND_bootstrap

AudioBootStrap DSOUND_bootstrap

## DSP_bootstrap

AudioBootStrap DSP_bootstrap

## DUMMYAUDIO_bootstrap

AudioBootStrap DUMMYAUDIO_bootstrap

Definition at line 61 of file SDL_dummyaudio.c.

## EMSCRIPTENAUDIO_bootstrap

AudioBootStrap EMSCRIPTENAUDIO_bootstrap

## ESD_bootstrap

AudioBootStrap ESD_bootstrap

## FUSIONSOUND_bootstrap

AudioBootStrap FUSIONSOUND_bootstrap

## HAIKUAUDIO_bootstrap

AudioBootStrap HAIKUAUDIO_bootstrap

## JACK_bootstrap

AudioBootStrap JACK_bootstrap

## NACLAUDIO_bootstrap

AudioBootStrap NACLAUDIO_bootstrap

## NAS_bootstrap

AudioBootStrap NAS_bootstrap

## NETBSDAUDIO_bootstrap

AudioBootStrap NETBSDAUDIO_bootstrap

## PAUDIO_bootstrap

AudioBootStrap PAUDIO_bootstrap

## PSPAUDIO_bootstrap

AudioBootStrap PSPAUDIO_bootstrap

## PULSEAUDIO_bootstrap

AudioBootStrap PULSEAUDIO_bootstrap

## QSAAUDIO_bootstrap

AudioBootStrap QSAAUDIO_bootstrap

## SNDIO_bootstrap

AudioBootStrap SNDIO_bootstrap

## SUNAUDIO_bootstrap

AudioBootStrap SUNAUDIO_bootstrap

## WASAPI_bootstrap

AudioBootStrap WASAPI_bootstrap

## WINMM_bootstrap

AudioBootStrap WINMM_bootstrap