1 /*****************************************************************************
2 * input.c : internal management of input streams for the audio output
3 *****************************************************************************
4 * Copyright (C) 2002-2004 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 *, 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_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 = p_config->ppsz_list[i];
138 text.psz_string = 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 p_input->i_nb_resamplers = 0;
332 chain_output_format.i_rate = (__MAX(p_input->input.i_rate,
333 p_aout->mixer.mixer.i_rate)
334 * (100 + AOUT_MAX_RESAMPLING)) / 100;
335 if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate )
337 /* Just in case... */
338 chain_output_format.i_rate++;
340 p_input->i_nb_resamplers = 0;
341 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,
342 &p_input->i_nb_resamplers,
343 &chain_output_format,
344 &p_aout->mixer.mixer ) < 0 )
346 inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");
350 aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,
351 p_input->i_nb_resamplers,
352 &p_input->input_alloc );
353 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
355 /* Setup the initial rate of the resampler */
356 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
358 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
360 aout_FiltersHintBuffers( p_aout, p_input->pp_filters,
361 p_input->i_nb_filters,
362 &p_input->input_alloc );
363 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
365 /* i_bytes_per_sec is still == -1 if no filters */
366 p_input->input_alloc.i_bytes_per_sec = __MAX(
367 p_input->input_alloc.i_bytes_per_sec,
368 (int)(p_input->input.i_bytes_per_frame
369 * p_input->input.i_rate
370 / p_input->input.i_frame_length) );
373 p_input->b_error = VLC_FALSE;
374 p_input->b_restart = VLC_FALSE;
379 /*****************************************************************************
380 * aout_InputDelete : delete an input
381 *****************************************************************************
382 * This function must be entered with the mixer lock.
383 *****************************************************************************/
384 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
386 if ( p_input->b_error ) return 0;
388 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
389 p_input->i_nb_filters );
390 p_input->i_nb_filters = 0;
391 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
392 p_input->i_nb_resamplers );
393 p_input->i_nb_resamplers = 0;
394 aout_FifoDestroy( p_aout, &p_input->fifo );
399 /*****************************************************************************
400 * aout_InputPlay : play a buffer
401 *****************************************************************************
402 * This function must be entered with the input lock.
403 *****************************************************************************/
404 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
405 aout_buffer_t * p_buffer )
409 if( p_input->b_restart )
411 aout_fifo_t fifo, dummy_fifo;
412 byte_t *p_first_byte_to_mix;
414 vlc_mutex_lock( &p_aout->mixer_lock );
416 /* A little trick to avoid loosing our input fifo */
417 aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );
418 p_first_byte_to_mix = p_input->p_first_byte_to_mix;
419 fifo = p_input->fifo;
420 p_input->fifo = dummy_fifo;
421 aout_InputDelete( p_aout, p_input );
422 aout_InputNew( p_aout, p_input );
423 p_input->p_first_byte_to_mix = p_first_byte_to_mix;
424 p_input->fifo = fifo;
426 vlc_mutex_unlock( &p_aout->mixer_lock );
429 /* We don't care if someone changes the start date behind our back after
430 * this. We'll deal with that when pushing the buffer, and compensate
431 * with the next incoming buffer. */
432 vlc_mutex_lock( &p_aout->input_fifos_lock );
433 start_date = aout_FifoNextStart( p_aout, &p_input->fifo );
434 vlc_mutex_unlock( &p_aout->input_fifos_lock );
436 if ( start_date != 0 && start_date < mdate() )
438 /* The decoder is _very_ late. This can only happen if the user
439 * pauses the stream (or if the decoder is buggy, which cannot
441 msg_Warn( p_aout, "computed PTS is out of range ("I64Fd"), "
442 "clearing out", mdate() - start_date );
443 vlc_mutex_lock( &p_aout->input_fifos_lock );
444 aout_FifoSet( p_aout, &p_input->fifo, 0 );
445 p_input->p_first_byte_to_mix = NULL;
446 vlc_mutex_unlock( &p_aout->input_fifos_lock );
447 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
448 msg_Warn( p_aout, "timing screwed, stopping resampling" );
449 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
450 if ( p_input->i_nb_resamplers != 0 )
452 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
453 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
456 if( p_input->p_input_thread )
458 vlc_mutex_lock( &p_input->p_input_thread->p->counters.counters_lock);
459 stats_UpdateInteger( p_aout, p_input->p_input_thread->p->counters.p_lost_abuffers, 1, NULL );
460 vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock);
464 if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
466 /* The decoder gives us f*cked up PTS. It's its business, but we
467 * can't present it anyway, so drop the buffer. */
468 msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
469 mdate() - p_buffer->start_date );
470 if( p_input->p_input_thread )
472 vlc_mutex_lock( &p_input->p_input_thread->p->counters.counters_lock);
473 stats_UpdateInteger( p_aout, p_input->p_input_thread->p->counters.p_lost_abuffers, 1, NULL );
474 vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock);
476 aout_BufferFree( p_buffer );
477 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
478 if ( p_input->i_nb_resamplers != 0 )
480 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
481 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
486 /* If the audio drift is too big then it's not worth trying to resample
488 if ( start_date != 0 &&
489 ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) )
491 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), clearing out",
492 start_date - p_buffer->start_date );
493 vlc_mutex_lock( &p_aout->input_fifos_lock );
494 aout_FifoSet( p_aout, &p_input->fifo, 0 );
495 p_input->p_first_byte_to_mix = NULL;
496 vlc_mutex_unlock( &p_aout->input_fifos_lock );
497 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
498 msg_Warn( p_aout, "timing screwed, stopping resampling" );
499 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
500 if ( p_input->i_nb_resamplers != 0 )
502 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
503 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
507 else if ( start_date != 0 &&
508 ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) )
510 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
511 start_date - p_buffer->start_date );
512 aout_BufferFree( p_buffer );
513 if( p_input->p_input_thread )
515 vlc_mutex_lock( &p_input->p_input_thread->p->counters.counters_lock);
516 stats_UpdateInteger( p_aout, p_input->p_input_thread->p->counters.p_lost_abuffers, 1, NULL );
517 vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock);
522 if ( start_date == 0 ) start_date = p_buffer->start_date;
524 /* Run pre-filters. */
526 aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,
529 /* Run the resampler if needed.
530 * We first need to calculate the output rate of this resampler. */
531 if ( ( p_input->i_resampling_type == AOUT_RESAMPLING_NONE ) &&
532 ( start_date < p_buffer->start_date - AOUT_PTS_TOLERANCE
533 || start_date > p_buffer->start_date + AOUT_PTS_TOLERANCE ) &&
534 p_input->i_nb_resamplers > 0 )
536 /* Can happen in several circumstances :
537 * 1. A problem at the input (clock drift)
538 * 2. A small pause triggered by the user
539 * 3. Some delay in the output stage, causing a loss of lip
541 * Solution : resample the buffer to avoid a scratch.
543 mtime_t drift = p_buffer->start_date - start_date;
545 p_input->i_resamp_start_date = mdate();
546 p_input->i_resamp_start_drift = (int)drift;
549 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
551 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
553 msg_Warn( p_aout, "buffer is "I64Fd" %s, triggering %ssampling",
554 drift > 0 ? drift : -drift,
555 drift > 0 ? "in advance" : "late",
556 drift > 0 ? "down" : "up");
559 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
561 /* Resampling has been triggered previously (because of dates
562 * mismatch). We want the resampling to happen progressively so
563 * it isn't too audible to the listener. */
565 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
567 p_input->pp_resamplers[0]->input.i_rate += 2; /* Hz */
571 p_input->pp_resamplers[0]->input.i_rate -= 2; /* Hz */
574 /* Check if everything is back to normal, in which case we can stop the
576 if( p_input->pp_resamplers[0]->input.i_rate ==
577 p_input->input.i_rate )
579 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
580 msg_Warn( p_aout, "resampling stopped after "I64Fi" usec "
582 mdate() - p_input->i_resamp_start_date,
583 p_buffer->start_date - start_date);
585 else if( abs( (int)(p_buffer->start_date - start_date) ) <
586 abs( p_input->i_resamp_start_drift ) / 2 )
588 /* if we reduced the drift from half, then it is time to switch
589 * back the resampling direction. */
590 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
591 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
593 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
594 p_input->i_resamp_start_drift = 0;
596 else if( p_input->i_resamp_start_drift &&
597 ( abs( (int)(p_buffer->start_date - start_date) ) >
598 abs( p_input->i_resamp_start_drift ) * 3 / 2 ) )
600 /* If the drift is increasing and not decreasing, than something
601 * is bad. We'd better stop the resampling right now. */
602 msg_Warn( p_aout, "timing screwed, stopping resampling" );
603 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
604 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
608 /* Adding the start date will be managed by aout_FifoPush(). */
609 p_buffer->end_date = start_date +
610 (p_buffer->end_date - p_buffer->start_date);
611 p_buffer->start_date = start_date;
613 /* Actually run the resampler now. */
614 if ( p_input->i_nb_resamplers > 0 )
616 aout_FiltersPlay( p_aout, p_input->pp_resamplers,
617 p_input->i_nb_resamplers,
621 vlc_mutex_lock( &p_aout->input_fifos_lock );
622 aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
623 vlc_mutex_unlock( &p_aout->input_fifos_lock );
628 /*****************************************************************************
630 *****************************************************************************/
632 static void inputFailure( aout_instance_t * p_aout, aout_input_t * p_input,
633 char * psz_error_message )
636 msg_Err( p_aout, "couldn't set an input pipeline" );
639 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
640 p_input->i_nb_filters );
641 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
642 p_input->i_nb_resamplers );
643 aout_FifoDestroy( p_aout, &p_input->fifo );
644 var_Destroy( p_aout, "visual" );
645 var_Destroy( p_aout, "equalizer" );
646 var_Destroy( p_aout, "audio-filter" );
647 var_Destroy( p_aout, "audio-visual" );
650 p_input->b_error = 1;
653 static int ChangeFiltersString( aout_instance_t * p_aout, char* psz_variable,
654 char *psz_name, vlc_bool_t b_add )
659 var_Get( p_aout, psz_variable, &val );
661 if( !val.psz_string ) val.psz_string = strdup("");
663 psz_parser = strstr( val.psz_string, psz_name );
669 psz_parser = val.psz_string;
670 asprintf( &val.psz_string, (*val.psz_string) ? "%s:%s" : "%s%s",
671 val.psz_string, psz_name );
683 memmove( psz_parser, psz_parser + strlen(psz_name) +
684 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
685 strlen(psz_parser + strlen(psz_name)) + 1 );
689 free( val.psz_string );
694 var_Set( p_aout, psz_variable, val );
695 free( val.psz_string );
699 static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
700 vlc_value_t oldval, vlc_value_t newval, void *p_data )
702 aout_instance_t *p_aout = (aout_instance_t *)p_this;
703 char *psz_mode = newval.psz_string;
707 if( !psz_mode || !*psz_mode )
709 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
710 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
711 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE );
715 if( !strcmp( "goom", psz_mode ) )
717 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
718 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_TRUE );
719 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
721 else if( !strcmp( "galaktos", psz_mode ) )
723 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
724 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
725 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_TRUE );
729 val.psz_string = psz_mode;
730 var_Create( p_aout, "effect-list", VLC_VAR_STRING );
731 var_Set( p_aout, "effect-list", val );
733 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
734 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_TRUE );
735 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
740 for( i = 0; i < p_aout->i_nb_inputs; i++ )
742 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
748 static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd,
749 vlc_value_t oldval, vlc_value_t newval, void *p_data )
751 aout_instance_t *p_aout = (aout_instance_t *)p_this;
752 char *psz_mode = newval.psz_string;
757 if( !psz_mode || !*psz_mode )
759 i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
764 val.psz_string = psz_mode;
765 var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING );
766 var_Set( p_aout, "equalizer-preset", val );
767 i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
775 for( i = 0; i < p_aout->i_nb_inputs; i++ )
777 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;