]> git.sesse.net Git - vlc/blob - src/audio_output/aout_internal.h
aout: remove aout_mixer_input_t (no functional changes)
[vlc] / src / audio_output / aout_internal.h
1 /*****************************************************************************
2  * aout_internal.h : internal defines for audio output
3  *****************************************************************************
4  * Copyright (C) 2002 the VideoLAN team
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
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.
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 General Public License for more details.
18  *
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  *****************************************************************************/
23
24 #ifndef LIBVLC_AOUT_INTERNAL_H
25 # define LIBVLC_AOUT_INTERNAL_H 1
26
27 /* Max input rate factor (1/4 -> 4) */
28 # define AOUT_MAX_INPUT_RATE (4)
29
30 enum {
31     AOUT_RESAMPLING_NONE=0,
32     AOUT_RESAMPLING_UP,
33     AOUT_RESAMPLING_DOWN
34 };
35
36 # include <vlc_aout_mixer.h>
37
38 typedef struct
39 {
40     struct vout_thread_t  *(*pf_request_vout)( void *, struct vout_thread_t *,
41                                                video_format_t *, bool );
42     void *p_private;
43 } aout_request_vout_t;
44
45 struct filter_owner_sys_t
46 {
47     audio_output_t *p_aout;
48     aout_input_t    *p_input;
49 };
50
51 block_t *aout_FilterBufferNew( filter_t *, int );
52
53 /** an input stream for the audio output */
54 struct aout_input_t
55 {
56     audio_sample_format_t   input;
57     float                   multiplier; /**< Replay gain multiplier */
58
59     /* pre-filters */
60     filter_t *              pp_filters[AOUT_MAX_FILTERS];
61     int                     i_nb_filters;
62
63     filter_t *              p_playback_rate_filter;
64
65     /* resamplers */
66     filter_t *              pp_resamplers[AOUT_MAX_FILTERS];
67     int                     i_nb_resamplers;
68     int                     i_resampling_type;
69     mtime_t                 i_resamp_start_date;
70     int                     i_resamp_start_drift;
71
72     /* Mixer information */
73     audio_replay_gain_t     replay_gain;
74
75     /* If b_restart == 1, the input pipeline will be re-created. */
76     bool              b_restart;
77
78     /* If b_error == 1, there is no input pipeline. */
79     bool              b_error;
80
81     /* last rate from input */
82     int               i_last_input_rate;
83
84     /* */
85     int               i_buffer_lost;
86
87     /* */
88     bool              b_paused;
89     mtime_t           i_pause_date;
90
91     /* */
92     bool                b_recycle_vout;
93     aout_request_vout_t request_vout;
94
95     /* */
96     aout_fifo_t       fifo;
97  };
98
99 /****************************************************************************
100  * Prototypes
101  *****************************************************************************/
102
103 /* From input.c : */
104 int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * );
105 int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input );
106 void aout_InputPlay( audio_output_t * p_aout, aout_input_t * p_input,
107                      aout_buffer_t * p_buffer, int i_input_rate );
108 void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input );
109
110 /* From filters.c : */
111 int aout_FiltersCreatePipeline( audio_output_t *, filter_t **, int *,
112     const audio_sample_format_t *, const audio_sample_format_t * );
113 void aout_FiltersDestroyPipeline( filter_t *const *, unsigned );
114 void aout_FiltersPlay( filter_t *const *, unsigned, aout_buffer_t ** );
115
116 /* From mixer.c : */
117 int aout_MixerNew( audio_output_t * p_aout );
118 void aout_MixerDelete( audio_output_t * p_aout );
119 void aout_MixerRun( audio_output_t * p_aout, float );
120
121 /* From output.c : */
122 int aout_OutputNew( audio_output_t * p_aout,
123                     const audio_sample_format_t * p_format );
124 void aout_OutputPlay( audio_output_t * p_aout, aout_buffer_t * p_buffer );
125 void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
126 void aout_OutputDelete( audio_output_t * p_aout );
127
128
129 /* From common.c : */
130 /* Release with vlc_object_release() */
131 audio_output_t *aout_New ( vlc_object_t * );
132 #define aout_New(a) aout_New(VLC_OBJECT(a))
133
134 void aout_FifoInit( vlc_object_t *, aout_fifo_t *, uint32_t );
135 #define aout_FifoInit(o, f, r) aout_FifoInit(VLC_OBJECT(o), f, r)
136 mtime_t aout_FifoNextStart( const aout_fifo_t * ) VLC_USED;
137 void aout_FifoPush( aout_fifo_t *, aout_buffer_t * );
138 void aout_FifoSet( aout_fifo_t *, mtime_t );
139 void aout_FifoMoveDates( aout_fifo_t *, mtime_t );
140 void aout_FifoDestroy( aout_fifo_t * p_fifo );
141 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 );
142 bool aout_ChangeFilterString( vlc_object_t *, audio_output_t *, const char *psz_variable, const char *psz_name, bool b_add );
143
144 /* From dec.c */
145 aout_input_t *aout_DecNew( audio_output_t *, audio_sample_format_t *,
146                    const audio_replay_gain_t *, const aout_request_vout_t * );
147 void aout_DecDelete ( audio_output_t *, aout_input_t * );
148 aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
149 void aout_DecDeleteBuffer( audio_output_t *, aout_input_t *, aout_buffer_t * );
150 int aout_DecPlay( audio_output_t *, aout_input_t *, aout_buffer_t *, int i_input_rate );
151 int aout_DecGetResetLost( audio_output_t *, aout_input_t * );
152 void aout_DecChangePause( audio_output_t *, aout_input_t *, bool b_paused, mtime_t i_date );
153 void aout_DecFlush( audio_output_t *, aout_input_t * );
154 bool aout_DecIsEmpty( audio_output_t * p_aout, aout_input_t * p_input );
155
156 /* Audio output locking */
157
158 #if !defined (NDEBUG) \
159  && defined __linux__ && (defined (__i386__) || defined (__x86_64__))
160 # define AOUT_DEBUG 1
161 #endif
162
163 #ifdef AOUT_DEBUG
164 enum
165 {
166     OUTPUT_LOCK=1,
167     VOLUME_LOCK=2,
168 };
169
170 void aout_lock_check (unsigned);
171 void aout_unlock_check (unsigned);
172
173 #else
174 # define aout_lock_check( i )   (void)0
175 # define aout_unlock_check( i ) (void)0
176 #endif
177
178 static inline void aout_lock( audio_output_t *p_aout )
179 {
180     aout_lock_check( OUTPUT_LOCK );
181     vlc_mutex_lock( &p_aout->lock );
182 }
183
184 static inline void aout_unlock( audio_output_t *p_aout )
185 {
186     aout_unlock_check( OUTPUT_LOCK );
187     vlc_mutex_unlock( &p_aout->lock );
188 }
189
190 static inline void aout_lock_volume( audio_output_t *p_aout )
191 {
192     aout_lock_check( VOLUME_LOCK );
193     vlc_mutex_lock( &p_aout->volume_lock );
194 }
195
196 static inline void aout_unlock_volume( audio_output_t *p_aout )
197 {
198     aout_unlock_check( VOLUME_LOCK );
199     vlc_mutex_unlock( &p_aout->volume_lock );
200 }
201
202 /* Helpers */
203
204 /**
205  * This function will safely mark aout input to be restarted as soon as
206  * possible to take configuration changes into account */
207 static inline void AoutInputsMarkToRestart( audio_output_t *p_aout )
208 {
209     aout_lock( p_aout );
210     if( p_aout->p_input != NULL )
211         p_aout->p_input->b_restart = true;
212     aout_unlock( p_aout );
213 }
214
215 #endif /* !LIBVLC_AOUT_INTERNAL_H */