SDL_sysaudio.h File Reference
`#include "../SDL_internal.h"`
`#include "SDL_mutex.h"`
`#include "SDL_thread.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_AudioBufferQueue
struct | SDL_AudioDriverImpl
struct | SDL_AudioDeviceItem
struct | SDL_AudioDriver
struct | SDL_AudioStreamer
struct | SDL_AudioDevice
struct | AudioBootStrap

## Macros

#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)

## Macro Definition Documentation

#define _THIS SDL_AudioDevice *_this

Definition at line 31 of file SDL_sysaudio.h.

#define SDL_AUDIOBUFFERQUEUE_PACKETLEN (8 * 1024)

Definition at line 58 of file SDL_sysaudio.h.

Referenced by open_audio_device(), and SDL_QueueAudio().

## Function Documentation

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

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().

{
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:324
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:718
name
GLuint const GLchar * name
Definition: SDL_opengl_glext.h:660
SDL_AUDIODEVICEADDED
Definition: SDL_events.h:141
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:731
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:131
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:357
add_capture_device
static SDL_INLINE int add_capture_device(const char *name, void *handle)
Definition: SDL_audio.c:317
SDL_Event
General event structure.
Definition: SDL_events.h:521

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.

{
SDL_assert(get_audio_device(device->id) == device);
if (!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);
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:147
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:718
SDL_AudioDevice::iscapture
int iscapture
Definition: SDL_sysaudio.h:161
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:142
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:731
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:131
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:357
SDL_AudioDriverImpl::LockDevice
void(* LockDevice)(_THIS)
Definition: SDL_sysaudio.h:80
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:167
SDL_AudioDriver::impl
SDL_AudioDriverImpl impl
Definition: SDL_sysaudio.h:120
SDL_Event
General event structure.
Definition: SDL_events.h:521
SDL_AudioDevice::enabled
int enabled
Definition: SDL_sysaudio.h:162
get_audio_device
static SDL_AudioDevice * get_audio_device(SDL_AudioDeviceID id)
Definition: SDL_audio.c:150

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

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.

{
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);
}
SDL_UnlockMutex(current_audio.detectionLock);
current_audio.impl.FreeDeviceHandle(handle);
}
SDL_LockMutex
#define SDL_LockMutex
Definition: SDL_dynapi_overrides.h:266
SDL_AudioDriver::captureDevicesRemoved
SDL_bool captureDevicesRemoved
Definition: SDL_sysaudio.h:124
mark_device_removed
static void mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag)
Definition: SDL_audio.c:390
current_audio
static SDL_AudioDriver current_audio
Definition: SDL_audio.c:33
SDL_AudioDriver::detectionLock
SDL_mutex * detectionLock
Definition: SDL_sysaudio.h:123
SDL_AudioDriver::outputDevices
SDL_AudioDeviceItem * outputDevices
Definition: SDL_sysaudio.h:128
SDL_AudioDriver::outputDevicesRemoved
SDL_bool outputDevicesRemoved
Definition: SDL_sysaudio.h:125
SDL_AudioDriver::impl
SDL_AudioDriverImpl impl
Definition: SDL_sysaudio.h:120
SDL_AudioDriverImpl::FreeDeviceHandle
void(* FreeDeviceHandle)(void *handle)
Definition: SDL_sysaudio.h:82
SDL_UnlockMutex
#define SDL_UnlockMutex
Definition: SDL_dynapi_overrides.h:268
SDL_AudioDriver::inputDevices
SDL_AudioDeviceItem * inputDevices
Definition: SDL_sysaudio.h:129