VLC  4.0.0-dev
aout_internal.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * aout_internal.h : internal defines for audio output
3  *****************************************************************************
4  * Copyright (C) 2002 VLC authors and VideoLAN
5  *
6  * Authors: Christophe Massiot <massiot@via.ecp.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22 
23 #ifndef LIBVLC_AOUT_INTERNAL_H
24 # define LIBVLC_AOUT_INTERNAL_H 1
25 
26 # include <stdatomic.h>
27 
28 # include <vlc_atomic.h>
29 # include <vlc_viewpoint.h>
30 # include "../clock/clock.h"
31 
32 /* Max input rate factor (1/4 -> 4) */
33 # define AOUT_MAX_INPUT_RATE (4)
34 
35 enum {
39 };
40 
41 typedef struct aout_volume aout_volume_t;
42 typedef struct aout_dev aout_dev_t;
43 
44 typedef struct
45 {
47  module_t *module; /**< Output plugin (or NULL if inactive) */
50  bool bitexact;
51 
52  struct
53  {
56  unsigned count;
57  } dev;
58 
59  struct
60  {
61  atomic_bool update;
64  } vp;
65 
66  struct
67  {
68  struct vlc_clock_t *clock;
69  float rate; /**< Play-out speed rate */
70  vlc_tick_t resamp_start_drift; /**< Resampler drift absolute value */
71  int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */
76  } sync;
78 
79  int requested_stereo_mode; /**< Requested stereo mode set by the user */
80 
81  /* Original input format and profile, won't change for the lifetime of a
82  * stream (between aout_DecNew() and aout_DecDelete()). */
85 
86  /* Format used to configure the conversion filters. It is based on the
87  * input_format but its fourcc can be different when the module is handling
88  * codec passthrough. Indeed, in case of DTSHD->DTS or EAC3->AC3 fallback,
89  * the filter need to know which codec is handled by the output. */
91 
92  /* Output format used and modified by the module. */
94 
96 
97  atomic_uint buffers_lost;
98  atomic_uint buffers_played;
99  atomic_uchar restart;
100 
102 } aout_owner_t;
103 
104 typedef struct
105 {
109 
110 static inline aout_owner_t *aout_owner (audio_output_t *aout)
111 {
112  return &((aout_instance_t *)aout)->owner;
113 }
114 
115 /****************************************************************************
116  * Prototypes
117  *****************************************************************************/
118 
119 /* From mixer.c : */
121 #define aout_volume_New(o, g) aout_volume_New(VLC_OBJECT(o), g)
123 void aout_volume_SetVolume(aout_volume_t *, float);
126 
127 
128 /* From output.c : */
130 #define aout_New(a) aout_New(VLC_OBJECT(a))
132 
134 void aout_OutputDelete( audio_output_t * p_aout );
135 
136 
137 /* From common.c : */
138 void aout_FormatsPrint(vlc_object_t *, const char *,
139  const audio_sample_format_t *,
140  const audio_sample_format_t *);
141 #define aout_FormatsPrint(o, t, a, b) \
142  aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
143 
144 /* From dec.c */
145 #define AOUT_DEC_SUCCESS 0
146 #define AOUT_DEC_CHANGED 1
147 #define AOUT_DEC_FAILED VLC_EGENERIC
148 
149 int aout_DecNew(audio_output_t *, const audio_sample_format_t *, int profile,
150  struct vlc_clock_t *clock, const audio_replay_gain_t *);
152 int aout_DecPlay(audio_output_t *aout, block_t *block);
153 void aout_DecGetResetStats(audio_output_t *, unsigned *, unsigned *);
154 void aout_DecChangePause(audio_output_t *, bool b_paused, vlc_tick_t i_date);
155 void aout_DecChangeRate(audio_output_t *aout, float rate);
159 void aout_RequestRestart (audio_output_t *, unsigned);
160 void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts,
161  vlc_tick_t audio_ts);
162 
163 static inline void aout_InputRequestRestart(audio_output_t *aout)
164 {
166 }
167 
169 {
170  static const uint32_t wave_channels[] = {
174 
175  fmt->i_physical_channels = 0;
176  for (int i = 0; i < fmt->i_channels && i < AOUT_CHAN_MAX; ++i)
177  fmt->i_physical_channels |= wave_channels[i];
178  aout_FormatPrepare(fmt);
179 }
180 
181 /* From filters.c */
182 
183 /* Extended version of aout_FiltersNew
184  *
185  * The clock, that is not mandatory, will be used to create a new slave clock
186  * for the filter vizualisation plugins.
187  */
189  const audio_sample_format_t *,
190  const audio_sample_format_t *,
191  const aout_filters_cfg_t *cfg) VLC_USED;
195 
196 #endif /* !LIBVLC_AOUT_INTERNAL_H */
void aout_FormatPrepare(audio_sample_format_t *p_format)
Definition: common.c:87
#define AOUT_CHAN_REARCENTER
Definition: vlc_es.h:120
Definition: aout_internal.h:44
audio_sample_format_t filter_format
Definition: aout_internal.h:90
void aout_FiltersResetClock(aout_filters_t *filters)
Definition: filters.c:656
audio_sample_format_t input_format
Definition: aout_internal.h:84
#define AOUT_CHAN_MIDDLERIGHT
Definition: vlc_es.h:124
void aout_DecDelete(audio_output_t *)
Stops all plugins involved in the audio output.
Definition: dec.c:139
Definition: vlc_atomic.h:38
module_t * module
Output plugin (or NULL if inactive)
Definition: aout_internal.h:47
atomic_bool update
Definition: aout_internal.h:61
void aout_FiltersSetClockDelay(aout_filters_t *filters, vlc_tick_t delay)
Definition: filters.c:662
aout_filters_t * aout_FiltersNewWithClock(vlc_object_t *, const vlc_clock_t *, const audio_sample_format_t *, const audio_sample_format_t *, const aout_filters_cfg_t *cfg)
int aout_DecPlay(audio_output_t *aout, block_t *block)
Definition: dec.c:415
Definition: vlc_es.h:55
aout_filters_cfg_t filters_cfg
Definition: aout_internal.h:95
aout_filters_t * filters
Definition: aout_internal.h:48
vlc_tick_t first_pts
Definition: aout_internal.h:75
vlc_tick_t delay
Definition: clock.c:72
Definition: vlc_aout.h:496
vlc_mutex_t lock
Definition: rand.c:32
uint8_t i_channels
Definition: vlc_es.h:113
static aout_owner_t * aout_owner(audio_output_t *aout)
Definition: aout_internal.h:110
audio_sample_format_t mixer_format
Definition: aout_internal.h:93
void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts, vlc_tick_t audio_ts)
Definition: dec.c:315
void aout_DecGetResetStats(audio_output_t *, unsigned *, unsigned *)
Definition: aout_internal.h:37
Definition: volume.c:37
Definition: filters.c:345
Internal module descriptor.
Definition: modules.h:75
#define AOUT_RESTART_FILTERS
Definition: vlc_aout.h:324
Definition: aout_internal.h:36
#define AOUT_CHAN_CENTER
Definition: vlc_es.h:117
unsigned count
Definition: aout_internal.h:56
audio format description
Definition: vlc_es.h:81
atomic_uint buffers_played
Definition: aout_internal.h:98
float rate
Play-out speed rate.
Definition: aout_internal.h:69
#define AOUT_CHAN_LFE
Definition: vlc_es.h:125
int aout_DecNew(audio_output_t *, const audio_sample_format_t *, int profile, struct vlc_clock_t *clock, const audio_replay_gain_t *)
Creates an audio output.
Definition: dec.c:56
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45
vlc_viewpoint_t value
Definition: aout_internal.h:63
audio_output_t output
Definition: aout_internal.h:106
Atomic operations do not require locking, but they are not very powerful.
uint32_t vlc_fourcc_t
Definition: fourcc_gen.c:33
int aout_volume_SetFormat(aout_volume_t *, vlc_fourcc_t)
Selects the current sample format for software amplification.
Definition: volume.c:81
Definition: clock.c:61
void aout_DecChangeDelay(audio_output_t *aout, vlc_tick_t delay)
Definition: dec.c:534
Viewpoints.
Definition: vlc_viewpoint.h:41
uint16_t i_physical_channels
Definition: vlc_es.h:88
#define AOUT_CHAN_MAX
Definition: vlc_es.h:153
int requested_stereo_mode
Requested stereo mode set by the user.
Definition: aout_internal.h:79
vlc_tick_t request_delay
Definition: aout_internal.h:73
vlc_tick_t delay
Definition: aout_internal.h:74
#define aout_FormatsPrint(o, t, a, b)
Definition: aout_internal.h:141
#define AOUT_CHAN_REARRIGHT
Definition: vlc_es.h:122
Mutex.
Definition: vlc_threads.h:266
#define aout_volume_New(o, g)
Definition: aout_internal.h:121
void aout_DecChangePause(audio_output_t *, bool b_paused, vlc_tick_t i_date)
Definition: dec.c:514
bool bitexact
Definition: aout_internal.h:50
static void aout_InputRequestRestart(audio_output_t *aout)
Definition: aout_internal.h:163
#define aout_New(a)
Definition: aout_internal.h:130
#define AOUT_CHAN_MIDDLELEFT
Definition: vlc_es.h:123
Video and audio viewpoint struct and helpers.
int aout_volume_Amplify(aout_volume_t *, block_t *)
Applies replay gain and software volume to an audio buffer.
Definition: volume.c:133
void aout_OutputDelete(audio_output_t *p_aout)
Stops the audio output stream (undoes aout_OutputNew()).
Definition: output.c:627
aout_owner_t owner
Definition: aout_internal.h:107
Audio output object.
Definition: vlc_aout.h:140
void aout_DecFlush(audio_output_t *)
Definition: dec.c:541
bool discontinuity
Definition: aout_internal.h:72
Definition: aout_internal.h:38
atomic_uchar restart
Definition: aout_internal.h:99
int input_profile
Definition: aout_internal.h:83
int aout_OutputNew(audio_output_t *)
Starts an audio output stream.
Definition: output.c:524
void aout_DecChangeRate(audio_output_t *aout, float rate)
Definition: dec.c:527
#define AOUT_CHAN_REARLEFT
Definition: vlc_es.h:121
Definition: output.c:38
int resamp_type
Resampler mode (FIXME: redundant / resampling)
Definition: aout_internal.h:71
atomic_uint buffers_lost
Definition: aout_internal.h:97
struct vlc_clock_t * clock
Definition: aout_internal.h:68
void aout_RequestRestart(audio_output_t *, unsigned)
Marks the audio output for restart, to update any parameter of the output plug-in (e...
Definition: dec.c:217
#define AOUT_CHAN_LEFT
Definition: vlc_es.h:118
Definition: vlc_block.h:117
bool aout_FiltersCanResample(aout_filters_t *filters)
Definition: filters.c:702
vlc_tick_t resamp_start_drift
Resampler drift absolute value.
Definition: aout_internal.h:70
vlc_mutex_t lock
Definition: aout_internal.h:46
aout_dev_t * list
Definition: aout_internal.h:55
Definition: aout_internal.h:104
vlc_tick_t original_pts
Definition: aout_internal.h:77
#define AOUT_CHAN_RIGHT
Definition: vlc_es.h:119
void aout_DecDrain(audio_output_t *)
Definition: dec.c:574
vlc_atomic_rc_t rc
Definition: aout_internal.h:101
void aout_Destroy(audio_output_t *)
Deinitializes an audio output module and destroys an audio output object.
Definition: output.c:358
void aout_volume_Delete(aout_volume_t *)
Destroys a software amplifier.
Definition: volume.c:108
VLC object common members.
Definition: vlc_objects.h:43
aout_volume_t * volume
Definition: aout_internal.h:49
#define VLC_USED
Definition: fourcc_gen.c:32
void aout_volume_SetVolume(aout_volume_t *, float)
Definition: volume.c:122
static void aout_SetWavePhysicalChannels(audio_sample_format_t *fmt)
Definition: aout_internal.h:168