VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
vlc_aout.h File Reference

This file defines functions, structures and macros for audio output object. More...

Include dependency graph for vlc_aout.h:

Go to the source code of this file.

Data Structures

struct  audio_output
 Audio output object. More...
struct  aout_fifo_t
 Audio output buffer FIFO. More...
struct  aout_packet_t

Macros

#define AOUT_MAX_ADVANCE_TIME   (AOUT_MAX_PREPARE_TIME + CLOCK_FREQ)
#define AOUT_MAX_PREPARE_TIME   (2 * CLOCK_FREQ)
#define AOUT_MIN_PREPARE_TIME   AOUT_MAX_PTS_ADVANCE
#define AOUT_MAX_PTS_ADVANCE   (CLOCK_FREQ / 25)
 Maximum advance of actual audio playback time to coded PTS, above which downsampling will be performed.
#define AOUT_MAX_PTS_DELAY   (3 * CLOCK_FREQ / 50)
 Maximum delay of actual audio playback time from coded PTS, above which upsampling will be performed.
#define AOUT_MAX_RESAMPLING   10
#define AOUT_FMTS_IDENTICAL(p_first, p_second)
#define AOUT_FMTS_SIMILAR(p_first, p_second)
#define AOUT_FMT_LINEAR(p_format)   (aout_BitsPerSample((p_format)->i_format) != 0)
#define VLC_CODEC_SPDIFL   VLC_FOURCC('s','p','d','i')
#define VLC_CODEC_SPDIFB   VLC_FOURCC('s','p','d','b')
#define AOUT_FMT_SPDIF(p_format)
#define AOUT_VAR_MONO   1
#define AOUT_VAR_STEREO   2
#define AOUT_VAR_2F2R   4
#define AOUT_VAR_3F2R   5
#define AOUT_VAR_5_1   6
#define AOUT_VAR_6_1   7
#define AOUT_VAR_7_1   8
#define AOUT_VAR_SPDIF   10
#define AOUT_VAR_CHAN_UNSET   0 /* must be zero */
#define AOUT_VAR_CHAN_STEREO   1
#define AOUT_VAR_CHAN_RSTEREO   2
#define AOUT_VAR_CHAN_LEFT   3
#define AOUT_VAR_CHAN_RIGHT   4
#define AOUT_VAR_CHAN_DOLBYS   5
#define AOUT_SPDIF_SIZE   6144
#define A52_FRAME_NB   1536
#define AOUT_RESTART_FILTERS   1
#define AOUT_RESTART_OUTPUT   2
#define AOUT_RESTART_DECODER   4
#define aout_FormatPrint(o, t, f)   aout_FormatPrint(VLC_OBJECT(o), t, f)

Functions

unsigned aout_CheckChannelReorder (const uint32_t *, const uint32_t *, uint32_t mask, uint8_t *table)
 This function computes the reordering needed to go from pi_chan_order_in to pi_chan_order_out.
void aout_ChannelReorder (void *, size_t, unsigned, const uint8_t *, vlc_fourcc_t)
void aout_Interleave (void *dst, const void *src, unsigned samples, unsigned channels, vlc_fourcc_t fourcc)
void aout_Deinterleave (void *dst, const void *src, unsigned samples, unsigned channels, vlc_fourcc_t fourcc)
bool aout_CheckChannelExtraction (int *pi_selection, uint32_t *pi_layout, int *pi_channels, const uint32_t pi_order_dst[9], const uint32_t *pi_order_src, int i_channels)
 This fonction will compute the extraction parameter into pi_selection to go from i_channels with their type given by pi_order_src[] into the order describe by pi_order_dst.
void aout_ChannelExtract (void *p_dst, int i_dst_channels, const void *p_src, int i_src_channels, int i_sample_count, const int *pi_selection, int i_bits_per_sample)
 Do the actual channels extraction using the parameters created by aout_CheckChannelExtraction.
static unsigned aout_FormatNbChannels (const audio_sample_format_t *fmt)
unsigned int aout_BitsPerSample (vlc_fourcc_t i_format)
void aout_FormatPrepare (audio_sample_format_t *p_format)
void aout_FormatPrint (vlc_object_t *, const char *, const audio_sample_format_t *)
const char * aout_FormatPrintChannels (const audio_sample_format_t *)
float aout_VolumeGet (audio_output_t *)
 Gets the volume of the audio output stream (independent of mute).
int aout_VolumeSet (audio_output_t *, float)
 Sets the volume of the audio output stream.
int aout_MuteGet (audio_output_t *)
 Gets the audio output stream mute flag.
int aout_MuteSet (audio_output_t *, bool)
 Sets the audio output stream mute flag.
char * aout_DeviceGet (audio_output_t *)
 Gets the currently selected device.
int aout_DeviceSet (audio_output_t *, const char *)
 Selects an audio output device.
int aout_DevicesList (audio_output_t *, char ***, char ***)
 Enumerates possible audio output devices.
static void aout_VolumeReport (audio_output_t *aout, float volume)
 Report change of configured audio volume to the core and UI.
static void aout_MuteReport (audio_output_t *aout, bool mute)
 Report change of muted flag to the core and UI.
static void aout_PolicyReport (audio_output_t *aout, bool cork)
 Report audio policy status.
static void aout_DeviceReport (audio_output_t *aout, const char *id)
 Report change of output device.
static int aout_GainRequest (audio_output_t *aout, float gain)
 Request a change of software audio amplification.
static void aout_RestartRequest (audio_output_t *aout, unsigned mode)
static int aout_ChannelsRestart (vlc_object_t *obj, const char *varname, vlc_value_t oldval, vlc_value_t newval, void *data)
vout_thread_taout_filter_RequestVout (filter_t *, vout_thread_t *p_vout, video_format_t *p_fmt)
void aout_PacketInit (audio_output_t *, aout_packet_t *, unsigned, const audio_sample_format_t *)
void aout_PacketDestroy (audio_output_t *)
int aout_PacketTimeGet (audio_output_t *, mtime_t *)
void aout_PacketPlay (audio_output_t *, block_t *)
void aout_PacketFlush (audio_output_t *, bool)
block_taout_PacketNext (audio_output_t *, mtime_t)

Variables

static const uint32_t pi_vlc_chan_order_wg4 []
 It describes the audio channel order VLC expect.

Detailed Description

This file defines functions, structures and macros for audio output object.

Macro Definition Documentation

#define A52_FRAME_NB   1536
#define AOUT_FMT_LINEAR (   p_format)    (aout_BitsPerSample((p_format)->i_format) != 0)
#define AOUT_FMT_SPDIF (   p_format)
Value:
( ((p_format)->i_format == VLC_CODEC_SPDIFL) \
|| ((p_format)->i_format == VLC_CODEC_SPDIFB) \
|| ((p_format)->i_format == VLC_CODEC_A52) \
|| ((p_format)->i_format == VLC_CODEC_DTS) )

Referenced by aout_DecSilence().

#define AOUT_FMTS_IDENTICAL (   p_first,
  p_second 
)
Value:
( \
((p_first)->i_format == (p_second)->i_format) \
&& AOUT_FMTS_SIMILAR(p_first, p_second) )

Referenced by aout_FiltersNew(), aout_new_buffer(), and CreateFilter().

#define AOUT_FMTS_SIMILAR (   p_first,
  p_second 
)
Value:
( \
((p_first)->i_rate == (p_second)->i_rate) \
&& ((p_first)->i_physical_channels == (p_second)->i_physical_channels)\
&& ((p_first)->i_original_channels == (p_second)->i_original_channels) )
#define aout_FormatPrint (   o,
  t,
 
)    aout_FormatPrint(VLC_OBJECT(o), t, f)

Referenced by aout_FiltersNew(), and aout_OutputNew().

#define AOUT_MAX_ADVANCE_TIME   (AOUT_MAX_PREPARE_TIME + CLOCK_FREQ)

Referenced by aout_DecPlay(), and DecoderPlayAudio().

#define AOUT_MAX_PREPARE_TIME   (2 * CLOCK_FREQ)

Referenced by DecoderPlayAudio().

#define AOUT_MAX_PTS_ADVANCE   (CLOCK_FREQ / 25)

Maximum advance of actual audio playback time to coded PTS, above which downsampling will be performed.

Referenced by aout_DecSynchronize().

#define AOUT_MAX_PTS_DELAY   (3 * CLOCK_FREQ / 50)

Maximum delay of actual audio playback time from coded PTS, above which upsampling will be performed.

Referenced by aout_DecPlay(), and aout_DecSynchronize().

#define AOUT_MAX_RESAMPLING   10
#define AOUT_MIN_PREPARE_TIME   AOUT_MAX_PTS_ADVANCE
#define AOUT_RESTART_DECODER   4
#define AOUT_RESTART_FILTERS   1
#define AOUT_RESTART_OUTPUT   2
#define AOUT_SPDIF_SIZE   6144
#define AOUT_VAR_2F2R   4
#define AOUT_VAR_3F2R   5
#define AOUT_VAR_5_1   6
#define AOUT_VAR_6_1   7
#define AOUT_VAR_7_1   8
#define AOUT_VAR_CHAN_DOLBYS   5

Referenced by aout_OutputNew().

#define AOUT_VAR_CHAN_LEFT   3

Referenced by aout_OutputNew().

#define AOUT_VAR_CHAN_RIGHT   4

Referenced by aout_OutputNew().

#define AOUT_VAR_CHAN_RSTEREO   2

Referenced by aout_OutputNew().

#define AOUT_VAR_CHAN_STEREO   1

Referenced by aout_OutputNew().

#define AOUT_VAR_CHAN_UNSET   0 /* must be zero */
#define AOUT_VAR_MONO   1
#define AOUT_VAR_SPDIF   10
#define AOUT_VAR_STEREO   2
#define VLC_CODEC_SPDIFB   VLC_FOURCC('s','p','d','b')
#define VLC_CODEC_SPDIFL   VLC_FOURCC('s','p','d','i')

Function Documentation

unsigned int aout_BitsPerSample ( vlc_fourcc_t  i_format)
void aout_ChannelExtract ( void *  p_dst,
int  i_dst_channels,
const void *  p_src,
int  i_src_channels,
int  i_sample_count,
const int *  pi_selection,
int  i_bits_per_sample 
)

Do the actual channels extraction using the parameters created by aout_CheckChannelExtraction.

XXX this function does not work in place (p_dst and p_src must not overlap). XXX Only 8, 16, 24, 32, 64 bits per sample are supported.

References ExtractChannel().

void aout_ChannelReorder ( void *  ,
size_t  ,
unsigned  ,
const uint8_t *  ,
vlc_fourcc_t   
)
static int aout_ChannelsRestart ( vlc_object_t obj,
const char *  varname,
vlc_value_t  oldval,
vlc_value_t  newval,
void *  data 
)
inlinestatic
bool aout_CheckChannelExtraction ( int *  pi_selection,
uint32_t *  pi_layout,
int *  pi_channels,
const uint32_t  pi_order_dst[9],
const uint32_t *  pi_order_src,
int  i_channels 
)

This fonction will compute the extraction parameter into pi_selection to go from i_channels with their type given by pi_order_src[] into the order describe by pi_order_dst.

It will also set :

  • *pi_channels as the number of channels that will be extracted which is lower (in case of non understood channels type) or equal to i_channels.
  • the layout of the channels (*pi_layout).

It will return true if channel extraction is really needed, in which case aout_ChannelExtract must be used

XXX It must be used when the source may have channel type not understood by VLC. In this case the channel type pi_order_src[] must be set to 0. XXX It must also be used if multiple channels have the same type.

References AOUT_CHAN_CENTER, AOUT_CHAN_DUALMONO, AOUT_CHAN_LEFT, AOUT_CHAN_MAX, AOUT_CHAN_RIGHT, and pi_vlc_chan_order_wg4.

unsigned aout_CheckChannelReorder ( const uint32_t *  ,
const uint32_t *  ,
uint32_t  mask,
uint8_t *  table 
)

This function computes the reordering needed to go from pi_chan_order_in to pi_chan_order_out.

If pi_chan_order_in or pi_chan_order_out is NULL, it will assume that vlc internal (WG4) order is requested.

void aout_Deinterleave ( void *  dst,
const void *  src,
unsigned  samples,
unsigned  channels,
vlc_fourcc_t  fourcc 
)
char* aout_DeviceGet ( audio_output_t aout)

Gets the currently selected device.

Returns
the selected device ID (caller must free() it) NULL if no device is selected or in case of error.

References var_GetNonEmptyString.

static void aout_DeviceReport ( audio_output_t aout,
const char *  id 
)
inlinestatic

Report change of output device.

References audio_output::device_report, and audio_output::event.

int aout_DeviceSet ( audio_output_t aout,
const char *  id 
)

Selects an audio output device.

Parameters
iddevice ID to select, or NULL for the default device
Returns
zero on success, non-zero on error (TODO).

References aout_OutputTryLock(), aout_OutputUnlock(), aout_owner(), aout_owner_t::device, aout_owner_t::lock, aout_owner_t::req, strdup(), unlikely, unset_str, vlc_mutex_lock(), and vlc_mutex_unlock().

int aout_DevicesList ( audio_output_t aout,
char ***  ids,
char ***  names 
)

Enumerates possible audio output devices.

The function will heap-allocate two tables of heap-allocated strings; the caller is responsible for freeing all strings and both tables.

Parameters
idspointer to a table of device identifiers [OUT]
namespointer to a table of device human-readable descriptions [OUT]
Returns
the number of devices, or negative on error.
Note
In case of error, *ids and *names are undefined.

References aout_OutputDevicesEnum(), aout_OutputLock(), and aout_OutputUnlock().

vout_thread_t* aout_filter_RequestVout ( filter_t ,
vout_thread_t p_vout,
video_format_t p_fmt 
)
static unsigned aout_FormatNbChannels ( const audio_sample_format_t fmt)
inlinestatic
void aout_FormatPrepare ( audio_sample_format_t p_format)
void aout_FormatPrint ( vlc_object_t ,
const char *  ,
const audio_sample_format_t  
)
const char* aout_FormatPrintChannels ( const audio_sample_format_t )
static int aout_GainRequest ( audio_output_t aout,
float  gain 
)
inlinestatic

Request a change of software audio amplification.

Parameters
gainlinear amplitude gain (must be positive)
Warning
Values in excess 1.0 may cause overflow and distorsion.

References audio_output::event, and audio_output::gain_request.

void aout_Interleave ( void *  dst,
const void *  src,
unsigned  samples,
unsigned  channels,
vlc_fourcc_t  fourcc 
)
int aout_MuteGet ( audio_output_t aout)

Gets the audio output stream mute flag.

Returns
0 if not muted, 1 if muted, -1 if undefined.

References var_InheritBool.

Referenced by playlist_MuteGet().

static void aout_MuteReport ( audio_output_t aout,
bool  mute 
)
inlinestatic

Report change of muted flag to the core and UI.

References audio_output::event, and audio_output::mute_report.

int aout_MuteSet ( audio_output_t aout,
bool  mute 
)

Sets the audio output stream mute flag.

Returns
0 on success, -1 on failure (TODO).

References aout_OutputTryLock(), aout_OutputUnlock(), aout_owner(), aout_owner_t::lock, aout_owner_t::mute, aout_owner_t::req, vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by playlist_MuteSet().

void aout_PacketDestroy ( audio_output_t )
void aout_PacketFlush ( audio_output_t ,
bool   
)
void aout_PacketInit ( audio_output_t ,
aout_packet_t ,
unsigned  ,
const audio_sample_format_t  
)
block_t* aout_PacketNext ( audio_output_t ,
mtime_t   
)
void aout_PacketPlay ( audio_output_t ,
block_t  
)
int aout_PacketTimeGet ( audio_output_t ,
mtime_t  
)
static void aout_PolicyReport ( audio_output_t aout,
bool  cork 
)
inlinestatic

Report audio policy status.

cork true to request a cork, false to undo any pending cork.

References audio_output::event, and audio_output::policy_report.

static void aout_RestartRequest ( audio_output_t aout,
unsigned  mode 
)
inlinestatic
float aout_VolumeGet ( audio_output_t aout)

Gets the volume of the audio output stream (independent of mute).

Returns
Current audio volume (0. = silent, 1. = nominal), or a strictly negative value if undefined.

References var_GetFloat.

Referenced by playlist_VolumeGet(), and playlist_VolumeUp().

static void aout_VolumeReport ( audio_output_t aout,
float  volume 
)
inlinestatic

Report change of configured audio volume to the core and UI.

int aout_VolumeSet ( audio_output_t aout,
float  vol 
)

Sets the volume of the audio output stream.

Note
The mute status is not changed.
Returns
0 on success, -1 on failure (TODO).

References aout_OutputTryLock(), aout_OutputUnlock(), aout_owner(), aout_owner_t::lock, aout_owner_t::req, vlc_mutex_lock(), vlc_mutex_unlock(), and aout_owner_t::volume.

Referenced by playlist_VolumeSet(), and playlist_VolumeUp().

Variable Documentation

const uint32_t pi_vlc_chan_order_wg4[]
static
Initial value:
{
0x2 , 0x4 ,
0x100 , 0x200 ,
0x20 , 0x40 , 0x10 ,
0x1 , 0x1000 , 0
}

It describes the audio channel order VLC expect.

Referenced by aout_CheckChannelExtraction(), and aout_CheckChannelReorder().