| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
#if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__) |
|---|
| 25 |
# error This header file can only be included from LibVLC. |
|---|
| 26 |
#endif |
|---|
| 27 |
|
|---|
| 28 |
#ifndef __LIBVLC_AOUT_INTERNAL_H |
|---|
| 29 |
# define __LIBVLC_AOUT_INTERNAL_H 1 |
|---|
| 30 |
|
|---|
| 31 |
#include <assert.h> |
|---|
| 32 |
|
|---|
| 33 |
#if defined( __APPLE__ ) || defined( SYS_BSD ) |
|---|
| 34 |
#undef HAVE_ALLOCA |
|---|
| 35 |
#endif |
|---|
| 36 |
|
|---|
| 37 |
#ifdef HAVE_ALLOCA |
|---|
| 38 |
# define ALLOCA_TEST( p_alloc, p_new_buffer ) \ |
|---|
| 39 |
if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_STACK ) \ |
|---|
| 40 |
{ \ |
|---|
| 41 |
(p_new_buffer) = alloca( i_alloc_size + sizeof(aout_buffer_t) );\ |
|---|
| 42 |
i_alloc_type = AOUT_ALLOC_STACK; \ |
|---|
| 43 |
} \ |
|---|
| 44 |
else |
|---|
| 45 |
#else |
|---|
| 46 |
# define ALLOCA_TEST( p_alloc, p_new_buffer ) |
|---|
| 47 |
#endif |
|---|
| 48 |
|
|---|
| 49 |
#define aout_BufferAlloc( p_alloc, i_nb_usec, p_previous_buffer, \ |
|---|
| 50 |
p_new_buffer ) \ |
|---|
| 51 |
if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_NONE ) \ |
|---|
| 52 |
{ \ |
|---|
| 53 |
(p_new_buffer) = p_previous_buffer; \ |
|---|
| 54 |
} \ |
|---|
| 55 |
else \ |
|---|
| 56 |
{ \ |
|---|
| 57 |
int i_alloc_size, i_alloc_type; \ |
|---|
| 58 |
i_alloc_size = (int)( (uint64_t)(p_alloc)->i_bytes_per_sec \ |
|---|
| 59 |
* (i_nb_usec) / 1000000 + 1 ); \ |
|---|
| 60 |
ALLOCA_TEST( p_alloc, p_new_buffer ) \ |
|---|
| 61 |
{ \ |
|---|
| 62 |
(p_new_buffer) = malloc( i_alloc_size + sizeof(aout_buffer_t) );\ |
|---|
| 63 |
i_alloc_type = AOUT_ALLOC_HEAP; \ |
|---|
| 64 |
} \ |
|---|
| 65 |
if ( p_new_buffer != NULL ) \ |
|---|
| 66 |
{ \ |
|---|
| 67 |
(p_new_buffer)->i_alloc_type = i_alloc_type; \ |
|---|
| 68 |
(p_new_buffer)->i_size = i_alloc_size; \ |
|---|
| 69 |
(p_new_buffer)->p_buffer = (uint8_t *)(p_new_buffer) \ |
|---|
| 70 |
+ sizeof(aout_buffer_t); \ |
|---|
| 71 |
(p_new_buffer)->b_discontinuity = false; \ |
|---|
| 72 |
if ( (p_previous_buffer) != NULL ) \ |
|---|
| 73 |
{ \ |
|---|
| 74 |
(p_new_buffer)->start_date = \ |
|---|
| 75 |
((aout_buffer_t *)p_previous_buffer)->start_date;\ |
|---|
| 76 |
(p_new_buffer)->end_date = \ |
|---|
| 77 |
((aout_buffer_t *)p_previous_buffer)->end_date; \ |
|---|
| 78 |
} \ |
|---|
| 79 |
} \ |
|---|
| 80 |
\ |
|---|
| 81 |
\ |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input ); |
|---|
| 89 |
int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input ); |
|---|
| 90 |
int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, |
|---|
| 91 |
aout_buffer_t * p_buffer, int i_input_rate ); |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
int aout_FiltersCreatePipeline ( aout_instance_t * p_aout, 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 ); |
|---|
| 95 |
void aout_FiltersDestroyPipeline ( aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters ); |
|---|
| 96 |
void aout_FiltersPlay ( aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_buffer_t ** pp_input_buffer ); |
|---|
| 97 |
void aout_FiltersHintBuffers( aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_alloc_t * p_first_alloc ); |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
int aout_MixerNew( aout_instance_t * p_aout ); |
|---|
| 101 |
void aout_MixerDelete( aout_instance_t * p_aout ); |
|---|
| 102 |
void aout_MixerRun( aout_instance_t * p_aout ); |
|---|
| 103 |
int aout_MixerMultiplierSet( aout_instance_t * p_aout, float f_multiplier ); |
|---|
| 104 |
int aout_MixerMultiplierGet( aout_instance_t * p_aout, float * pf_multiplier ); |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
int aout_OutputNew( aout_instance_t * p_aout, |
|---|
| 108 |
audio_sample_format_t * p_format ); |
|---|
| 109 |
void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer ); |
|---|
| 110 |
void aout_OutputDelete( aout_instance_t * p_aout ); |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
#define aout_New(a) __aout_New(VLC_OBJECT(a)) |
|---|
| 115 |
|
|---|
| 116 |
aout_instance_t * __aout_New ( vlc_object_t * ); |
|---|
| 117 |
|
|---|
| 118 |
void aout_FifoInit( aout_instance_t *, aout_fifo_t *, uint32_t ); |
|---|
| 119 |
mtime_t aout_FifoNextStart( aout_instance_t *, aout_fifo_t * ); |
|---|
| 120 |
void aout_FifoPush( aout_instance_t *, aout_fifo_t *, aout_buffer_t * ); |
|---|
| 121 |
void aout_FifoSet( aout_instance_t *, aout_fifo_t *, mtime_t ); |
|---|
| 122 |
void aout_FifoMoveDates( aout_instance_t *, aout_fifo_t *, mtime_t ); |
|---|
| 123 |
void aout_FifoDestroy( aout_instance_t * p_aout, aout_fifo_t * p_fifo ); |
|---|
| 124 |
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 ); |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
int aout_VolumeSoftGet( aout_instance_t *, audio_volume_t * ); |
|---|
| 129 |
int aout_VolumeSoftSet( aout_instance_t *, audio_volume_t ); |
|---|
| 130 |
int aout_VolumeSoftInfos( aout_instance_t *, audio_volume_t * ); |
|---|
| 131 |
int aout_VolumeNoneGet( aout_instance_t *, audio_volume_t * ); |
|---|
| 132 |
int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t ); |
|---|
| 133 |
int aout_VolumeNoneInfos( aout_instance_t *, audio_volume_t * ); |
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
#define aout_DecNew(a, b, c, d) __aout_DecNew(VLC_OBJECT(a), b, c, d) |
|---|
| 137 |
aout_input_t * __aout_DecNew( vlc_object_t *, aout_instance_t **, audio_sample_format_t *, audio_replay_gain_t * ); |
|---|
| 138 |
int aout_DecDelete ( aout_instance_t *, aout_input_t * ); |
|---|
| 139 |
aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t ); |
|---|
| 140 |
void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * ); |
|---|
| 141 |
int aout_DecPlay( aout_instance_t *, aout_input_t *, aout_buffer_t *, int i_input_rate ); |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
static inline void aout_lock_mixer( aout_instance_t *p_aout ) |
|---|
| 146 |
{ |
|---|
| 147 |
vlc_mutex_lock( &p_aout->mixer_lock ); |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
static inline void aout_unlock_mixer( aout_instance_t *p_aout ) |
|---|
| 151 |
{ |
|---|
| 152 |
vlc_mutex_unlock( &p_aout->mixer_lock ); |
|---|
| 153 |
} |
|---|
| 154 |
|
|---|
| 155 |
static inline void aout_lock_input_fifos( aout_instance_t *p_aout ) |
|---|
| 156 |
{ |
|---|
| 157 |
vlc_mutex_lock( &p_aout->input_fifos_lock ); |
|---|
| 158 |
} |
|---|
| 159 |
|
|---|
| 160 |
static inline void aout_unlock_input_fifos( aout_instance_t *p_aout ) |
|---|
| 161 |
{ |
|---|
| 162 |
vlc_mutex_unlock( &p_aout->input_fifos_lock ); |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
static inline void aout_lock_output_fifo( aout_instance_t *p_aout ) |
|---|
| 166 |
{ |
|---|
| 167 |
vlc_mutex_lock( &p_aout->output_fifo_lock ); |
|---|
| 168 |
} |
|---|
| 169 |
|
|---|
| 170 |
static inline void aout_unlock_output_fifo( aout_instance_t *p_aout ) |
|---|
| 171 |
{ |
|---|
| 172 |
vlc_mutex_unlock( &p_aout->output_fifo_lock ); |
|---|
| 173 |
} |
|---|
| 174 |
|
|---|
| 175 |
static inline void aout_lock_input( aout_instance_t *p_aout, aout_input_t * p_input ) |
|---|
| 176 |
{ |
|---|
| 177 |
(void)p_aout; |
|---|
| 178 |
vlc_mutex_lock( &p_input->lock ); |
|---|
| 179 |
} |
|---|
| 180 |
|
|---|
| 181 |
static inline void aout_unlock_input( aout_instance_t *p_aout, aout_input_t * p_input ) |
|---|
| 182 |
{ |
|---|
| 183 |
(void)p_aout; |
|---|
| 184 |
vlc_mutex_unlock( &p_input->lock ); |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
static inline void AoutInputsMarkToRestart( aout_instance_t *p_aout ) |
|---|
| 192 |
{ |
|---|
| 193 |
int i; |
|---|
| 194 |
aout_lock_mixer( p_aout ); |
|---|
| 195 |
for( i = 0; i < p_aout->i_nb_inputs; i++ ) |
|---|
| 196 |
p_aout->pp_inputs[i]->b_restart = true; |
|---|
| 197 |
aout_unlock_mixer( p_aout ); |
|---|
| 198 |
} |
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
static inline bool AoutChangeFilterString( vlc_object_t *p_obj, aout_instance_t * p_aout, |
|---|
| 204 |
const char* psz_variable, |
|---|
| 205 |
const char *psz_name, bool b_add ) |
|---|
| 206 |
{ |
|---|
| 207 |
vlc_value_t val; |
|---|
| 208 |
char *psz_parser; |
|---|
| 209 |
|
|---|
| 210 |
if( *psz_name == '\0' ) |
|---|
| 211 |
return false; |
|---|
| 212 |
|
|---|
| 213 |
if( p_aout ) |
|---|
| 214 |
var_Get( p_aout, psz_variable, &val ); |
|---|
| 215 |
else |
|---|
| 216 |
val.psz_string = config_GetPsz( p_obj, "audio-filter" ); |
|---|
| 217 |
|
|---|
| 218 |
if( !val.psz_string ) |
|---|
| 219 |
val.psz_string = strdup(""); |
|---|
| 220 |
|
|---|
| 221 |
psz_parser = strstr( val.psz_string, psz_name ); |
|---|
| 222 |
|
|---|
| 223 |
if( ( b_add && psz_parser ) || ( !b_add && !psz_parser ) ) |
|---|
| 224 |
{ |
|---|
| 225 |
|
|---|
| 226 |
free( val.psz_string ); |
|---|
| 227 |
return false; |
|---|
| 228 |
} |
|---|
| 229 |
|
|---|
| 230 |
if( b_add ) |
|---|
| 231 |
{ |
|---|
| 232 |
char *psz_old = val.psz_string; |
|---|
| 233 |
if( *psz_old ) |
|---|
| 234 |
{ |
|---|
| 235 |
if( asprintf( &val.psz_string, "%s:%s", psz_old, psz_name ) == -1 ) |
|---|
| 236 |
val.psz_string = NULL; |
|---|
| 237 |
} |
|---|
| 238 |
else |
|---|
| 239 |
val.psz_string = strdup( psz_name ); |
|---|
| 240 |
free( psz_old ); |
|---|
| 241 |
} |
|---|
| 242 |
else |
|---|
| 243 |
{ |
|---|
| 244 |
const int i_name = strlen( psz_name ); |
|---|
| 245 |
const char *psz_next; |
|---|
| 246 |
|
|---|
| 247 |
psz_next = &psz_parser[i_name]; |
|---|
| 248 |
if( *psz_next == ':' ) |
|---|
| 249 |
psz_next++; |
|---|
| 250 |
|
|---|
| 251 |
memmove( psz_parser, psz_next, strlen(psz_next)+1 ); |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
if( p_aout ) |
|---|
| 255 |
var_Set( p_aout, psz_variable, val ); |
|---|
| 256 |
else |
|---|
| 257 |
config_PutPsz( p_obj, psz_variable, val.psz_string ); |
|---|
| 258 |
free( val.psz_string ); |
|---|
| 259 |
return true; |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
#endif |
|---|