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_viewpoint.h>
29 # include "../clock/clock.h"
30 
31 /* Max input rate factor (1/4 -> 4) */
32 # define AOUT_MAX_INPUT_RATE (4)
33 
34 enum {
38 };
39 
40 typedef struct aout_volume aout_volume_t;
41 typedef struct aout_dev aout_dev_t;
42 
43 typedef struct
44 {
46  module_t *module; /**< Output plugin (or NULL if inactive) */
49 
50  struct
51  {
54  unsigned count;
55  } dev;
56 
57  struct
58  {
59  atomic_bool update;
62  } vp;
63 
64  struct
65  {
66  struct vlc_clock_t *clock;
67  float rate; /**< Play-out speed rate */
68  vlc_tick_t resamp_start_drift; /**< Resampler drift absolute value */
69  int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */
74  } sync;
76 
77  int requested_stereo_mode; /**< Requested stereo mode set by the user */
78 
79  /* Original input format and profile, won't change for the lifetime of a
80  * stream (between aout_DecNew() and aout_DecDelete()). */
83 
84  /* Format used to configure the conversion filters. It is based on the
85  * input_format but its fourcc can be different when the module is handling
86  * codec passthrough. Indeed, in case of DTSHD->DTS or EAC3->AC3 fallback,
87  * the filter need to know which codec is handled by the output. */
89 
90  /* Output format used and modified by the module. */
92 
94 
95  atomic_uint buffers_lost;
96  atomic_uint buffers_played;
97  atomic_uchar restart;
98 
99  atomic_uintptr_t refs;
100 } aout_owner_t;
101 
102 typedef struct
103 {
107 
108 static inline aout_owner_t *aout_owner (audio_output_t *aout)
109 {
110  return &((aout_instance_t *)aout)->owner;
111 }
112 
113 /****************************************************************************
114  * Prototypes
115  *****************************************************************************/
116 
117 /* From mixer.c : */
119 #define aout_volume_New(o, g) aout_volume_New(VLC_OBJECT(o), g)
121 void aout_volume_SetVolume(aout_volume_t *, float);
124 
125 
126 /* From output.c : */
128 #define aout_New(a) aout_New(VLC_OBJECT(a))
130 
132 void aout_OutputDelete( audio_output_t * p_aout );
133 
134 
135 /* From common.c : */
136 void aout_FormatsPrint(vlc_object_t *, const char *,
137  const audio_sample_format_t *,
138  const audio_sample_format_t *);
139 #define aout_FormatsPrint(o, t, a, b) \
140  aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
141 
142 /* From dec.c */
143 #define AOUT_DEC_SUCCESS 0
144 #define AOUT_DEC_CHANGED 1
145 #define AOUT_DEC_FAILED VLC_EGENERIC
146 
147 int aout_DecNew(audio_output_t *, const audio_sample_format_t *, int profile,
148  struct vlc_clock_t *clock, const audio_replay_gain_t *);
150 int aout_DecPlay(audio_output_t *aout, block_t *block);
151 void aout_DecGetResetStats(audio_output_t *, unsigned *, unsigned *);
152 void aout_DecChangePause(audio_output_t *, bool b_paused, vlc_tick_t i_date);
153 void aout_DecChangeRate(audio_output_t *aout, float rate);
157 void aout_RequestRestart (audio_output_t *, unsigned);
158 void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts,
159  vlc_tick_t audio_ts);
160 
161 static inline void aout_InputRequestRestart(audio_output_t *aout)
162 {
164 }
165 
167 {
168  static const uint32_t wave_channels[] = {
172 
173  fmt->i_physical_channels = 0;
174  for (int i = 0; i < fmt->i_channels && i < AOUT_CHAN_MAX; ++i)
175  fmt->i_physical_channels |= wave_channels[i];
176  aout_FormatPrepare(fmt);
177 }
178 
179 /* From filters.c */
180 
181 /* Extended version of aout_FiltersNew
182  *
183  * The clock, that is not mandatory, will be used to create a new slave clock
184  * for the filter vizualisation plugins.
185  */
187  const audio_sample_format_t *,
188  const audio_sample_format_t *,
189  const aout_filters_cfg_t *cfg) VLC_USED;
193 
194 #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:43
audio_sample_format_t filter_format
Definition: aout_internal.h:88
void aout_FiltersResetClock(aout_filters_t *filters)
Definition: filters.c:656
audio_sample_format_t input_format
Definition: aout_internal.h:82
#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:134
module_t * module
Output plugin (or NULL if inactive)
Definition: aout_internal.h:46
atomic_bool update
Definition: aout_internal.h:59
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:405
Definition: vlc_es.h:55
pthread_mutex_t vlc_mutex_t
Mutex.
Definition: vlc_threads.h:278
aout_filters_cfg_t filters_cfg
Definition: aout_internal.h:93
aout_filters_t * filters
Definition: aout_internal.h:47
vlc_tick_t first_pts
Definition: aout_internal.h:73
vlc_tick_t delay
Definition: clock.c:73
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:108
audio_sample_format_t mixer_format
Definition: aout_internal.h:91
void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts, vlc_tick_t audio_ts)
Definition: dec.c:305
void aout_DecGetResetStats(audio_output_t *, unsigned *, unsigned *)
Definition: aout_internal.h:36
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:35
#define AOUT_CHAN_CENTER
Definition: vlc_es.h:117
unsigned count
Definition: aout_internal.h:54
audio format description
Definition: vlc_es.h:81
atomic_uint buffers_played
Definition: aout_internal.h:96
float rate
Play-out speed rate.
Definition: aout_internal.h:67
#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:61
audio_output_t output
Definition: aout_internal.h:104
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:520
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:77
vlc_tick_t request_delay
Definition: aout_internal.h:71
vlc_tick_t delay
Definition: aout_internal.h:72
#define aout_FormatsPrint(o, t, a, b)
Definition: aout_internal.h:139
#define AOUT_CHAN_REARRIGHT
Definition: vlc_es.h:122
#define aout_volume_New(o, g)
Definition: aout_internal.h:119
void aout_DecChangePause(audio_output_t *, bool b_paused, vlc_tick_t i_date)
Definition: dec.c:500
static void aout_InputRequestRestart(audio_output_t *aout)
Definition: aout_internal.h:161
#define aout_New(a)
Definition: aout_internal.h:128
#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:105
atomic_uintptr_t refs
Definition: aout_internal.h:99
Audio output object.
Definition: vlc_aout.h:140
void aout_DecFlush(audio_output_t *)
Definition: dec.c:527
bool discontinuity
Definition: aout_internal.h:70
Definition: aout_internal.h:37
atomic_uchar restart
Definition: aout_internal.h:97
int input_profile
Definition: aout_internal.h:81
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:513
#define AOUT_CHAN_REARLEFT
Definition: vlc_es.h:121
Definition: output.c:37
int resamp_type
Resampler mode (FIXME: redundant / resampling)
Definition: aout_internal.h:69
atomic_uint buffers_lost
Definition: aout_internal.h:95
struct vlc_clock_t * clock
Definition: aout_internal.h:66
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:208
#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:68
vlc_mutex_t lock
Definition: aout_internal.h:45
aout_dev_t * list
Definition: aout_internal.h:53
Definition: aout_internal.h:102
vlc_tick_t original_pts
Definition: aout_internal.h:75
#define AOUT_CHAN_RIGHT
Definition: vlc_es.h:119
void aout_DecDrain(audio_output_t *)
Definition: dec.c:557
void aout_Destroy(audio_output_t *)
Deinitializes an audio output module and destroys an audio output object.
Definition: output.c:355
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:48
#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:166