Fixed a crash caused by yadif deinterlacer on Windows XP
[vlc/solaris.git] / src / audio_output / aout_internal.h
blob14ade82656b79a5d911cc4e03fab72ee8b7ccbfe
1 /*****************************************************************************
2 * aout_internal.h : internal defines for audio output
3 *****************************************************************************
4 * Copyright (C) 2002 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
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.
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.
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 *****************************************************************************/
24 #ifndef LIBVLC_AOUT_INTERNAL_H
25 # define LIBVLC_AOUT_INTERNAL_H 1
27 /* Max input rate factor (1/4 -> 4) */
28 # define AOUT_MAX_INPUT_RATE (4)
30 enum {
31 AOUT_RESAMPLING_NONE=0,
32 AOUT_RESAMPLING_UP,
33 AOUT_RESAMPLING_DOWN
36 typedef struct
38 struct vout_thread_t *(*pf_request_vout)( void *, struct vout_thread_t *,
39 video_format_t *, bool );
40 void *p_private;
41 } aout_request_vout_t;
43 struct filter_owner_sys_t
45 audio_output_t *p_aout;
46 aout_input_t *p_input;
49 /** an input stream for the audio output */
50 struct aout_input_t
52 unsigned samplerate; /**< Input sample rate */
54 /* pre-filters */
55 filter_t * pp_filters[AOUT_MAX_FILTERS];
56 int i_nb_filters;
58 filter_t * p_playback_rate_filter;
60 /* resamplers */
61 filter_t * pp_resamplers[AOUT_MAX_FILTERS];
62 int i_nb_resamplers;
63 int i_resampling_type;
64 mtime_t i_resamp_start_date;
65 int i_resamp_start_drift;
67 /* last rate from input */
68 int i_last_input_rate;
70 /* */
71 int i_buffer_lost;
73 /* */
74 bool b_recycle_vout;
75 aout_request_vout_t request_vout;
78 typedef struct
80 vlc_mutex_t lock;
81 module_t *module; /**< Output plugin (or NULL if inactive) */
82 aout_input_t *input;
84 struct
86 date_t date;
87 } sync;
89 struct
91 vlc_mutex_t lock;
92 float multiplier; /**< Software volume amplification multiplier */
93 struct audio_mixer *mixer; /**< Software volume plugin */
94 } volume;
96 struct
98 vlc_atomic_t multiplier;
99 audio_replay_gain_t data;
100 } gain;
102 audio_sample_format_t mixer_format;
103 audio_sample_format_t input_format;
105 /* Filters between mixer and output */
106 filter_t *filters[AOUT_MAX_FILTERS];
107 int nb_filters;
109 vlc_atomic_t restart;
110 } aout_owner_t;
112 typedef struct
114 audio_output_t output;
115 aout_owner_t owner;
116 } aout_instance_t;
118 static inline aout_owner_t *aout_owner (audio_output_t *aout)
120 return &((aout_instance_t *)aout)->owner;
123 /****************************************************************************
124 * Prototypes
125 *****************************************************************************/
127 /* From input.c : */
128 aout_input_t *aout_InputNew(audio_output_t *, const audio_sample_format_t *,
129 const audio_sample_format_t *,
130 const aout_request_vout_t *);
131 int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input );
132 block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
133 block_t *p_buffer, int i_input_rate, date_t * );
135 /* From filters.c : */
136 int aout_FiltersCreatePipeline( vlc_object_t *, filter_t **, int *,
137 const audio_sample_format_t *, const audio_sample_format_t * );
138 #define aout_FiltersCreatePipeline(o, pv, pc, inf, outf) \
139 aout_FiltersCreatePipeline(VLC_OBJECT(o), pv, pc, inf, outf)
140 void aout_FiltersDestroyPipeline( filter_t *const *, unsigned );
141 void aout_FiltersPlay( filter_t *const *, unsigned, aout_buffer_t ** );
143 /* From mixer.c : */
144 struct audio_mixer *aout_MixerNew(vlc_object_t *, vlc_fourcc_t);
145 #define aout_MixerNew(o, f) aout_MixerNew(VLC_OBJECT(o), f)
146 void aout_MixerDelete(struct audio_mixer *);
147 void aout_MixerRun(struct audio_mixer *, block_t *, float);
148 float aout_ReplayGainSelect(vlc_object_t *, const char *,
149 const audio_replay_gain_t *);
150 #define aout_ReplayGainSelect(o, s, g) \
151 aout_ReplayGainSelect(VLC_OBJECT(o), s, g)
153 static inline void aout_ReplayGainInit(audio_replay_gain_t *restrict d,
154 const audio_replay_gain_t *restrict s)
156 if (s != NULL)
157 *d = *s;
158 else
159 memset (d, 0, sizeof (*d));
163 /* From output.c : */
164 int aout_OutputNew( audio_output_t * p_aout,
165 const audio_sample_format_t * p_format );
166 void aout_OutputPlay( audio_output_t * p_aout, aout_buffer_t * p_buffer );
167 void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
168 void aout_OutputFlush( audio_output_t * p_aout, bool );
169 void aout_OutputDelete( audio_output_t * p_aout );
172 /* From common.c : */
173 audio_output_t *aout_New (vlc_object_t *);
174 #define aout_New(a) aout_New(VLC_OBJECT(a))
175 void aout_Destroy (audio_output_t *);
177 void aout_FifoInit( vlc_object_t *, aout_fifo_t *, uint32_t );
178 mtime_t aout_FifoFirstDate( const aout_fifo_t * ) VLC_USED;
179 #define aout_FifoInit(o, f, r) aout_FifoInit(VLC_OBJECT(o), f, r)
180 void aout_FifoPush( aout_fifo_t *, aout_buffer_t * );
181 aout_buffer_t *aout_FifoPop( aout_fifo_t * p_fifo ) VLC_USED;
182 void aout_FifoReset( aout_fifo_t * );
183 void aout_FifoMoveDates( aout_fifo_t *, mtime_t );
184 void aout_FifoDestroy( aout_fifo_t * p_fifo );
185 void aout_FormatsPrint(vlc_object_t *, const char *,
186 const audio_sample_format_t *,
187 const audio_sample_format_t *);
188 #define aout_FormatsPrint(o, t, a, b) \
189 aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
190 bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout,
191 const char *var, const char *name, bool b_add );
193 /* From dec.c */
194 int aout_DecNew(audio_output_t *, const audio_sample_format_t *,
195 const audio_replay_gain_t *, const aout_request_vout_t *);
196 void aout_DecDelete(audio_output_t *);
197 block_t *aout_DecNewBuffer(audio_output_t *, size_t);
198 void aout_DecDeleteBuffer(audio_output_t *, block_t *);
199 int aout_DecPlay(audio_output_t *, block_t *, int i_input_rate);
200 int aout_DecGetResetLost(audio_output_t *);
201 void aout_DecChangePause(audio_output_t *, bool b_paused, mtime_t i_date);
202 void aout_DecFlush(audio_output_t *);
203 bool aout_DecIsEmpty(audio_output_t *);
205 void aout_InputRequestRestart(audio_output_t *);
206 void aout_RequestRestart(audio_output_t *);
207 void aout_Shutdown (audio_output_t *);
209 /* Audio output locking */
211 #if !defined (NDEBUG) \
212 && defined __linux__ && (defined (__i386__) || defined (__x86_64__))
213 # define AOUT_DEBUG 1
214 #endif
216 #ifdef AOUT_DEBUG
217 enum
219 OUTPUT_LOCK=1,
220 VOLUME_LOCK=2,
223 void aout_lock_check (unsigned);
224 void aout_unlock_check (unsigned);
226 #else
227 # define aout_lock_check( i ) (void)0
228 # define aout_unlock_check( i ) (void)0
229 #endif
231 static inline void aout_lock( audio_output_t *p_aout )
233 aout_lock_check( OUTPUT_LOCK );
234 vlc_mutex_lock( &aout_owner(p_aout)->lock );
237 static inline void aout_unlock( audio_output_t *p_aout )
239 aout_unlock_check( OUTPUT_LOCK );
240 vlc_mutex_unlock( &aout_owner(p_aout)->lock );
243 static inline void aout_lock_volume( audio_output_t *p_aout )
245 aout_lock_check( VOLUME_LOCK );
246 vlc_mutex_lock( &aout_owner(p_aout)->volume.lock );
249 static inline void aout_unlock_volume( audio_output_t *p_aout )
251 aout_unlock_check( VOLUME_LOCK );
252 vlc_mutex_unlock( &aout_owner(p_aout)->volume.lock );
255 #define aout_assert_locked( aout ) \
256 vlc_assert_locked( &aout_owner(aout)->lock )
258 #endif /* !LIBVLC_AOUT_INTERNAL_H */