]> git.sesse.net Git - vlc/blob - src/audio_output/aout_internal.h
aout: drop remnants of foreign endian support (refs #7764)
[vlc] / src / audio_output / aout_internal.h
1 /*****************************************************************************
2  * aout_internal.h : internal defines for audio output
3  *****************************************************************************
4  * Copyright (C) 2002 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef LIBVLC_AOUT_INTERNAL_H
25 # define LIBVLC_AOUT_INTERNAL_H 1
26
27 # include <vlc_atomic.h>
28
29 /* Max input rate factor (1/4 -> 4) */
30 # define AOUT_MAX_INPUT_RATE (4)
31
32 # define AOUT_MAX_FILTERS 10
33
34 enum {
35     AOUT_RESAMPLING_NONE=0,
36     AOUT_RESAMPLING_UP,
37     AOUT_RESAMPLING_DOWN
38 };
39
40 typedef struct
41 {
42     struct vout_thread_t  *(*pf_request_vout)( void *, struct vout_thread_t *,
43                                                video_format_t *, bool );
44     void *p_private;
45 } aout_request_vout_t;
46
47 typedef struct aout_volume aout_volume_t;
48
49 typedef struct
50 {
51     vlc_mutex_t lock;
52     module_t *module; /**< Output plugin (or NULL if inactive) */
53     aout_volume_t *volume;
54
55     struct
56     {
57         mtime_t end; /**< Last seen PTS */
58         unsigned resamp_start_drift; /**< Resampler drift absolute value */
59         int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */
60         bool discontinuity;
61     } sync;
62
63     audio_sample_format_t input_format;
64     audio_sample_format_t mixer_format;
65
66     filter_t *rate_filter; /**< The filter adjusting samples count
67         (either the scaletempo filter or a resampler) */
68     filter_t *resampler; /**< The resampler */
69     int resampling; /**< Current resampling (Hz) */
70     unsigned nb_filters;
71     filter_t *filters[AOUT_MAX_FILTERS]; /**< Configured user filters
72         (e.g. equalization) and their conversions */
73
74     aout_request_vout_t request_vout;
75     bool recycle_vout;
76
77     atomic_uint buffers_lost;
78     atomic_uchar restart;
79 } aout_owner_t;
80
81 typedef struct
82 {
83     audio_output_t output;
84     aout_owner_t   owner;
85 } aout_instance_t;
86
87 static inline aout_owner_t *aout_owner (audio_output_t *aout)
88 {
89     return &((aout_instance_t *)aout)->owner;
90 }
91
92 /****************************************************************************
93  * Prototypes
94  *****************************************************************************/
95
96 /* From filters.c : */
97 int aout_FiltersNew(audio_output_t *, const audio_sample_format_t *,
98                    const audio_sample_format_t *, const aout_request_vout_t *);
99 void aout_FiltersDelete(audio_output_t *);
100 bool aout_FiltersAdjustResampling(audio_output_t *, int);
101 block_t *aout_FiltersPlay(audio_output_t *, block_t *, int rate);
102
103 /* From mixer.c : */
104 aout_volume_t *aout_volume_New(vlc_object_t *, const audio_replay_gain_t *);
105 #define aout_volume_New(o, g) aout_volume_New(VLC_OBJECT(o), g)
106 int aout_volume_SetFormat(aout_volume_t *, vlc_fourcc_t);
107 void aout_volume_SetVolume(aout_volume_t *, float);
108 int aout_volume_Amplify(aout_volume_t *, block_t *);
109 void aout_volume_Delete(aout_volume_t *);
110
111
112 /* From output.c : */
113 audio_output_t *aout_New (vlc_object_t *);
114 #define aout_New(a) aout_New(VLC_OBJECT(a))
115 void aout_Destroy (audio_output_t *);
116
117 int aout_OutputNew(audio_output_t *, audio_sample_format_t *);
118 int aout_OutputTimeGet(audio_output_t *, mtime_t *);
119 void aout_OutputPlay(audio_output_t *, block_t *);
120 void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
121 void aout_OutputFlush( audio_output_t * p_aout, bool );
122 void aout_OutputDelete( audio_output_t * p_aout );
123
124
125 /* From common.c : */
126 void aout_FormatsPrint(vlc_object_t *, const char *,
127                        const audio_sample_format_t *,
128                        const audio_sample_format_t *);
129 #define aout_FormatsPrint(o, t, a, b) \
130         aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
131 bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout,
132                               const char *var, const char *name, bool b_add );
133
134 /* From dec.c */
135 int aout_DecNew(audio_output_t *, const audio_sample_format_t *,
136                 const audio_replay_gain_t *, const aout_request_vout_t *);
137 void aout_DecDelete(audio_output_t *);
138 block_t *aout_DecNewBuffer(audio_output_t *, size_t);
139 void aout_DecDeleteBuffer(audio_output_t *, block_t *);
140 int aout_DecPlay(audio_output_t *, block_t *, int i_input_rate);
141 int aout_DecGetResetLost(audio_output_t *);
142 void aout_DecChangePause(audio_output_t *, bool b_paused, mtime_t i_date);
143 void aout_DecFlush(audio_output_t *);
144 bool aout_DecIsEmpty(audio_output_t *);
145 void aout_RequestRestart (audio_output_t *, unsigned);
146
147 static inline void aout_InputRequestRestart(audio_output_t *aout)
148 {
149     aout_RequestRestart(aout, AOUT_RESTART_FILTERS);
150 }
151
152 /* Audio output locking */
153 static inline void aout_lock( audio_output_t *p_aout )
154 {
155     vlc_mutex_lock( &aout_owner(p_aout)->lock );
156 }
157
158 static inline void aout_unlock( audio_output_t *p_aout )
159 {
160     vlc_mutex_unlock( &aout_owner(p_aout)->lock );
161 }
162
163 #define aout_assert_locked( aout ) \
164         vlc_assert_locked( &aout_owner(aout)->lock )
165
166 #endif /* !LIBVLC_AOUT_INTERNAL_H */