00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef VLC_AOUT_H
00025 #define VLC_AOUT_H 1
00026
00027 # ifdef __cplusplus
00028 extern "C" {
00029 # endif
00030
00031 #include "vlc_es.h"
00032
00033 #define AOUT_FMTS_IDENTICAL( p_first, p_second ) ( \
00034 ((p_first)->i_format == (p_second)->i_format) \
00035 && ((p_first)->i_rate == (p_second)->i_rate) \
00036 && ((p_first)->i_physical_channels == (p_second)->i_physical_channels)\
00037 && ((p_first)->i_original_channels == (p_second)->i_original_channels) )
00038
00039
00040 #define AOUT_FMTS_SIMILAR( p_first, p_second ) ( \
00041 ((p_first)->i_rate == (p_second)->i_rate) \
00042 && ((p_first)->i_physical_channels == (p_second)->i_physical_channels)\
00043 && ((p_first)->i_original_channels == (p_second)->i_original_channels) )
00044
00045 #ifdef WORDS_BIGENDIAN
00046 # define AOUT_FMT_S16_NE VLC_FOURCC('s','1','6','b')
00047 # define AOUT_FMT_U16_NE VLC_FOURCC('u','1','6','b')
00048 # define AOUT_FMT_S24_NE VLC_FOURCC('s','2','4','b')
00049 # define AOUT_FMT_SPDIF_NE VLC_FOURCC('s','p','d','b')
00050 #else
00051 # define AOUT_FMT_S16_NE VLC_FOURCC('s','1','6','l')
00052 # define AOUT_FMT_U16_NE VLC_FOURCC('u','1','6','l')
00053 # define AOUT_FMT_S24_NE VLC_FOURCC('s','2','4','l')
00054 # define AOUT_FMT_SPDIF_NE VLC_FOURCC('s','p','d','i')
00055 #endif
00056
00057 #define AOUT_FMT_NON_LINEAR( p_format ) \
00058 ( ((p_format)->i_format == VLC_FOURCC('s','p','d','i')) \
00059 || ((p_format)->i_format == VLC_FOURCC('s','p','d','b')) \
00060 || ((p_format)->i_format == VLC_FOURCC('a','5','2',' ')) \
00061 || ((p_format)->i_format == VLC_FOURCC('d','t','s',' ')) )
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 typedef int32_t vlc_fixed_t;
00084 #define FIXED32_FRACBITS 28
00085 #define FIXED32_MIN ((vlc_fixed_t) -0x80000000L)
00086 #define FIXED32_MAX ((vlc_fixed_t) +0x7fffffffL)
00087 #define FIXED32_ONE ((vlc_fixed_t) 0x10000000)
00088
00089
00090
00091
00092
00093
00094
00095 #define AOUT_CHAN_CENTER 0x1
00096 #define AOUT_CHAN_LEFT 0x2
00097 #define AOUT_CHAN_RIGHT 0x4
00098 #define AOUT_CHAN_REARCENTER 0x10
00099 #define AOUT_CHAN_REARLEFT 0x20
00100 #define AOUT_CHAN_REARRIGHT 0x40
00101 #define AOUT_CHAN_MIDDLELEFT 0x100
00102 #define AOUT_CHAN_MIDDLERIGHT 0x200
00103 #define AOUT_CHAN_LFE 0x1000
00104
00105
00106 #define AOUT_CHAN_DOLBYSTEREO 0x10000
00107 #define AOUT_CHAN_DUALMONO 0x20000
00108 #define AOUT_CHAN_REVERSESTEREO 0x40000
00109
00110 #define AOUT_CHAN_PHYSMASK 0xFFFF
00111 #define AOUT_CHAN_MAX 9
00112
00113
00114 #define AOUT_VAR_MONO 1
00115 #define AOUT_VAR_STEREO 2
00116 #define AOUT_VAR_2F2R 4
00117 #define AOUT_VAR_3F2R 5
00118 #define AOUT_VAR_5_1 6
00119 #define AOUT_VAR_6_1 7
00120 #define AOUT_VAR_7_1 8
00121 #define AOUT_VAR_SPDIF 10
00122
00123 #define AOUT_VAR_CHAN_STEREO 1
00124 #define AOUT_VAR_CHAN_RSTEREO 2
00125 #define AOUT_VAR_CHAN_LEFT 3
00126 #define AOUT_VAR_CHAN_RIGHT 4
00127 #define AOUT_VAR_CHAN_DOLBYS 5
00128
00129
00130
00131
00132
00133
00134 struct aout_buffer_t
00135 {
00136 uint8_t * p_buffer;
00137 int i_alloc_type;
00138
00139
00140 size_t i_size, i_nb_bytes;
00141 unsigned int i_nb_samples;
00142 mtime_t start_date, end_date;
00143 bool b_discontinuity;
00144
00145 struct aout_buffer_t * p_next;
00146
00147
00148
00149 void * p_sys;
00150
00151
00152 void (*pf_release)( aout_buffer_t * );
00153 };
00154
00155 #define aout_BufferFree( p_buffer ) do { \
00156 if( p_buffer != NULL && (p_buffer)->i_alloc_type == AOUT_ALLOC_HEAP ) \
00157 { \
00158 free( p_buffer ); \
00159 } \
00160 p_buffer = NULL; } while(0)
00161
00162
00163 #define AOUT_SPDIF_SIZE 6144
00164
00165
00166 #define A52_FRAME_NB 1536
00167
00168
00169 #define AOUT_MAX_INPUT_RATE (4)
00170
00171
00172
00173
00174 struct audio_date_t
00175 {
00176 mtime_t date;
00177 uint32_t i_divider;
00178 uint32_t i_remainder;
00179 };
00180
00181
00182 typedef struct aout_alloc_t
00183 {
00184 int i_alloc_type;
00185 int i_bytes_per_sec;
00186 } aout_alloc_t;
00187
00188 #define AOUT_ALLOC_NONE 0
00189 #define AOUT_ALLOC_STACK 1
00190 #define AOUT_ALLOC_HEAP 2
00191
00192
00193 typedef struct aout_mixer_t
00194 {
00195 audio_sample_format_t mixer;
00196 aout_alloc_t output_alloc;
00197
00198 module_t * p_module;
00199 struct aout_mixer_sys_t * p_sys;
00200 void (* pf_do_work)( struct aout_instance_t *,
00201 struct aout_buffer_t * );
00202
00203
00204 bool b_error;
00205
00206
00207
00208 float f_multiplier;
00209 } aout_mixer_t;
00210
00211
00212 struct aout_fifo_t
00213 {
00214 aout_buffer_t * p_first;
00215 aout_buffer_t ** pp_last;
00216 audio_date_t end_date;
00217 };
00218
00219
00220 struct aout_filter_t
00221 {
00222 VLC_COMMON_MEMBERS
00223
00224 audio_sample_format_t input;
00225 audio_sample_format_t output;
00226 aout_alloc_t output_alloc;
00227
00228 module_t * p_module;
00229 struct aout_filter_sys_t * p_sys;
00230 void (* pf_do_work)( struct aout_instance_t *,
00231 struct aout_filter_t *,
00232 struct aout_buffer_t *,
00233 struct aout_buffer_t * );
00234 bool b_in_place;
00235 bool b_continuity;
00236 };
00237
00238 #define AOUT_RESAMPLING_NONE 0
00239 #define AOUT_RESAMPLING_UP 1
00240 #define AOUT_RESAMPLING_DOWN 2
00241
00242 struct aout_input_t
00243 {
00244
00245
00246 vlc_mutex_t lock;
00247
00248
00249 input_thread_t *p_input_thread;
00250
00251 audio_sample_format_t input;
00252 aout_alloc_t input_alloc;
00253
00254
00255 aout_filter_t * pp_filters[AOUT_MAX_FILTERS];
00256 int i_nb_filters;
00257
00258 aout_filter_t * p_playback_rate_filter;
00259
00260
00261 aout_filter_t * pp_resamplers[AOUT_MAX_FILTERS];
00262 int i_nb_resamplers;
00263 int i_resampling_type;
00264 mtime_t i_resamp_start_date;
00265 int i_resamp_start_drift;
00266
00267 aout_fifo_t fifo;
00268
00269
00270 uint8_t * p_first_byte_to_mix;
00271 audio_replay_gain_t replay_gain;
00272 float f_multiplier;
00273
00274
00275 bool b_restart;
00276
00277
00278 bool b_error;
00279
00280
00281 bool b_changed;
00282
00283
00284 int i_last_input_rate;
00285
00286 int i_pts_delay;
00287
00288 int i_desync;
00289
00290 };
00291
00292
00293 typedef struct aout_output_t
00294 {
00295 audio_sample_format_t output;
00296
00297
00298 bool b_starving;
00299
00300
00301 aout_filter_t * pp_filters[AOUT_MAX_FILTERS];
00302 int i_nb_filters;
00303
00304 aout_fifo_t fifo;
00305
00306 struct module_t * p_module;
00307 struct aout_sys_t * p_sys;
00308 void (* pf_play)( aout_instance_t * );
00309 int (* pf_volume_get )( aout_instance_t *, audio_volume_t * );
00310 int (* pf_volume_set )( aout_instance_t *, audio_volume_t );
00311 int (* pf_volume_infos )( aout_instance_t *, audio_volume_t * );
00312 int i_nb_samples;
00313
00314
00315
00316 audio_volume_t i_volume;
00317
00318
00319 bool b_error;
00320 } aout_output_t;
00321
00322
00323 struct aout_instance_t
00324 {
00325 VLC_COMMON_MEMBERS
00326
00327
00328
00329
00330
00331
00332
00333 vlc_mutex_t input_fifos_lock;
00334
00335
00336
00337 vlc_mutex_t mixer_lock;
00338
00339
00340 vlc_mutex_t output_fifo_lock;
00341
00342
00343 aout_input_t * pp_inputs[AOUT_MAX_INPUTS];
00344 int i_nb_inputs;
00345
00346
00347 aout_mixer_t mixer;
00348
00349
00350 aout_output_t output;
00351 };
00352
00353
00354
00355
00356
00357
00358 VLC_EXPORT( void, aout_DateInit, ( audio_date_t *, uint32_t ) );
00359 VLC_EXPORT( void, aout_DateSet, ( audio_date_t *, mtime_t ) );
00360 VLC_EXPORT( void, aout_DateMove, ( audio_date_t *, mtime_t ) );
00361 VLC_EXPORT( mtime_t, aout_DateGet, ( const audio_date_t * ) );
00362 VLC_EXPORT( mtime_t, aout_DateIncrement, ( audio_date_t *, uint32_t ) );
00363
00364 VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, bool ) );
00365
00366 VLC_EXPORT( int, aout_CheckChannelReorder, ( const uint32_t *, const uint32_t *, uint32_t, int, int * ) );
00367 VLC_EXPORT( void, aout_ChannelReorder, ( uint8_t *, int, int, const int *, int ) );
00368
00369 VLC_EXPORT( unsigned int, aout_FormatNbChannels, ( const audio_sample_format_t * p_format ) );
00370 VLC_EXPORT( unsigned int, aout_BitsPerSample, ( vlc_fourcc_t i_format ) );
00371 VLC_EXPORT( void, aout_FormatPrepare, ( audio_sample_format_t * p_format ) );
00372 VLC_EXPORT( void, aout_FormatPrint, ( aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format ) );
00373 VLC_EXPORT( const char *, aout_FormatPrintChannels, ( const audio_sample_format_t * ) );
00374
00375 VLC_EXPORT( mtime_t, aout_FifoFirstDate, ( aout_instance_t *, aout_fifo_t * ) );
00376 VLC_EXPORT( aout_buffer_t *, aout_FifoPop, ( aout_instance_t * p_aout, aout_fifo_t * p_fifo ) );
00377
00378
00379 VLC_EXPORT( void, aout_VolumeSoftInit, ( aout_instance_t * ) );
00380 VLC_EXPORT( void, aout_VolumeNoneInit, ( aout_instance_t * ) );
00381 #define aout_VolumeGet(a, b) __aout_VolumeGet(VLC_OBJECT(a), b)
00382 VLC_EXPORT( int, __aout_VolumeGet, ( vlc_object_t *, audio_volume_t * ) );
00383 #define aout_VolumeSet(a, b) __aout_VolumeSet(VLC_OBJECT(a), b)
00384 VLC_EXPORT( int, __aout_VolumeSet, ( vlc_object_t *, audio_volume_t ) );
00385 #define aout_VolumeInfos(a, b) __aout_VolumeInfos(VLC_OBJECT(a), b)
00386 VLC_EXPORT( int, __aout_VolumeInfos, ( vlc_object_t *, audio_volume_t * ) );
00387 #define aout_VolumeUp(a, b, c) __aout_VolumeUp(VLC_OBJECT(a), b, c)
00388 VLC_EXPORT( int, __aout_VolumeUp, ( vlc_object_t *, int, audio_volume_t * ) );
00389 #define aout_VolumeDown(a, b, c) __aout_VolumeDown(VLC_OBJECT(a), b, c)
00390 VLC_EXPORT( int, __aout_VolumeDown, ( vlc_object_t *, int, audio_volume_t * ) );
00391 #define aout_VolumeMute(a, b) __aout_VolumeMute(VLC_OBJECT(a), b)
00392 VLC_EXPORT( int, __aout_VolumeMute, ( vlc_object_t *, audio_volume_t * ) );
00393 VLC_EXPORT( int, aout_FindAndRestart, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );
00394 VLC_EXPORT( int, aout_ChannelsRestart, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );
00395
00396 VLC_EXPORT( void, aout_EnableFilter, (vlc_object_t *, const char *, bool ));
00397
00398 #define aout_VisualNext(a) aout_VisualChange( VLC_OBJECT(a),1 )
00399 #define aout_VisualPrev(a) aout_VisualChange( VLC_OBJECT(a),-1 )
00400
00401 VLC_EXPORT( char *, aout_VisualChange, (vlc_object_t *, int ) );
00402
00403 # ifdef __cplusplus
00404 }
00405 # endif
00406
00407 #endif