1 /*****************************************************************************
2 * input.c : internal management of input streams for the audio output
3 *****************************************************************************
4 * Copyright (C) 2002-2007 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 /*****************************************************************************
26 *****************************************************************************/
31 #include <stdlib.h> /* calloc(), malloc(), free() */
34 #include <vlc_input.h> /* for input_thread_t and i_pts_delay */
41 #include "aout_internal.h"
43 /** FIXME: Ugly but needed to access the counters */
44 #include "input/input_internal.h"
46 static void inputFailure( aout_instance_t *, aout_input_t *, const char * );
47 static int VisualizationCallback( vlc_object_t *, char const *,
48 vlc_value_t, vlc_value_t, void * );
49 static int EqualizerCallback( vlc_object_t *, char const *,
50 vlc_value_t, vlc_value_t, void * );
52 /*****************************************************************************
53 * aout_InputNew : allocate a new input and rework the filter pipeline
54 *****************************************************************************/
55 int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
57 audio_sample_format_t chain_input_format;
58 audio_sample_format_t chain_output_format;
59 vlc_value_t val, text;
60 char * psz_filters, *psz_visual;
63 aout_FormatPrint( p_aout, "input", &p_input->input );
65 p_input->i_nb_resamplers = p_input->i_nb_filters = 0;
68 aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
69 p_input->p_first_byte_to_mix = NULL;
71 /* Prepare format structure */
72 memcpy( &chain_input_format, &p_input->input,
73 sizeof(audio_sample_format_t) );
74 memcpy( &chain_output_format, &p_aout->mixer.mixer,
75 sizeof(audio_sample_format_t) );
76 chain_output_format.i_rate = p_input->input.i_rate;
77 aout_FormatPrepare( &chain_output_format );
79 /* Now add user filters */
80 if( var_Type( p_aout, "visual" ) == 0 )
83 var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
84 text.psz_string = _("Visualizations");
85 var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL );
86 val.psz_string = ""; text.psz_string = _("Disable");
87 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
88 val.psz_string = "spectrometer"; text.psz_string = _("Spectrometer");
89 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
90 val.psz_string = "scope"; text.psz_string = _("Scope");
91 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
92 val.psz_string = "spectrum"; text.psz_string = _("Spectrum");
93 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
95 /* Look for goom plugin */
96 p_module = config_FindModule( VLC_OBJECT(p_aout), "goom" );
99 val.psz_string = "goom"; text.psz_string = "Goom";
100 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
103 /* Look for galaktos plugin */
104 p_module = config_FindModule( VLC_OBJECT(p_aout), "galaktos" );
107 val.psz_string = "galaktos"; text.psz_string = "GaLaktos";
108 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
111 if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )
113 var_Set( p_aout, "visual", val );
114 if( val.psz_string ) free( val.psz_string );
116 var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );
119 if( var_Type( p_aout, "equalizer" ) == 0 )
121 module_config_t *p_config;
124 p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );
125 if( p_config && p_config->i_list )
127 var_Create( p_aout, "equalizer",
128 VLC_VAR_STRING | VLC_VAR_HASCHOICE );
129 text.psz_string = _("Equalizer");
130 var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );
132 val.psz_string = ""; text.psz_string = _("Disable");
133 var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );
135 for( i = 0; i < p_config->i_list; i++ )
137 val.psz_string = (char *)p_config->ppsz_list[i];
138 text.psz_string = (char *)p_config->ppsz_list_text[i];
139 var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
143 var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
147 if( var_Type( p_aout, "audio-filter" ) == 0 )
149 var_Create( p_aout, "audio-filter",
150 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
151 text.psz_string = _("Audio filters");
152 var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );
154 if( var_Type( p_aout, "audio-visual" ) == 0 )
156 var_Create( p_aout, "audio-visual",
157 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
158 text.psz_string = _("Audio visualizations");
159 var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL );
162 var_Get( p_aout, "audio-filter", &val );
163 psz_filters = val.psz_string;
164 var_Get( p_aout, "audio-visual", &val );
165 psz_visual = val.psz_string;
167 /* parse user filter lists */
168 for( i_visual = 0; i_visual < 2; i_visual++ )
170 char *psz_next = NULL;
171 char *psz_parser = i_visual ? psz_visual : psz_filters;
173 if( psz_parser == NULL || !*psz_parser )
176 while( psz_parser && *psz_parser )
178 aout_filter_t * p_filter = NULL;
180 if( p_input->i_nb_filters >= AOUT_MAX_FILTERS )
182 msg_Dbg( p_aout, "max filters reached (%d)", AOUT_MAX_FILTERS );
186 while( *psz_parser == ' ' && *psz_parser == ':' )
190 if( ( psz_next = strchr( psz_parser , ':' ) ) )
194 if( *psz_parser =='\0' )
199 /* Create a VLC object */
200 p_filter = vlc_object_create( p_aout, sizeof(aout_filter_t) );
201 if( p_filter == NULL )
203 msg_Err( p_aout, "cannot add user filter %s (skipped)",
205 psz_parser = psz_next;
209 vlc_object_attach( p_filter , p_aout );
211 /* try to find the requested filter */
212 if( i_visual == 1 ) /* this can only be a visualization module */
215 memcpy( &p_filter->input, &chain_output_format,
216 sizeof(audio_sample_format_t) );
217 memcpy( &p_filter->output, &chain_output_format,
218 sizeof(audio_sample_format_t) );
220 p_filter->p_module = module_Need( p_filter, "visualization",
221 psz_parser, VLC_TRUE );
223 else /* this can be a audio filter module as well as a visualization module */
226 memcpy( &p_filter->input, &chain_input_format,
227 sizeof(audio_sample_format_t) );
228 memcpy( &p_filter->output, &chain_output_format,
229 sizeof(audio_sample_format_t) );
231 p_filter->p_module = module_Need( p_filter, "audio filter",
232 psz_parser, VLC_TRUE );
234 if ( p_filter->p_module == NULL )
236 /* if the filter requested a special format, retry */
237 if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input,
238 &chain_input_format )
239 && AOUT_FMTS_IDENTICAL( &p_filter->output,
240 &chain_output_format ) ) )
242 aout_FormatPrepare( &p_filter->input );
243 aout_FormatPrepare( &p_filter->output );
244 p_filter->p_module = module_Need( p_filter,
246 psz_parser, VLC_TRUE );
248 /* try visual filters */
251 memcpy( &p_filter->input, &chain_output_format,
252 sizeof(audio_sample_format_t) );
253 memcpy( &p_filter->output, &chain_output_format,
254 sizeof(audio_sample_format_t) );
255 p_filter->p_module = module_Need( p_filter,
257 psz_parser, VLC_TRUE );
263 if ( p_filter->p_module == NULL )
265 msg_Err( p_aout, "cannot add user filter %s (skipped)",
268 vlc_object_detach( p_filter );
269 vlc_object_destroy( p_filter );
271 psz_parser = psz_next;
275 /* complete the filter chain if necessary */
276 if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) )
278 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
279 &p_input->i_nb_filters,
281 &p_filter->input ) < 0 )
283 msg_Err( p_aout, "cannot add user filter %s (skipped)",
286 module_Unneed( p_filter, p_filter->p_module );
287 vlc_object_detach( p_filter );
288 vlc_object_destroy( p_filter );
290 psz_parser = psz_next;
296 p_filter->b_continuity = VLC_FALSE;
297 p_input->pp_filters[p_input->i_nb_filters++] = p_filter;
298 memcpy( &chain_input_format, &p_filter->output,
299 sizeof( audio_sample_format_t ) );
301 /* next filter if any */
302 psz_parser = psz_next;
305 if( psz_filters ) free( psz_filters );
306 if( psz_visual ) free( psz_visual );
308 /* complete the filter chain if necessary */
309 if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) )
311 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
312 &p_input->i_nb_filters,
314 &chain_output_format ) < 0 )
316 inputFailure( p_aout, p_input, "couldn't set an input pipeline" );
321 /* Prepare hints for the buffer allocator. */
322 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
323 p_input->input_alloc.i_bytes_per_sec = -1;
325 /* Create resamplers. */
326 if ( !AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) )
328 chain_output_format.i_rate = (__MAX(p_input->input.i_rate,
329 p_aout->mixer.mixer.i_rate)
330 * (100 + AOUT_MAX_RESAMPLING)) / 100;
331 if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate )
333 /* Just in case... */
334 chain_output_format.i_rate++;
336 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,
337 &p_input->i_nb_resamplers,
338 &chain_output_format,
339 &p_aout->mixer.mixer ) < 0 )
341 inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");
345 aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,
346 p_input->i_nb_resamplers,
347 &p_input->input_alloc );
348 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
350 /* Setup the initial rate of the resampler */
351 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
353 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
355 aout_FiltersHintBuffers( p_aout, p_input->pp_filters,
356 p_input->i_nb_filters,
357 &p_input->input_alloc );
358 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
360 /* i_bytes_per_sec is still == -1 if no filters */
361 p_input->input_alloc.i_bytes_per_sec = __MAX(
362 p_input->input_alloc.i_bytes_per_sec,
363 (int)(p_input->input.i_bytes_per_frame
364 * p_input->input.i_rate
365 / p_input->input.i_frame_length) );
368 p_input->b_error = VLC_FALSE;
369 p_input->b_restart = VLC_FALSE;
374 /*****************************************************************************
375 * aout_InputDelete : delete an input
376 *****************************************************************************
377 * This function must be entered with the mixer lock.
378 *****************************************************************************/
379 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
381 if ( p_input->b_error ) return 0;
383 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
384 p_input->i_nb_filters );
385 p_input->i_nb_filters = 0;
386 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
387 p_input->i_nb_resamplers );
388 p_input->i_nb_resamplers = 0;
389 aout_FifoDestroy( p_aout, &p_input->fifo );
394 /*****************************************************************************
395 * aout_InputPlay : play a buffer
396 *****************************************************************************
397 * This function must be entered with the input lock.
398 *****************************************************************************/
399 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
400 aout_buffer_t * p_buffer )
404 if( p_input->b_restart )
406 aout_fifo_t fifo, dummy_fifo;
407 byte_t *p_first_byte_to_mix;
409 vlc_mutex_lock( &p_aout->mixer_lock );
411 /* A little trick to avoid loosing our input fifo */
412 aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );
413 p_first_byte_to_mix = p_input->p_first_byte_to_mix;
414 fifo = p_input->fifo;
415 p_input->fifo = dummy_fifo;
416 aout_InputDelete( p_aout, p_input );
417 aout_InputNew( p_aout, p_input );
418 p_input->p_first_byte_to_mix = p_first_byte_to_mix;
419 p_input->fifo = fifo;
421 vlc_mutex_unlock( &p_aout->mixer_lock );
424 /* We don't care if someone changes the start date behind our back after
425 * this. We'll deal with that when pushing the buffer, and compensate
426 * with the next incoming buffer. */
427 vlc_mutex_lock( &p_aout->input_fifos_lock );
428 start_date = aout_FifoNextStart( p_aout, &p_input->fifo );
429 vlc_mutex_unlock( &p_aout->input_fifos_lock );
431 if ( start_date != 0 && start_date < mdate() )
433 /* The decoder is _very_ late. This can only happen if the user
434 * pauses the stream (or if the decoder is buggy, which cannot
436 msg_Warn( p_aout, "computed PTS is out of range ("I64Fd"), "
437 "clearing out", mdate() - start_date );
438 vlc_mutex_lock( &p_aout->input_fifos_lock );
439 aout_FifoSet( p_aout, &p_input->fifo, 0 );
440 p_input->p_first_byte_to_mix = NULL;
441 vlc_mutex_unlock( &p_aout->input_fifos_lock );
442 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
443 msg_Warn( p_aout, "timing screwed, stopping resampling" );
444 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
445 if ( p_input->i_nb_resamplers != 0 )
447 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
448 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
451 if( p_input->p_input_thread )
453 vlc_mutex_lock( &p_input->p_input_thread->p->counters.counters_lock);
454 stats_UpdateInteger( p_aout, p_input->p_input_thread->p->counters.p_lost_abuffers, 1, NULL );
455 vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock);
459 if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
461 /* The decoder gives us f*cked up PTS. It's its business, but we
462 * can't present it anyway, so drop the buffer. */
463 msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
464 mdate() - p_buffer->start_date );
465 if( p_input->p_input_thread )
467 vlc_mutex_lock( &p_input->p_input_thread->p->counters.counters_lock);
468 stats_UpdateInteger( p_aout, p_input->p_input_thread->p->counters.p_lost_abuffers, 1, NULL );
469 vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock);
471 aout_BufferFree( p_buffer );
472 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
473 if ( p_input->i_nb_resamplers != 0 )
475 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
476 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
481 /* If the audio drift is too big then it's not worth trying to resample
483 if ( start_date != 0 &&
484 ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) )
486 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), clearing out",
487 start_date - p_buffer->start_date );
488 vlc_mutex_lock( &p_aout->input_fifos_lock );
489 aout_FifoSet( p_aout, &p_input->fifo, 0 );
490 p_input->p_first_byte_to_mix = NULL;
491 vlc_mutex_unlock( &p_aout->input_fifos_lock );
492 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
493 msg_Warn( p_aout, "timing screwed, stopping resampling" );
494 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
495 if ( p_input->i_nb_resamplers != 0 )
497 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
498 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
502 else if ( start_date != 0 &&
503 ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) )
505 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
506 start_date - p_buffer->start_date );
507 aout_BufferFree( p_buffer );
508 if( p_input->p_input_thread )
510 vlc_mutex_lock( &p_input->p_input_thread->p->counters.counters_lock);
511 stats_UpdateInteger( p_aout, p_input->p_input_thread->p->counters.p_lost_abuffers, 1, NULL );
512 vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock);
517 if ( start_date == 0 ) start_date = p_buffer->start_date;
519 /* Run pre-filters. */
521 aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,
524 /* Run the resampler if needed.
525 * We first need to calculate the output rate of this resampler. */
526 if ( ( p_input->i_resampling_type == AOUT_RESAMPLING_NONE ) &&
527 ( start_date < p_buffer->start_date - AOUT_PTS_TOLERANCE
528 || start_date > p_buffer->start_date + AOUT_PTS_TOLERANCE ) &&
529 p_input->i_nb_resamplers > 0 )
531 /* Can happen in several circumstances :
532 * 1. A problem at the input (clock drift)
533 * 2. A small pause triggered by the user
534 * 3. Some delay in the output stage, causing a loss of lip
536 * Solution : resample the buffer to avoid a scratch.
538 mtime_t drift = p_buffer->start_date - start_date;
540 p_input->i_resamp_start_date = mdate();
541 p_input->i_resamp_start_drift = (int)drift;
544 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
546 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
548 msg_Warn( p_aout, "buffer is "I64Fd" %s, triggering %ssampling",
549 drift > 0 ? drift : -drift,
550 drift > 0 ? "in advance" : "late",
551 drift > 0 ? "down" : "up");
554 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
556 /* Resampling has been triggered previously (because of dates
557 * mismatch). We want the resampling to happen progressively so
558 * it isn't too audible to the listener. */
560 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
562 p_input->pp_resamplers[0]->input.i_rate += 2; /* Hz */
566 p_input->pp_resamplers[0]->input.i_rate -= 2; /* Hz */
569 /* Check if everything is back to normal, in which case we can stop the
571 if( p_input->pp_resamplers[0]->input.i_rate ==
572 p_input->input.i_rate )
574 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
575 msg_Warn( p_aout, "resampling stopped after "I64Fi" usec "
577 mdate() - p_input->i_resamp_start_date,
578 p_buffer->start_date - start_date);
580 else if( abs( (int)(p_buffer->start_date - start_date) ) <
581 abs( p_input->i_resamp_start_drift ) / 2 )
583 /* if we reduced the drift from half, then it is time to switch
584 * back the resampling direction. */
585 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
586 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
588 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
589 p_input->i_resamp_start_drift = 0;
591 else if( p_input->i_resamp_start_drift &&
592 ( abs( (int)(p_buffer->start_date - start_date) ) >
593 abs( p_input->i_resamp_start_drift ) * 3 / 2 ) )
595 /* If the drift is increasing and not decreasing, than something
596 * is bad. We'd better stop the resampling right now. */
597 msg_Warn( p_aout, "timing screwed, stopping resampling" );
598 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
599 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
603 /* Adding the start date will be managed by aout_FifoPush(). */
604 p_buffer->end_date = start_date +
605 (p_buffer->end_date - p_buffer->start_date);
606 p_buffer->start_date = start_date;
608 /* Actually run the resampler now. */
609 if ( p_input->i_nb_resamplers > 0 )
611 aout_FiltersPlay( p_aout, p_input->pp_resamplers,
612 p_input->i_nb_resamplers,
616 vlc_mutex_lock( &p_aout->input_fifos_lock );
617 aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
618 vlc_mutex_unlock( &p_aout->input_fifos_lock );
623 /*****************************************************************************
625 *****************************************************************************/
627 static void inputFailure( aout_instance_t * p_aout, aout_input_t * p_input,
628 const char * psz_error_message )
631 msg_Err( p_aout, "%s", psz_error_message );
634 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
635 p_input->i_nb_filters );
636 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
637 p_input->i_nb_resamplers );
638 aout_FifoDestroy( p_aout, &p_input->fifo );
639 var_Destroy( p_aout, "visual" );
640 var_Destroy( p_aout, "equalizer" );
641 var_Destroy( p_aout, "audio-filter" );
642 var_Destroy( p_aout, "audio-visual" );
645 p_input->b_error = 1;
648 static int ChangeFiltersString( aout_instance_t * p_aout, const char* psz_variable,
649 const char *psz_name, vlc_bool_t b_add )
654 var_Get( p_aout, psz_variable, &val );
656 if( !val.psz_string ) val.psz_string = strdup("");
658 psz_parser = strstr( val.psz_string, psz_name );
664 psz_parser = val.psz_string;
665 asprintf( &val.psz_string, (*val.psz_string) ? "%s:%s" : "%s%s",
666 val.psz_string, psz_name );
678 memmove( psz_parser, psz_parser + strlen(psz_name) +
679 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
680 strlen(psz_parser + strlen(psz_name)) + 1 );
684 free( val.psz_string );
689 var_Set( p_aout, psz_variable, val );
690 free( val.psz_string );
694 static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
695 vlc_value_t oldval, vlc_value_t newval, void *p_data )
697 aout_instance_t *p_aout = (aout_instance_t *)p_this;
698 char *psz_mode = newval.psz_string;
701 (void)psz_cmd; (void)oldval; (void)p_data;
703 if( !psz_mode || !*psz_mode )
705 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
706 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
707 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE );
711 if( !strcmp( "goom", psz_mode ) )
713 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
714 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_TRUE );
715 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
717 else if( !strcmp( "galaktos", psz_mode ) )
719 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
720 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
721 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_TRUE );
725 val.psz_string = psz_mode;
726 var_Create( p_aout, "effect-list", VLC_VAR_STRING );
727 var_Set( p_aout, "effect-list", val );
729 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
730 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_TRUE );
731 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
736 for( i = 0; i < p_aout->i_nb_inputs; i++ )
738 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
744 static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd,
745 vlc_value_t oldval, vlc_value_t newval, void *p_data )
747 aout_instance_t *p_aout = (aout_instance_t *)p_this;
748 char *psz_mode = newval.psz_string;
752 (void)psz_cmd; (void)oldval; (void)p_data;
754 if( !psz_mode || !*psz_mode )
756 i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
761 val.psz_string = psz_mode;
762 var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING );
763 var_Set( p_aout, "equalizer-preset", val );
764 i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
772 for( i = 0; i < p_aout->i_nb_inputs; i++ )
774 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;