RetroArch
Functions | Variables
audio_driver.c File Reference
#include <string.h>
#include <retro_assert.h>
#include <lists/string_list.h>
#include <audio/conversion/float_to_s16.h>
#include <audio/conversion/s16_to_float.h>
#include <audio/dsp_filter.h>
#include <file/file_path.h>
#include <lists/dir_list.h>
#include <string/stdstring.h>
#include "audio_driver.h"
#include "audio_thread_wrapper.h"
#include "../gfx/video_driver.h"
Include dependency graph for audio_driver.c:

Functions

static void audio_mixer_play_stop_sequential_cb (audio_mixer_sound_t *sound, unsigned reason)
 
static void audio_mixer_play_stop_cb (audio_mixer_sound_t *sound, unsigned reason)
 
enum resampler_quality audio_driver_get_resampler_quality (void)
 
audio_mixer_stream_taudio_driver_mixer_get_stream (unsigned i)
 
const char * audio_driver_mixer_get_stream_name (unsigned i)
 
bool compute_audio_buffer_statistics (audio_statistics_t *stats)
 
static void report_audio_buffer_statistics (void)
 
const voidaudio_driver_find_handle (int idx)
 
const char * audio_driver_find_ident (int idx)
 
const char * config_get_audio_driver_options (void)
 
static bool audio_driver_deinit_internal (void)
 
static void audio_driver_mixer_init (unsigned out_rate)
 
static bool audio_driver_init_internal (bool audio_cb_inited)
 
void audio_driver_set_nonblocking_state (bool enable)
 
static void audio_driver_flush (const int16_t *data, size_t samples)
 
void audio_driver_sample (int16_t left, int16_t right)
 
void audio_driver_menu_sample (void)
 
size_t audio_driver_sample_batch (const int16_t *data, size_t frames)
 
void audio_driver_sample_rewind (int16_t left, int16_t right)
 
size_t audio_driver_sample_batch_rewind (const int16_t *data, size_t frames)
 
void audio_driver_dsp_filter_free (void)
 
void audio_driver_dsp_filter_init (const char *device)
 
void audio_driver_set_buffer_size (size_t bufsize)
 
void audio_driver_monitor_adjust_system_rates (void)
 
void audio_driver_setup_rewind (void)
 
bool audio_driver_find_driver (void)
 
void audio_driver_deinit_resampler (void)
 
bool audio_driver_free_devices_list (void)
 
bool audio_driver_new_devices_list (void)
 
bool audio_driver_init (void)
 
bool audio_driver_get_devices_list (void **data)
 
bool audio_driver_mixer_extension_supported (const char *ext)
 
static int audio_mixer_find_index (audio_mixer_sound_t *sound)
 
bool audio_driver_mixer_get_free_stream_slot (unsigned *id)
 
bool audio_driver_mixer_add_stream (audio_mixer_stream_params_t *params)
 
enum audio_mixer_state audio_driver_mixer_get_stream_state (unsigned i)
 
static void audio_driver_mixer_play_stream_internal (unsigned i, unsigned type)
 
void audio_driver_mixer_play_stream (unsigned i)
 
void audio_driver_mixer_play_stream_looped (unsigned i)
 
void audio_driver_mixer_play_stream_sequential (unsigned i)
 
float audio_driver_mixer_get_stream_volume (unsigned i)
 
void audio_driver_mixer_set_stream_volume (unsigned i, float vol)
 
void audio_driver_mixer_stop_stream (unsigned i)
 
void audio_driver_mixer_remove_stream (unsigned i)
 
static void audio_driver_mixer_deinit (void)
 
bool audio_driver_deinit (void)
 
bool audio_driver_set_callback (const void *data)
 
bool audio_driver_enable_callback (void)
 
bool audio_driver_disable_callback (void)
 
void audio_driver_monitor_set_rate (void)
 
bool audio_driver_callback (void)
 
bool audio_driver_has_callback (void)
 
bool audio_driver_toggle_mute (void)
 
bool audio_driver_mixer_toggle_mute (void)
 
static INLINE bool audio_driver_alive (void)
 
bool audio_driver_start (bool is_shutdown)
 
bool audio_driver_stop (void)
 
void audio_driver_unset_callback (void)
 
void audio_driver_frame_is_reverse (void)
 
void audio_driver_destroy_data (void)
 
void audio_driver_set_own_driver (void)
 
void audio_driver_unset_own_driver (void)
 
bool audio_driver_owns_driver (void)
 
void audio_driver_suspend (void)
 
bool audio_driver_is_suspended (void)
 
void audio_driver_resume (void)
 
void audio_driver_set_active (void)
 
bool audio_driver_is_active (void)
 
void audio_driver_destroy (void)
 
void audio_set_bool (enum audio_action action, bool val)
 
void audio_set_float (enum audio_action action, float val)
 
float * audio_get_float_ptr (enum audio_action action)
 
boolaudio_get_bool_ptr (enum audio_action action)
 

Variables

static const audio_driver_taudio_drivers []
 
static struct audio_mixer_stream audio_mixer_streams [AUDIO_MIXER_MAX_STREAMS] = {{0}}
 
static size_t audio_driver_chunk_size = 0
 
static size_t audio_driver_chunk_nonblock_size = 0
 
static size_t audio_driver_chunk_block_size = 0
 
static size_t audio_driver_rewind_ptr = 0
 
static size_t audio_driver_rewind_size = 0
 
static int16_taudio_driver_rewind_buf = NULL
 
static int16_taudio_driver_output_samples_conv_buf = NULL
 
static unsigned audio_driver_free_samples_buf [AUDIO_BUFFER_FREE_SAMPLES_COUNT]
 
static uint64_t audio_driver_free_samples_count = 0
 
static size_t audio_driver_buffer_size = 0
 
static size_t audio_driver_data_ptr = 0
 
static bool audio_driver_control = false
 
static bool audio_driver_mixer_mute_enable = false
 
static bool audio_driver_mute_enable = false
 
static bool audio_driver_use_float = false
 
static bool audio_driver_active = false
 
static bool audio_driver_data_own = false
 
static bool audio_mixer_active = false
 
static float audio_driver_rate_control_delta = 0.0f
 
static float audio_driver_input = 0.0f
 
static float audio_driver_volume_gain = 0.0f
 
static float audio_driver_mixer_volume_gain = 0.0f
 
static float * audio_driver_input_data = NULL
 
static float * audio_driver_output_samples_buf = NULL
 
static double audio_source_ratio_original = 0.0f
 
static double audio_source_ratio_current = 0.0f
 
static struct retro_audio_callback audio_callback = {0}
 
static retro_dsp_filter_taudio_driver_dsp = NULL
 
static struct string_listaudio_driver_devices_list = NULL
 
static const retro_resampler_taudio_driver_resampler = NULL
 
static voidaudio_driver_resampler_data = NULL
 
static const audio_driver_tcurrent_audio = NULL
 
static voidaudio_driver_context_audio_data = NULL
 
static bool audio_suspended = false
 

Function Documentation

◆ audio_driver_alive()

static INLINE bool audio_driver_alive ( void  )
static
Here is the caller graph for this function:

◆ audio_driver_callback()

bool audio_driver_callback ( void  )
Here is the caller graph for this function:

◆ audio_driver_deinit()

bool audio_driver_deinit ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_deinit_internal()

static bool audio_driver_deinit_internal ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_deinit_resampler()

void audio_driver_deinit_resampler ( void  )
Here is the caller graph for this function:

◆ audio_driver_destroy()

void audio_driver_destroy ( void  )
Here is the caller graph for this function:

◆ audio_driver_destroy_data()

void audio_driver_destroy_data ( void  )
Here is the caller graph for this function:

◆ audio_driver_disable_callback()

bool audio_driver_disable_callback ( void  )
Here is the caller graph for this function:

◆ audio_driver_dsp_filter_free()

void audio_driver_dsp_filter_free ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_dsp_filter_init()

void audio_driver_dsp_filter_init ( const char *  device)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_enable_callback()

bool audio_driver_enable_callback ( void  )
Here is the caller graph for this function:

◆ audio_driver_find_driver()

bool audio_driver_find_driver ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_find_handle()

const void* audio_driver_find_handle ( int  idx)

audio_driver_find_handle: : index of driver to get handle to.

Returns: handle to audio driver at index. Can be NULL if nothing found.

Here is the caller graph for this function:

◆ audio_driver_find_ident()

const char* audio_driver_find_ident ( int  idx)

audio_driver_find_ident: : index of driver to get handle to.

Returns: Human-readable identifier of audio driver at index. Can be NULL if nothing found.

Here is the caller graph for this function:

◆ audio_driver_flush()

static void audio_driver_flush ( const int16_t data,
size_t  samples 
)
static

audio_driver_flush: : pointer to audio buffer. : amount of samples to write.

Writes audio samples to audio driver. Will first perform DSP processing (if enabled) and resampling.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_frame_is_reverse()

void audio_driver_frame_is_reverse ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_free_devices_list()

bool audio_driver_free_devices_list ( void  )
Here is the caller graph for this function:

◆ audio_driver_get_devices_list()

bool audio_driver_get_devices_list ( void **  data)
Here is the caller graph for this function:

◆ audio_driver_get_resampler_quality()

enum resampler_quality audio_driver_get_resampler_quality ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_has_callback()

bool audio_driver_has_callback ( void  )
Here is the caller graph for this function:

◆ audio_driver_init()

bool audio_driver_init ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_init_internal()

static bool audio_driver_init_internal ( bool  audio_cb_inited)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_is_active()

bool audio_driver_is_active ( void  )
Here is the caller graph for this function:

◆ audio_driver_is_suspended()

bool audio_driver_is_suspended ( void  )
Here is the caller graph for this function:

◆ audio_driver_menu_sample()

void audio_driver_menu_sample ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_add_stream()

bool audio_driver_mixer_add_stream ( audio_mixer_stream_params_t params)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_deinit()

static void audio_driver_mixer_deinit ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_extension_supported()

bool audio_driver_mixer_extension_supported ( const char *  ext)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_get_free_stream_slot()

bool audio_driver_mixer_get_free_stream_slot ( unsigned *  id)
Here is the caller graph for this function:

◆ audio_driver_mixer_get_stream()

audio_mixer_stream_t* audio_driver_mixer_get_stream ( unsigned  i)
Here is the caller graph for this function:

◆ audio_driver_mixer_get_stream_name()

const char* audio_driver_mixer_get_stream_name ( unsigned  i)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_get_stream_state()

enum audio_mixer_state audio_driver_mixer_get_stream_state ( unsigned  i)
Here is the caller graph for this function:

◆ audio_driver_mixer_get_stream_volume()

float audio_driver_mixer_get_stream_volume ( unsigned  i)
Here is the caller graph for this function:

◆ audio_driver_mixer_init()

static void audio_driver_mixer_init ( unsigned  out_rate)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_play_stream()

void audio_driver_mixer_play_stream ( unsigned  i)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_play_stream_internal()

static void audio_driver_mixer_play_stream_internal ( unsigned  i,
unsigned  type 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_play_stream_looped()

void audio_driver_mixer_play_stream_looped ( unsigned  i)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_play_stream_sequential()

void audio_driver_mixer_play_stream_sequential ( unsigned  i)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_remove_stream()

void audio_driver_mixer_remove_stream ( unsigned  i)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_set_stream_volume()

void audio_driver_mixer_set_stream_volume ( unsigned  i,
float  vol 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_stop_stream()

void audio_driver_mixer_stop_stream ( unsigned  i)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_mixer_toggle_mute()

bool audio_driver_mixer_toggle_mute ( void  )

◆ audio_driver_monitor_adjust_system_rates()

void audio_driver_monitor_adjust_system_rates ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_monitor_set_rate()

void audio_driver_monitor_set_rate ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_new_devices_list()

bool audio_driver_new_devices_list ( void  )
Here is the caller graph for this function:

◆ audio_driver_owns_driver()

bool audio_driver_owns_driver ( void  )
Here is the caller graph for this function:

◆ audio_driver_resume()

void audio_driver_resume ( void  )
Here is the caller graph for this function:

◆ audio_driver_sample()

void audio_driver_sample ( int16_t  left,
int16_t  right 
)

audio_driver_sample: : value of the left audio channel. : value of the right audio channel.

Audio sample render callback function.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_sample_batch()

size_t audio_driver_sample_batch ( const int16_t data,
size_t  frames 
)

audio_driver_sample_batch: : pointer to audio buffer. : amount of audio frames to push.

Batched audio sample render callback function.

Returns: amount of frames sampled. Will be equal to unless exceeds (AUDIO_CHUNK_SIZE_NONBLOCKING / 2).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_sample_batch_rewind()

size_t audio_driver_sample_batch_rewind ( const int16_t data,
size_t  frames 
)

audio_driver_sample_batch_rewind: : pointer to audio buffer. : amount of audio frames to push.

Batched audio sample render callback function (rewind version).

This callback function will be used instead of audio_driver_sample_batch when rewinding is activated.

Returns: amount of frames sampled. Will be equal to unless exceeds (AUDIO_CHUNK_SIZE_NONBLOCKING / 2).

Here is the caller graph for this function:

◆ audio_driver_sample_rewind()

void audio_driver_sample_rewind ( int16_t  left,
int16_t  right 
)

audio_driver_sample_rewind: : value of the left audio channel. : value of the right audio channel.

Audio sample render callback function (rewind version). This callback function will be used instead of audio_driver_sample when rewinding is activated.

Here is the caller graph for this function:

◆ audio_driver_set_active()

void audio_driver_set_active ( void  )
Here is the caller graph for this function:

◆ audio_driver_set_buffer_size()

void audio_driver_set_buffer_size ( size_t  bufsize)
Here is the caller graph for this function:

◆ audio_driver_set_callback()

bool audio_driver_set_callback ( const void data)
Here is the caller graph for this function:

◆ audio_driver_set_nonblocking_state()

void audio_driver_set_nonblocking_state ( bool  enable)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_set_own_driver()

void audio_driver_set_own_driver ( void  )

◆ audio_driver_setup_rewind()

void audio_driver_setup_rewind ( void  )
Here is the caller graph for this function:

◆ audio_driver_start()

bool audio_driver_start ( bool  is_shutdown)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_stop()

bool audio_driver_stop ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_driver_suspend()

void audio_driver_suspend ( void  )
Here is the caller graph for this function:

◆ audio_driver_toggle_mute()

bool audio_driver_toggle_mute ( void  )
Here is the caller graph for this function:

◆ audio_driver_unset_callback()

void audio_driver_unset_callback ( void  )
Here is the caller graph for this function:

◆ audio_driver_unset_own_driver()

void audio_driver_unset_own_driver ( void  )
Here is the caller graph for this function:

◆ audio_get_bool_ptr()

bool* audio_get_bool_ptr ( enum audio_action  action)
Here is the caller graph for this function:

◆ audio_get_float_ptr()

float* audio_get_float_ptr ( enum audio_action  action)
Here is the caller graph for this function:

◆ audio_mixer_find_index()

static int audio_mixer_find_index ( audio_mixer_sound_t sound)
static
Here is the caller graph for this function:

◆ audio_mixer_play_stop_cb()

static void audio_mixer_play_stop_cb ( audio_mixer_sound_t sound,
unsigned  reason 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_mixer_play_stop_sequential_cb()

static void audio_mixer_play_stop_sequential_cb ( audio_mixer_sound_t sound,
unsigned  reason 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audio_set_bool()

void audio_set_bool ( enum audio_action  action,
bool  val 
)

◆ audio_set_float()

void audio_set_float ( enum audio_action  action,
float  val 
)
Here is the caller graph for this function:

◆ compute_audio_buffer_statistics()

bool compute_audio_buffer_statistics ( audio_statistics_t stats)

compute_audio_buffer_statistics:

Computes audio buffer statistics.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ config_get_audio_driver_options()

const char* config_get_audio_driver_options ( void  )

config_get_audio_driver_options:

Get an enumerated list of all audio driver names, separated by '|'.

Returns: string listing of all audio driver names, separated by '|'.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ report_audio_buffer_statistics()

static void report_audio_buffer_statistics ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ audio_callback

struct retro_audio_callback audio_callback = {0}
static

◆ audio_driver_active

bool audio_driver_active = false
static

◆ audio_driver_buffer_size

size_t audio_driver_buffer_size = 0
static

◆ audio_driver_chunk_block_size

size_t audio_driver_chunk_block_size = 0
static

◆ audio_driver_chunk_nonblock_size

size_t audio_driver_chunk_nonblock_size = 0
static

◆ audio_driver_chunk_size

size_t audio_driver_chunk_size = 0
static

◆ audio_driver_context_audio_data

void* audio_driver_context_audio_data = NULL
static

◆ audio_driver_control

bool audio_driver_control = false
static

◆ audio_driver_data_own

bool audio_driver_data_own = false
static

◆ audio_driver_data_ptr

size_t audio_driver_data_ptr = 0
static

◆ audio_driver_devices_list

struct string_list* audio_driver_devices_list = NULL
static

◆ audio_driver_dsp

retro_dsp_filter_t* audio_driver_dsp = NULL
static

◆ audio_driver_free_samples_buf

unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT]
static

◆ audio_driver_free_samples_count

uint64_t audio_driver_free_samples_count = 0
static

◆ audio_driver_input

float audio_driver_input = 0.0f
static

◆ audio_driver_input_data

float* audio_driver_input_data = NULL
static

◆ audio_driver_mixer_mute_enable

bool audio_driver_mixer_mute_enable = false
static

◆ audio_driver_mixer_volume_gain

float audio_driver_mixer_volume_gain = 0.0f
static

◆ audio_driver_mute_enable

bool audio_driver_mute_enable = false
static

◆ audio_driver_output_samples_buf

float* audio_driver_output_samples_buf = NULL
static

◆ audio_driver_output_samples_conv_buf

int16_t* audio_driver_output_samples_conv_buf = NULL
static

◆ audio_driver_rate_control_delta

float audio_driver_rate_control_delta = 0.0f
static

◆ audio_driver_resampler

const retro_resampler_t* audio_driver_resampler = NULL
static

◆ audio_driver_resampler_data

void* audio_driver_resampler_data = NULL
static

◆ audio_driver_rewind_buf

int16_t* audio_driver_rewind_buf = NULL
static

◆ audio_driver_rewind_ptr

size_t audio_driver_rewind_ptr = 0
static

◆ audio_driver_rewind_size

size_t audio_driver_rewind_size = 0
static

◆ audio_driver_use_float

bool audio_driver_use_float = false
static

◆ audio_driver_volume_gain

float audio_driver_volume_gain = 0.0f
static

◆ audio_drivers

const audio_driver_t* audio_drivers[]
static

◆ audio_mixer_active

bool audio_mixer_active = false
static

◆ audio_mixer_streams

struct audio_mixer_stream audio_mixer_streams[AUDIO_MIXER_MAX_STREAMS] = {{0}}
static

◆ audio_source_ratio_current

double audio_source_ratio_current = 0.0f
static

◆ audio_source_ratio_original

double audio_source_ratio_original = 0.0f
static

◆ audio_suspended

bool audio_suspended = false
static

◆ current_audio

const audio_driver_t* current_audio = NULL
static