Coverage Report

Created: 2026-10-17 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/src/audio_output/aout_internal.h
Line
Count
Source
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_filter.h>
30
# include <vlc_list.h>
31
# include <vlc_viewpoint.h>
32
# include "../clock/clock.h"
33
34
/* Max input rate factor (1/4 -> 4) */
35
# define AOUT_MAX_INPUT_RATE (4)
36
37
0
#define AOUT_RESTART_FILTERS        0x1
38
0
#define AOUT_RESTART_OUTPUT         (AOUT_RESTART_FILTERS|0x2)
39
0
#define AOUT_RESTART_OUTPUT_DEC     (AOUT_RESTART_OUTPUT|0x4)
40
41
enum {
42
    AOUT_RESAMPLING_NONE=0,
43
    AOUT_RESAMPLING_UP,
44
    AOUT_RESAMPLING_DOWN
45
};
46
47
typedef struct aout_volume aout_volume_t;
48
typedef struct vlc_aout_stream vlc_aout_stream;
49
50
typedef struct
51
{
52
    vlc_mutex_t lock;
53
    module_t *module; /**< Output plugin (or NULL if inactive) */
54
    bool bitexact;
55
56
    vlc_aout_stream *main_stream;
57
58
    struct
59
    {
60
        vlc_mutex_t lock;
61
        struct vlc_list list;
62
        unsigned count;
63
    } dev;
64
65
    struct
66
    {
67
        atomic_bool update;
68
        vlc_mutex_t lock;
69
        vlc_viewpoint_t value;
70
    } vp;
71
72
    int requested_stereo_mode; /**< Requested stereo mode set by the user */
73
    int requested_mix_mode; /**< Requested mix mode set by the user */
74
75
    struct vlc_audio_meter meter;
76
77
    vlc_atomic_rc_t rc;
78
} aout_owner_t;
79
80
typedef struct
81
{
82
    audio_output_t output;
83
    aout_owner_t   owner;
84
} aout_instance_t;
85
86
static inline aout_instance_t *aout_instance (audio_output_t *aout)
87
0
{
88
0
    return container_of(aout, aout_instance_t, output);
89
0
}
Unexecuted instantiation: decoder.c:aout_instance
Unexecuted instantiation: player.c:aout_instance
Unexecuted instantiation: resource.c:aout_instance
Unexecuted instantiation: common.c:aout_instance
Unexecuted instantiation: dec.c:aout_instance
Unexecuted instantiation: filters.c:aout_instance
Unexecuted instantiation: meter.c:aout_instance
Unexecuted instantiation: output.c:aout_instance
Unexecuted instantiation: volume.c:aout_instance
Unexecuted instantiation: objects.c:aout_instance
90
91
static inline aout_owner_t *aout_owner (audio_output_t *aout)
92
0
{
93
0
    aout_instance_t *instance = aout_instance(aout);
94
0
    return &instance->owner;
95
0
}
Unexecuted instantiation: decoder.c:aout_owner
Unexecuted instantiation: player.c:aout_owner
Unexecuted instantiation: resource.c:aout_owner
Unexecuted instantiation: common.c:aout_owner
Unexecuted instantiation: dec.c:aout_owner
Unexecuted instantiation: filters.c:aout_owner
Unexecuted instantiation: meter.c:aout_owner
Unexecuted instantiation: output.c:aout_owner
Unexecuted instantiation: volume.c:aout_owner
Unexecuted instantiation: objects.c:aout_owner
96
97
/****************************************************************************
98
 * Prototypes
99
 *****************************************************************************/
100
101
/* From mixer.c : */
102
aout_volume_t *aout_volume_New(vlc_object_t *, const audio_replay_gain_t *);
103
0
#define aout_volume_New(o, g) aout_volume_New(VLC_OBJECT(o), g)
104
int aout_volume_SetFormat(aout_volume_t *, vlc_fourcc_t);
105
void aout_volume_SetVolume(aout_volume_t *, float);
106
int aout_volume_Amplify(aout_volume_t *, block_t *);
107
void aout_volume_Delete(aout_volume_t *);
108
109
110
/* From output.c : */
111
audio_output_t *aout_New (vlc_object_t *);
112
0
#define aout_New(a) aout_New(VLC_OBJECT(a))
113
114
/**
115
 * Starts an audio output stream.
116
 *
117
 * \param aout the audio output instance to initialize from
118
 * \param stream the audio output stream to initialize from
119
 * \param fmt the format to request to the output
120
 * \param input_profile the audio profile to request from the audio output
121
 * \param filter_fmt the format requested from the filters
122
 * \param filters_cfg the configuration to load the audio filters from
123
 *
124
 * \warning The caller must NOT hold the audio output lock.
125
 */
126
int aout_OutputNew(audio_output_t *aout, vlc_aout_stream *stream,
127
                   audio_sample_format_t *fmt, int input_profile,
128
                   audio_sample_format_t *filter_fmt,
129
                   aout_filters_cfg_t *filters_cfg);
130
/**
131
 * Stops the audio output stream (undoes aout_OutputNew()).
132
 * \note This can only be called after a successful aout_OutputNew().
133
 * \warning The caller must NOT hold the audio output lock.
134
 */
135
void aout_OutputDelete( audio_output_t * p_aout );
136
137
vlc_audio_meter_plugin *
138
aout_AddMeterPlugin(audio_output_t *aout, const char *chain,
139
                    const struct vlc_audio_meter_plugin_owner *owner);
140
141
void
142
aout_RemoveMeterPlugin(audio_output_t *aout, vlc_audio_meter_plugin *plugin);
143
144
/* From common.c : */
145
void aout_FormatsPrint(vlc_object_t *, const char *,
146
                       const audio_sample_format_t *,
147
                       const audio_sample_format_t *);
148
#define aout_FormatsPrint(o, t, a, b) \
149
0
        aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
150
151
/* From dec.c */
152
0
#define AOUT_DEC_SUCCESS 0
153
0
#define AOUT_DEC_CHANGED 1
154
0
#define AOUT_DEC_FAILED VLC_EGENERIC
155
156
struct vlc_aout_stream_cfg
157
{
158
    const audio_sample_format_t *fmt;
159
    int profile;
160
    struct vlc_clock_t *clock;
161
    const char *str_id;
162
    const audio_replay_gain_t *replay_gain;
163
};
164
165
vlc_aout_stream *vlc_aout_stream_New(audio_output_t *p_aout,
166
                                     const struct vlc_aout_stream_cfg *cfg);
167
void vlc_aout_stream_Delete(vlc_aout_stream *);
168
int vlc_aout_stream_Play(vlc_aout_stream *stream, block_t *block);
169
void vlc_aout_stream_GetResetStats(vlc_aout_stream *stream, unsigned *, unsigned *);
170
void vlc_aout_stream_ChangePause(vlc_aout_stream *stream, bool b_paused, vlc_tick_t i_date);
171
void vlc_aout_stream_ChangeRate(vlc_aout_stream *stream, float rate);
172
void vlc_aout_stream_ChangeDelay(vlc_aout_stream *stream, vlc_tick_t delay);
173
void vlc_aout_stream_Flush(vlc_aout_stream *stream);
174
void vlc_aout_stream_Drain(vlc_aout_stream *stream);
175
/* Contrary to other vlc_aout_stream_*() functions, this function can be called from
176
 * any threads */
177
bool vlc_aout_stream_IsDrained(vlc_aout_stream *stream);
178
/* Called from output.c */
179
void vlc_aout_stream_NotifyTiming(vlc_aout_stream *stream, vlc_tick_t system_ts,
180
                                  vlc_tick_t audio_ts);
181
void vlc_aout_stream_NotifyDrained(vlc_aout_stream *stream);
182
void vlc_aout_stream_NotifyGain(vlc_aout_stream *stream, float gain);
183
184
void vlc_aout_stream_RequestRestart(vlc_aout_stream *stream, unsigned);
185
void vlc_aout_stream_RequestRetiming(vlc_aout_stream *stream, vlc_tick_t system_ts,
186
                                     vlc_tick_t audio_ts);
187
188
void aout_InputRequestRestart(audio_output_t *aout);
189
190
static inline void aout_SetWavePhysicalChannels(audio_sample_format_t *fmt)
191
0
{
192
0
    static const uint32_t wave_channels[] = {
193
0
        AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT, AOUT_CHAN_CENTER,
194
0
        AOUT_CHAN_LFE, AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
195
0
        AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT, AOUT_CHAN_REARCENTER };
196
197
0
    fmt->i_physical_channels = 0;
198
0
    for (int i = 0; i < fmt->i_channels && i < AOUT_CHAN_MAX; ++i)
199
0
        fmt->i_physical_channels |= wave_channels[i];
200
0
    aout_FormatPrepare(fmt);
201
0
}
Unexecuted instantiation: decoder.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: player.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: resource.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: common.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: dec.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: filters.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: meter.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: output.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: volume.c:aout_SetWavePhysicalChannels
Unexecuted instantiation: objects.c:aout_SetWavePhysicalChannels
202
203
/* From filters.c */
204
205
/* Extended version of aout_FiltersNew
206
 *
207
 * The clock, that is not mandatory, will be used to create a new slave clock
208
 * for the filter visualization plugins.
209
 */
210
aout_filters_t *aout_FiltersNewWithClock(vlc_object_t *, vlc_clock_t *,
211
                                         const audio_sample_format_t *,
212
                                         const audio_sample_format_t *,
213
                                         const aout_filters_cfg_t *cfg) VLC_USED;
214
void aout_FiltersResetClock(aout_filters_t *filters);
215
void aout_FiltersSetClockDelay(aout_filters_t *filters, vlc_tick_t delay);
216
bool aout_FiltersCanResample (aout_filters_t *filters);
217
filter_t *aout_filter_Create(vlc_object_t *obj, const filter_owner_t *restrict owner,
218
                             const char *type, const char *name,
219
                             const audio_sample_format_t *infmt,
220
                             const audio_sample_format_t *outfmt,
221
                             config_chain_t *cfg, bool const_fmt);
222
223
#endif /* !LIBVLC_AOUT_INTERNAL_H */