aout_internal.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * aout_internal.h : internal defines for audio output
00003  *****************************************************************************
00004  * Copyright (C) 2002 the VideoLAN team
00005  * $Id: 0d9da2a5641e1540e5e992202e3399fc0173b003 $
00006  *
00007  * Authors: Christophe Massiot <massiot@via.ecp.fr>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
00025 # error This header file can only be included from LibVLC.
00026 #endif
00027 
00028 #ifndef __LIBVLC_AOUT_INTERNAL_H
00029 # define __LIBVLC_AOUT_INTERNAL_H 1
00030 
00031 aout_buffer_t *aout_BufferAlloc(aout_alloc_t *allocation, mtime_t microseconds,
00032         aout_buffer_t *old_buffer);
00033 
00034 typedef struct
00035 {
00036     struct vout_thread_t  *(*pf_request_vout)( void *, struct vout_thread_t *,
00037                                                video_format_t *, bool );
00038     void *p_private;
00039 } aout_request_vout_t;
00040 
00041 struct filter_owner_sys_t
00042 {
00043     aout_instance_t *p_aout;
00044     aout_input_t    *p_input;
00045 };
00046 
00047 block_t *aout_FilterBufferNew( filter_t *, int );
00048 
00049 /** an input stream for the audio output */
00050 struct aout_input_t
00051 {
00052     /* When this lock is taken, the pipeline cannot be changed by a
00053      * third-party. */
00054     vlc_mutex_t             lock;
00055 
00056     audio_sample_format_t   input;
00057     aout_alloc_t            input_alloc;
00058 
00059     /* pre-filters */
00060     filter_t *              pp_filters[AOUT_MAX_FILTERS];
00061     int                     i_nb_filters;
00062 
00063     filter_t *              p_playback_rate_filter;
00064 
00065     /* resamplers */
00066     filter_t *              pp_resamplers[AOUT_MAX_FILTERS];
00067     int                     i_nb_resamplers;
00068     int                     i_resampling_type;
00069     mtime_t                 i_resamp_start_date;
00070     int                     i_resamp_start_drift;
00071 
00072     /* Mixer information */
00073     audio_replay_gain_t     replay_gain;
00074 
00075     /* If b_restart == 1, the input pipeline will be re-created. */
00076     bool              b_restart;
00077 
00078     /* If b_error == 1, there is no input pipeline. */
00079     bool              b_error;
00080 
00081     /* Did we just change the output format? (expect buffer inconsistencies) */
00082     bool              b_changed;
00083 
00084     /* last rate from input */
00085     int               i_last_input_rate;
00086 
00087     /* */
00088     int               i_buffer_lost;
00089 
00090     /* */
00091     bool              b_paused;
00092     mtime_t           i_pause_date;
00093 
00094     /* */
00095     bool                b_recycle_vout;
00096     aout_request_vout_t request_vout;
00097 
00098     /* */
00099     aout_mixer_input_t mixer;
00100  };
00101 
00102 /****************************************************************************
00103  * Prototypes
00104  *****************************************************************************/
00105 
00106 /* From input.c : */
00107 int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * );
00108 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input );
00109 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
00110                     aout_buffer_t * p_buffer, int i_input_rate );
00111 void aout_InputCheckAndRestart( aout_instance_t * p_aout, aout_input_t * p_input );
00112 
00113 /* From filters.c : */
00114 int aout_FiltersCreatePipeline ( aout_instance_t * p_aout, filter_t ** pp_filters, int * pi_nb_filters, const audio_sample_format_t * p_input_format, const audio_sample_format_t * p_output_format );
00115 void aout_FiltersDestroyPipeline ( aout_instance_t * p_aout, filter_t ** pp_filters, int i_nb_filters );
00116 void  aout_FiltersPlay ( filter_t ** pp_filters, unsigned i_nb_filters, aout_buffer_t ** pp_input_buffer );
00117 void aout_FiltersHintBuffers( aout_instance_t * p_aout, filter_t ** pp_filters, int i_nb_filters, aout_alloc_t * p_first_alloc );
00118 
00119 /* From mixer.c : */
00120 int aout_MixerNew( aout_instance_t * p_aout );
00121 void aout_MixerDelete( aout_instance_t * p_aout );
00122 void aout_MixerRun( aout_instance_t * p_aout );
00123 int aout_MixerMultiplierSet( aout_instance_t * p_aout, float f_multiplier );
00124 int aout_MixerMultiplierGet( aout_instance_t * p_aout, float * pf_multiplier );
00125 
00126 /* From output.c : */
00127 int aout_OutputNew( aout_instance_t * p_aout,
00128                     audio_sample_format_t * p_format );
00129 void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer );
00130 void aout_OutputDelete( aout_instance_t * p_aout );
00131 
00132 
00133 /* From common.c : */
00134 #define aout_New(a) __aout_New(VLC_OBJECT(a))
00135 /* Release with vlc_object_release() */
00136 aout_instance_t * __aout_New ( vlc_object_t * );
00137 
00138 void aout_FifoInit( aout_instance_t *, aout_fifo_t *, uint32_t );
00139 mtime_t aout_FifoNextStart( aout_instance_t *, aout_fifo_t * );
00140 void aout_FifoPush( aout_instance_t *, aout_fifo_t *, aout_buffer_t * );
00141 void aout_FifoSet( aout_instance_t *, aout_fifo_t *, mtime_t );
00142 void aout_FifoMoveDates( aout_instance_t *, aout_fifo_t *, mtime_t );
00143 void aout_FifoDestroy( aout_instance_t * p_aout, aout_fifo_t * p_fifo );
00144 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 );
00145 bool aout_ChangeFilterString( vlc_object_t *, aout_instance_t *, const char *psz_variable, const char *psz_name, bool b_add );
00146 
00147 /* From intf.c :*/
00148 int aout_VolumeSoftGet( aout_instance_t *, audio_volume_t * );
00149 int aout_VolumeSoftSet( aout_instance_t *, audio_volume_t );
00150 int aout_VolumeSoftInfos( aout_instance_t *, audio_volume_t * );
00151 int aout_VolumeNoneGet( aout_instance_t *, audio_volume_t * );
00152 int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t );
00153 int aout_VolumeNoneInfos( aout_instance_t *, audio_volume_t * );
00154 
00155 /* From dec.c */
00156 #define aout_DecNew(a, b, c, d, e) __aout_DecNew(VLC_OBJECT(a), b, c, d, e)
00157 aout_input_t * __aout_DecNew( vlc_object_t *, aout_instance_t **,
00158                               audio_sample_format_t *, const audio_replay_gain_t *,
00159                               const aout_request_vout_t * );
00160 int aout_DecDelete ( aout_instance_t *, aout_input_t * );
00161 aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
00162 void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * );
00163 int aout_DecPlay( aout_instance_t *, aout_input_t *, aout_buffer_t *, int i_input_rate );
00164 int aout_DecGetResetLost( aout_instance_t *, aout_input_t * );
00165 void aout_DecChangePause( aout_instance_t *, aout_input_t *, bool b_paused, mtime_t i_date );
00166 void aout_DecFlush( aout_instance_t *, aout_input_t * );
00167 
00168 /* Audio output locking */
00169 
00170 #if !defined (NDEBUG) \
00171  && defined __linux__ && (defined (__i386__) || defined (__x86_64__))
00172 # define AOUT_DEBUG 1
00173 #endif
00174 
00175 #ifdef AOUT_DEBUG
00176 enum
00177 {
00178     MIXER_LOCK=1,
00179     INPUT_LOCK=2,
00180     INPUT_FIFO_LOCK=4,
00181     OUTPUT_FIFO_LOCK=8,
00182     VOLUME_VARS_LOCK=16
00183 };
00184 
00185 void aout_lock (unsigned);
00186 void aout_unlock (unsigned);
00187 
00188 #else
00189 # define aout_lock( i )   (void)0
00190 # define aout_unlock( i ) (void)0
00191 #endif
00192 
00193 static inline void aout_lock_mixer( aout_instance_t *p_aout )
00194 {
00195     aout_lock( MIXER_LOCK );
00196     vlc_mutex_lock( &p_aout->mixer_lock );
00197 }
00198 
00199 static inline void aout_unlock_mixer( aout_instance_t *p_aout )
00200 {
00201     aout_unlock( MIXER_LOCK );
00202     vlc_mutex_unlock( &p_aout->mixer_lock );
00203 }
00204 
00205 static inline void aout_lock_input_fifos( aout_instance_t *p_aout )
00206 {
00207     aout_lock( INPUT_FIFO_LOCK );
00208     vlc_mutex_lock( &p_aout->input_fifos_lock );
00209 }
00210 
00211 static inline void aout_unlock_input_fifos( aout_instance_t *p_aout )
00212 {
00213     aout_unlock( INPUT_FIFO_LOCK );
00214     vlc_mutex_unlock( &p_aout->input_fifos_lock );
00215 }
00216 
00217 static inline void aout_lock_output_fifo( aout_instance_t *p_aout )
00218 {
00219     aout_lock( OUTPUT_FIFO_LOCK );
00220     vlc_mutex_lock( &p_aout->output_fifo_lock );
00221 }
00222 
00223 static inline void aout_unlock_output_fifo( aout_instance_t *p_aout )
00224 {
00225     aout_unlock( OUTPUT_FIFO_LOCK );
00226     vlc_mutex_unlock( &p_aout->output_fifo_lock );
00227 }
00228 
00229 static inline void aout_lock_input( aout_instance_t *p_aout, aout_input_t * p_input )
00230 {
00231     (void)p_aout;
00232     aout_lock( INPUT_LOCK );
00233     vlc_mutex_lock( &p_input->lock );
00234 }
00235 
00236 static inline void aout_unlock_input( aout_instance_t *p_aout, aout_input_t * p_input )
00237 {
00238     (void)p_aout;
00239     aout_unlock( INPUT_LOCK );
00240     vlc_mutex_unlock( &p_input->lock );
00241 }
00242 
00243 static inline void aout_lock_volume( aout_instance_t *p_aout )
00244 {
00245     aout_lock( VOLUME_VARS_LOCK );
00246     vlc_mutex_lock( &p_aout->volume_vars_lock );
00247 }
00248 
00249 static inline void aout_unlock_volume( aout_instance_t *p_aout )
00250 {
00251     aout_unlock( VOLUME_VARS_LOCK );
00252     vlc_mutex_unlock( &p_aout->volume_vars_lock );
00253 }
00254 
00255 /* Helpers */
00256 
00257 /**
00258  * This function will safely mark aout input to be restarted as soon as
00259  * possible to take configuration changes into account */
00260 static inline void AoutInputsMarkToRestart( aout_instance_t *p_aout )
00261 {
00262     int i;
00263     aout_lock_mixer( p_aout );
00264     for( i = 0; i < p_aout->i_nb_inputs; i++ )
00265         p_aout->pp_inputs[i]->b_restart = true;
00266     aout_unlock_mixer( p_aout );
00267 }
00268 
00269 #endif /* !__LIBVLC_AOUT_INTERNAL_H */

Generated on Mon Nov 22 07:55:20 2010 for VLC by  doxygen 1.5.6