SDL  2.0
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 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)
 

Macro Definition Documentation

◆ _THIS

#define _THIS   SDL_AudioDevice *_this

Definition at line 35 of file SDL_sysaudio.h.

◆ DEFAULT_INPUT_DEVNAME

#define DEFAULT_INPUT_DEVNAME   "System audio capture device"

Definition at line 31 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 30 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 62 of file SDL_sysaudio.h.

Referenced by open_audio_device(), and queue_audio_to_device().

Function Documentation

◆ SDL_AddAudioDevice()

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

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

365 {
366  const int device_index = iscapture ? add_capture_device(name, handle) : add_output_device(name, handle);
367  if (device_index != -1) {
368  /* Post the event, if desired */
371  SDL_zero(event);
372  event.adevice.type = SDL_AUDIODEVICEADDED;
373  event.adevice.which = device_index;
374  event.adevice.iscapture = iscapture;
375  SDL_PushEvent(&event);
376  }
377  }
378 }
static SDL_INLINE int add_output_device(const char *name, void *handle)
Definition: SDL_audio.c:341
#define SDL_ENABLE
Definition: SDL_events.h:722
GLuint const GLchar * name
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
struct _cl_event * event
#define SDL_PushEvent
#define SDL_zero(x)
Definition: SDL_stdinc.h:359
static SDL_INLINE int add_capture_device(const char *name, void *handle)
Definition: SDL_audio.c:334
General event structure.
Definition: SDL_events.h:525

◆ SDL_OpenedAudioDeviceDisconnected()

void SDL_OpenedAudioDeviceDisconnected ( SDL_AudioDevice device)

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

382 {
383  SDL_assert(get_audio_device(device->id) == device);
384 
385  if (!SDL_AtomicGet(&device->enabled)) {
386  return;
387  }
388 
389  /* Ends the audio callback and mark the device as STOPPED, but the
390  app still needs to close the device to free resources. */
391  current_audio.impl.LockDevice(device);
392  SDL_AtomicSet(&device->enabled, 0);
394 
395  /* Post the event, if desired */
398  SDL_zero(event);
399  event.adevice.type = SDL_AUDIODEVICEREMOVED;
400  event.adevice.which = device->id;
401  event.adevice.iscapture = device->iscapture ? 1 : 0;
402  SDL_PushEvent(&event);
403  }
404 }
SDL_AudioDeviceID id
Definition: SDL_sysaudio.h:153
SDL_atomic_t enabled
Definition: SDL_sysaudio.h:167
#define SDL_ENABLE
Definition: SDL_events.h:722
static SDL_AudioDriver current_audio
Definition: SDL_audio.c:33
void(* UnlockDevice)(_THIS)
Definition: SDL_sysaudio.h:87
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
struct _cl_event * event
SDL_bool iscapture
Definition: SDL_sysaudio.h:169
#define SDL_PushEvent
#define SDL_zero(x)
Definition: SDL_stdinc.h:359
void(* LockDevice)(_THIS)
Definition: SDL_sysaudio.h:86
#define SDL_assert(condition)
Definition: SDL_assert.h:167
SDL_AudioDriverImpl impl
Definition: SDL_sysaudio.h:126
#define SDL_AtomicSet
#define SDL_AtomicGet
General event structure.
Definition: SDL_events.h:525
static SDL_AudioDevice * get_audio_device(SDL_AudioDeviceID id)
Definition: SDL_audio.c:141

◆ SDL_RemoveAudioDevice()

void SDL_RemoveAudioDevice ( const int  iscapture,
void handle 
)

Definition at line 422 of file SDL_audio.c.

References SDL_AudioDriver::captureDevicesRemoved, SDL_AudioDriver::detectionLock, 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(), and SDL_UnlockMutex.

423 {
424  int device_index;
425  SDL_AudioDevice *device = NULL;
426 
428  if (iscapture) {
430  } else {
432  }
433  for (device_index = 0; device_index < SDL_arraysize(open_devices); device_index++)
434  {
435  device = open_devices[device_index];
436  if (device != NULL && device->handle == handle)
437  {
439  break;
440  }
441  }
443 
445 }
static SDL_AudioDevice * open_devices[16]
Definition: SDL_audio.c:34
#define SDL_LockMutex
SDL_bool captureDevicesRemoved
Definition: SDL_sysaudio.h:130
static void mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag)
Definition: SDL_audio.c:407
void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
Definition: SDL_audio.c:381
static SDL_AudioDriver current_audio
Definition: SDL_audio.c:33
SDL_mutex * detectionLock
Definition: SDL_sysaudio.h:129
SDL_AudioDeviceItem * outputDevices
Definition: SDL_sysaudio.h:134
#define NULL
Definition: begin_code.h:143
SDL_bool outputDevicesRemoved
Definition: SDL_sysaudio.h:131
SDL_AudioDriverImpl impl
Definition: SDL_sysaudio.h:126
void(* FreeDeviceHandle)(void *handle)
Definition: SDL_sysaudio.h:88
#define SDL_UnlockMutex
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:90
SDL_AudioDeviceItem * inputDevices
Definition: SDL_sysaudio.h:135