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 # include <vlc_aout_mixer.h>
31 struct vout_thread_t *(*pf_request_vout)( void *, struct vout_thread_t *,
32 video_format_t *, bool );
34 } aout_request_vout_t;
36 struct filter_owner_sys_t
38 aout_instance_t *p_aout;
39 aout_input_t *p_input;
42 block_t *aout_FilterBufferNew( filter_t *, int );
44 /** an input stream for the audio output */
47 /* When this lock is taken, the pipeline cannot be changed by a
51 audio_sample_format_t input;
54 filter_t * pp_filters[AOUT_MAX_FILTERS];
57 filter_t * p_playback_rate_filter;
60 filter_t * pp_resamplers[AOUT_MAX_FILTERS];
62 int i_resampling_type;
63 mtime_t i_resamp_start_date;
64 int i_resamp_start_drift;
66 /* Mixer information */
67 audio_replay_gain_t replay_gain;
69 /* If b_restart == 1, the input pipeline will be re-created. */
72 /* If b_error == 1, there is no input pipeline. */
75 /* last rate from input */
76 int i_last_input_rate;
87 aout_request_vout_t request_vout;
90 aout_mixer_input_t mixer;
93 /****************************************************************************
95 *****************************************************************************/
98 int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * );
99 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input );
100 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
101 aout_buffer_t * p_buffer, int i_input_rate );
102 void aout_InputCheckAndRestart( aout_instance_t * p_aout, aout_input_t * p_input );
103 bool aout_InputIsEmpty( aout_instance_t * p_aout, aout_input_t * p_input );
105 /* From filters.c : */
106 int aout_FiltersCreatePipeline( aout_instance_t *, filter_t **, int *,
107 const audio_sample_format_t *, const audio_sample_format_t * );
108 void aout_FiltersDestroyPipeline( filter_t *const *, unsigned );
109 void aout_FiltersPlay( filter_t *const *, unsigned, aout_buffer_t ** );
112 int aout_MixerNew( aout_instance_t * p_aout );
113 void aout_MixerDelete( aout_instance_t * p_aout );
114 void aout_MixerRun( aout_instance_t * p_aout, float );
116 /* From output.c : */
117 int aout_OutputNew( aout_instance_t * p_aout,
118 const audio_sample_format_t * p_format );
119 void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer );
120 void aout_OutputDelete( aout_instance_t * p_aout );
123 /* From common.c : */
124 #define aout_New(a) __aout_New(VLC_OBJECT(a))
125 /* Release with vlc_object_release() */
126 aout_instance_t * __aout_New ( vlc_object_t * );
128 void aout_FifoInit( vlc_object_t *, aout_fifo_t *, uint32_t );
129 #define aout_FifoInit(o, f, r) aout_FifoInit(VLC_OBJECT(o), f, r)
130 mtime_t aout_FifoNextStart( const aout_fifo_t * ) VLC_USED;
131 void aout_FifoPush( aout_fifo_t *, aout_buffer_t * );
132 void aout_FifoSet( aout_fifo_t *, mtime_t );
133 void aout_FifoMoveDates( aout_fifo_t *, mtime_t );
134 void aout_FifoDestroy( aout_fifo_t * p_fifo );
135 void aout_FormatsPrint( aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format1, const audio_sample_format_t * p_format2 );
136 bool aout_ChangeFilterString( vlc_object_t *, aout_instance_t *, const char *psz_variable, const char *psz_name, bool b_add );
139 aout_input_t *aout_DecNew( aout_instance_t *, audio_sample_format_t *,
140 const audio_replay_gain_t *, const aout_request_vout_t * );
141 int aout_DecDelete ( aout_instance_t *, aout_input_t * );
142 aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
143 void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * );
144 int aout_DecPlay( aout_instance_t *, aout_input_t *, aout_buffer_t *, int i_input_rate );
145 int aout_DecGetResetLost( aout_instance_t *, aout_input_t * );
146 void aout_DecChangePause( aout_instance_t *, aout_input_t *, bool b_paused, mtime_t i_date );
147 void aout_DecFlush( aout_instance_t *, aout_input_t * );
149 /* Audio output locking */
151 #if !defined (NDEBUG) \
152 && defined __linux__ && (defined (__i386__) || defined (__x86_64__))
153 # define AOUT_DEBUG 1
166 void aout_lock (unsigned);
167 void aout_unlock (unsigned);
170 # define aout_lock( i ) (void)0
171 # define aout_unlock( i ) (void)0
174 static inline void aout_lock_mixer( aout_instance_t *p_aout )
176 aout_lock( MIXER_LOCK );
177 vlc_mutex_lock( &p_aout->mixer_lock );
180 static inline void aout_unlock_mixer( aout_instance_t *p_aout )
182 aout_unlock( MIXER_LOCK );
183 vlc_mutex_unlock( &p_aout->mixer_lock );
186 static inline void aout_lock_input_fifos( aout_instance_t *p_aout )
188 aout_lock( INPUT_FIFO_LOCK );
189 vlc_mutex_lock( &p_aout->input_fifos_lock );
192 static inline void aout_unlock_input_fifos( aout_instance_t *p_aout )
194 aout_unlock( INPUT_FIFO_LOCK );
195 vlc_mutex_unlock( &p_aout->input_fifos_lock );
198 static inline void aout_lock_output_fifo( aout_instance_t *p_aout )
200 aout_lock( OUTPUT_FIFO_LOCK );
201 vlc_mutex_lock( &p_aout->output_fifo_lock );
204 static inline void aout_unlock_output_fifo( aout_instance_t *p_aout )
206 aout_unlock( OUTPUT_FIFO_LOCK );
207 vlc_mutex_unlock( &p_aout->output_fifo_lock );
210 static inline void aout_lock_input( aout_instance_t *p_aout, aout_input_t * p_input )
213 aout_lock( INPUT_LOCK );
214 vlc_mutex_lock( &p_input->lock );
217 static inline void aout_unlock_input( aout_instance_t *p_aout, aout_input_t * p_input )
220 aout_unlock( INPUT_LOCK );
221 vlc_mutex_unlock( &p_input->lock );
224 static inline void aout_lock_volume( aout_instance_t *p_aout )
226 aout_lock( VOLUME_VARS_LOCK );
227 vlc_mutex_lock( &p_aout->volume_vars_lock );
230 static inline void aout_unlock_volume( aout_instance_t *p_aout )
232 aout_unlock( VOLUME_VARS_LOCK );
233 vlc_mutex_unlock( &p_aout->volume_vars_lock );
239 * This function will safely mark aout input to be restarted as soon as
240 * possible to take configuration changes into account */
241 static inline void AoutInputsMarkToRestart( aout_instance_t *p_aout )
243 aout_lock_mixer( p_aout );
244 if( p_aout->p_input != NULL )
245 p_aout->p_input->b_restart = true;
246 aout_unlock_mixer( p_aout );
249 #endif /* !LIBVLC_AOUT_INTERNAL_H */