1 /*****************************************************************************
2 * aout_internal.h : internal defines for audio output
3 *****************************************************************************
4 * Copyright (C) 2002 the VideoLAN team
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 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 General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, 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)
31 AOUT_RESAMPLING_NONE=0,
38 struct vout_thread_t *(*pf_request_vout)( void *, struct vout_thread_t *,
39 video_format_t *, bool );
41 } aout_request_vout_t;
43 struct filter_owner_sys_t
45 audio_output_t *p_aout;
46 aout_input_t *p_input;
49 block_t *aout_FilterBufferNew( filter_t *, int );
51 /** an input stream for the audio output */
54 audio_sample_format_t input;
55 float multiplier; /**< Replay gain multiplier */
58 filter_t * pp_filters[AOUT_MAX_FILTERS];
61 filter_t * p_playback_rate_filter;
64 filter_t * pp_resamplers[AOUT_MAX_FILTERS];
66 int i_resampling_type;
67 mtime_t i_resamp_start_date;
68 int i_resamp_start_drift;
70 /* Mixer information */
71 audio_replay_gain_t replay_gain;
73 /* If b_restart == 1, the input pipeline will be re-created. */
76 /* If b_error == 1, there is no input pipeline. */
79 /* last rate from input */
80 int i_last_input_rate;
87 aout_request_vout_t request_vout;
96 module_t *module; /**< Output plugin (or NULL if inactive) */
102 float multiplier; /**< Software volume amplification multiplier */
103 struct audio_mixer *mixer; /**< Software volume plugin */
104 } volume; /**< Volume and gain management (FIXME: input manager?) */
106 audio_sample_format_t mixer_format;
108 /* Filters between mixer and output */
109 filter_t *filters[AOUT_MAX_FILTERS];
117 audio_output_t output;
121 static inline aout_owner_t *aout_owner (audio_output_t *aout)
123 return &((aout_instance_t *)aout)->owner;
126 /****************************************************************************
128 *****************************************************************************/
131 int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * );
132 int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input );
133 block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
134 block_t *p_buffer, int i_input_rate );
135 void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input );
137 /* From filters.c : */
138 int aout_FiltersCreatePipeline( audio_output_t *, filter_t **, int *,
139 const audio_sample_format_t *, const audio_sample_format_t * );
140 void aout_FiltersDestroyPipeline( filter_t *const *, unsigned );
141 void aout_FiltersPlay( filter_t *const *, unsigned, aout_buffer_t ** );
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);
149 /* From output.c : */
150 int aout_OutputNew( audio_output_t * p_aout,
151 const audio_sample_format_t * p_format );
152 void aout_OutputPlay( audio_output_t * p_aout, aout_buffer_t * p_buffer );
153 void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
154 void aout_OutputFlush( audio_output_t * p_aout, bool );
155 void aout_OutputDelete( audio_output_t * p_aout );
158 /* From common.c : */
159 /* Release with vlc_object_release() */
160 audio_output_t *aout_New ( vlc_object_t * );
161 #define aout_New(a) aout_New(VLC_OBJECT(a))
163 void aout_FifoInit( vlc_object_t *, aout_fifo_t *, uint32_t );
164 mtime_t aout_FifoFirstDate( const aout_fifo_t * ) VLC_USED;
165 #define aout_FifoInit(o, f, r) aout_FifoInit(VLC_OBJECT(o), f, r)
166 void aout_FifoPush( aout_fifo_t *, aout_buffer_t * );
167 aout_buffer_t *aout_FifoPop( aout_fifo_t * p_fifo ) VLC_USED;
168 void aout_FifoReset( aout_fifo_t * );
169 void aout_FifoMoveDates( aout_fifo_t *, mtime_t );
170 void aout_FifoDestroy( aout_fifo_t * p_fifo );
171 void aout_FormatsPrint( audio_output_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format1, const audio_sample_format_t * p_format2 );
172 bool aout_ChangeFilterString( vlc_object_t *, audio_output_t *, const char *psz_variable, const char *psz_name, bool b_add );
175 aout_input_t *aout_DecNew( audio_output_t *, audio_sample_format_t *,
176 const audio_replay_gain_t *, const aout_request_vout_t * );
177 void aout_DecDelete ( audio_output_t *, aout_input_t * );
178 aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
179 void aout_DecDeleteBuffer( audio_output_t *, aout_input_t *, aout_buffer_t * );
180 int aout_DecPlay( audio_output_t *, aout_input_t *, aout_buffer_t *, int i_input_rate );
181 int aout_DecGetResetLost( audio_output_t *, aout_input_t * );
182 void aout_DecChangePause( audio_output_t *, aout_input_t *, bool b_paused, mtime_t i_date );
183 void aout_DecFlush( audio_output_t *, aout_input_t * );
184 bool aout_DecIsEmpty( audio_output_t * p_aout, aout_input_t * p_input );
186 /* Audio output locking */
188 #if !defined (NDEBUG) \
189 && defined __linux__ && (defined (__i386__) || defined (__x86_64__))
190 # define AOUT_DEBUG 1
200 void aout_lock_check (unsigned);
201 void aout_unlock_check (unsigned);
204 # define aout_lock_check( i ) (void)0
205 # define aout_unlock_check( i ) (void)0
208 static inline void aout_lock( audio_output_t *p_aout )
210 aout_lock_check( OUTPUT_LOCK );
211 vlc_mutex_lock( &aout_owner(p_aout)->lock );
214 static inline void aout_unlock( audio_output_t *p_aout )
216 aout_unlock_check( OUTPUT_LOCK );
217 vlc_mutex_unlock( &aout_owner(p_aout)->lock );
220 static inline void aout_lock_volume( audio_output_t *p_aout )
222 aout_lock_check( VOLUME_LOCK );
223 vlc_mutex_lock( &aout_owner(p_aout)->volume.lock );
226 static inline void aout_unlock_volume( audio_output_t *p_aout )
228 aout_unlock_check( VOLUME_LOCK );
229 vlc_mutex_unlock( &aout_owner(p_aout)->volume.lock );
232 #define aout_assert_locked( aout ) \
233 vlc_assert_locked( &aout_owner(aout)->lock )
238 * This function will safely mark aout input to be restarted as soon as
239 * possible to take configuration changes into account */
240 static inline void AoutInputsMarkToRestart( audio_output_t *p_aout )
243 if( aout_owner(p_aout)->input != NULL )
244 aout_owner(p_aout)->input->b_restart = true;
245 aout_unlock( p_aout );
248 #endif /* !LIBVLC_AOUT_INTERNAL_H */