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 */
40 #include "audio_output.h"
41 #include "aout_internal.h"
43 static void inputFailure( aout_instance_t *, aout_input_t *, char * );
44 static int VisualizationCallback( vlc_object_t *, char const *,
45 vlc_value_t, vlc_value_t, void * );
46 static int EqualizerCallback( vlc_object_t *, char const *,
47 vlc_value_t, vlc_value_t, void * );
49 /*****************************************************************************
50 * aout_InputNew : allocate a new input and rework the filter pipeline
51 *****************************************************************************/
52 int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
54 audio_sample_format_t chain_input_format;
55 audio_sample_format_t chain_output_format;
56 vlc_value_t val, text;
57 char * psz_filters, *psz_visual;
60 aout_FormatPrint( p_aout, "input", &p_input->input );
62 p_input->i_nb_filters = 0;
65 aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
66 p_input->p_first_byte_to_mix = NULL;
68 /* Prepare format structure */
69 memcpy( &chain_input_format, &p_input->input,
70 sizeof(audio_sample_format_t) );
71 memcpy( &chain_output_format, &p_aout->mixer.mixer,
72 sizeof(audio_sample_format_t) );
73 chain_output_format.i_rate = p_input->input.i_rate;
74 aout_FormatPrepare( &chain_output_format );
76 /* Now add user filters */
77 if( var_Type( p_aout, "visual" ) == 0 )
80 var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
81 text.psz_string = _("Visualizations");
82 var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL );
83 val.psz_string = ""; text.psz_string = _("Disable");
84 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
85 val.psz_string = "spectrometer"; text.psz_string = _("Spectrometer");
86 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
87 val.psz_string = "scope"; text.psz_string = _("Scope");
88 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
89 val.psz_string = "spectrum"; text.psz_string = _("Spectrum");
90 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
92 /* Look for goom plugin */
93 p_module = config_FindModule( VLC_OBJECT(p_aout), "goom" );
96 val.psz_string = "goom"; text.psz_string = "Goom";
97 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
100 /* Look for galaktos plugin */
101 p_module = config_FindModule( VLC_OBJECT(p_aout), "galaktos" );
104 val.psz_string = "galaktos"; text.psz_string = "GaLaktos";
105 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
108 if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )
110 var_Set( p_aout, "visual", val );
111 if( val.psz_string ) free( val.psz_string );
113 var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );
116 if( var_Type( p_aout, "equalizer" ) == 0 )
118 module_config_t *p_config;
121 p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );
122 if( p_config && p_config->i_list )
124 var_Create( p_aout, "equalizer",
125 VLC_VAR_STRING | VLC_VAR_HASCHOICE );
126 text.psz_string = _("Equalizer");
127 var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );
129 val.psz_string = ""; text.psz_string = _("Disable");
130 var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );
132 for( i = 0; i < p_config->i_list; i++ )
134 val.psz_string = p_config->ppsz_list[i];
135 text.psz_string = p_config->ppsz_list_text[i];
136 var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
140 var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
144 if( var_Type( p_aout, "audio-filter" ) == 0 )
146 var_Create( p_aout, "audio-filter",
147 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
148 text.psz_string = _("Audio filters");
149 var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );
151 if( var_Type( p_aout, "audio-visual" ) == 0 )
153 var_Create( p_aout, "audio-visual",
154 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
155 text.psz_string = _("Audio visualizations");
156 var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL );
159 var_Get( p_aout, "audio-filter", &val );
160 psz_filters = val.psz_string;
161 var_Get( p_aout, "audio-visual", &val );
162 psz_visual = val.psz_string;
164 /* parse user filter lists */
165 for( i_visual = 0; i_visual < 2; i_visual++ )
167 char *psz_next = NULL;
168 char *psz_parser = i_visual ? psz_visual : psz_filters;
170 if( psz_parser == NULL || !*psz_parser )
173 while( psz_parser && *psz_parser )
175 aout_filter_t * p_filter = NULL;
177 if( p_input->i_nb_filters >= AOUT_MAX_FILTERS )
179 msg_Dbg( p_aout, "max filters reached (%d)", AOUT_MAX_FILTERS );
183 while( *psz_parser == ' ' && *psz_parser == ':' )
187 if( ( psz_next = strchr( psz_parser , ':' ) ) )
191 if( *psz_parser =='\0' )
196 /* Create a VLC object */
197 p_filter = vlc_object_create( p_aout, sizeof(aout_filter_t) );
198 if( p_filter == NULL )
200 msg_Err( p_aout, "cannot add user filter %s (skipped)",
202 psz_parser = psz_next;
206 vlc_object_attach( p_filter , p_aout );
208 /* try to find the requested filter */
209 if( i_visual == 1 ) /* this can only be a visualization module */
212 memcpy( &p_filter->input, &chain_output_format,
213 sizeof(audio_sample_format_t) );
214 memcpy( &p_filter->output, &chain_output_format,
215 sizeof(audio_sample_format_t) );
217 p_filter->p_module = module_Need( p_filter, "visualization",
218 psz_parser, VLC_TRUE );
220 else /* this can be a audio filter module as well as a visualization module */
223 memcpy( &p_filter->input, &chain_input_format,
224 sizeof(audio_sample_format_t) );
225 memcpy( &p_filter->output, &chain_output_format,
226 sizeof(audio_sample_format_t) );
228 p_filter->p_module = module_Need( p_filter, "audio filter",
229 psz_parser, VLC_TRUE );
231 if ( p_filter->p_module == NULL )
233 /* if the filter requested a special format, retry */
234 if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input,
235 &chain_input_format )
236 && AOUT_FMTS_IDENTICAL( &p_filter->output,
237 &chain_output_format ) ) )
239 aout_FormatPrepare( &p_filter->input );
240 aout_FormatPrepare( &p_filter->output );
241 p_filter->p_module = module_Need( p_filter,
243 psz_parser, VLC_TRUE );
245 /* try visual filters */
248 memcpy( &p_filter->input, &chain_output_format,
249 sizeof(audio_sample_format_t) );
250 memcpy( &p_filter->output, &chain_output_format,
251 sizeof(audio_sample_format_t) );
252 p_filter->p_module = module_Need( p_filter,
254 psz_parser, VLC_TRUE );
260 if ( p_filter->p_module == NULL )
262 msg_Err( p_aout, "cannot add user filter %s (skipped)",
265 vlc_object_detach( p_filter );
266 vlc_object_destroy( p_filter );
268 psz_parser = psz_next;
272 /* complete the filter chain if necessary */
273 if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) )
275 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
276 &p_input->i_nb_filters,
278 &p_filter->input ) < 0 )
280 msg_Err( p_aout, "cannot add user filter %s (skipped)",
283 module_Unneed( p_filter, p_filter->p_module );
284 vlc_object_detach( p_filter );
285 vlc_object_destroy( p_filter );
287 psz_parser = psz_next;
293 p_filter->b_continuity = VLC_FALSE;
294 p_input->pp_filters[p_input->i_nb_filters++] = p_filter;
295 memcpy( &chain_input_format, &p_filter->output,
296 sizeof( audio_sample_format_t ) );
298 /* next filter if any */
299 psz_parser = psz_next;
302 if( psz_filters ) free( psz_filters );
303 if( psz_visual ) free( psz_visual );
305 /* complete the filter chain if necessary */
306 if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) )
308 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
309 &p_input->i_nb_filters,
311 &chain_output_format ) < 0 )
313 inputFailure( p_aout, p_input, "couldn't set an input pipeline" );
318 /* Prepare hints for the buffer allocator. */
319 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
320 p_input->input_alloc.i_bytes_per_sec = -1;
322 /* Create resamplers. */
323 if ( AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) )
325 p_input->i_nb_resamplers = 0;
329 chain_output_format.i_rate = (__MAX(p_input->input.i_rate,
330 p_aout->mixer.mixer.i_rate)
331 * (100 + AOUT_MAX_RESAMPLING)) / 100;
332 if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate )
334 /* Just in case... */
335 chain_output_format.i_rate++;
337 p_input->i_nb_resamplers = 0;
338 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,
339 &p_input->i_nb_resamplers,
340 &chain_output_format,
341 &p_aout->mixer.mixer ) < 0 )
343 inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");
347 aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,
348 p_input->i_nb_resamplers,
349 &p_input->input_alloc );
350 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
352 /* Setup the initial rate of the resampler */
353 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
355 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
357 aout_FiltersHintBuffers( p_aout, p_input->pp_filters,
358 p_input->i_nb_filters,
359 &p_input->input_alloc );
360 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
362 /* i_bytes_per_sec is still == -1 if no filters */
363 p_input->input_alloc.i_bytes_per_sec = __MAX(
364 p_input->input_alloc.i_bytes_per_sec,
365 (int)(p_input->input.i_bytes_per_frame
366 * p_input->input.i_rate
367 / p_input->input.i_frame_length) );
370 p_input->b_error = VLC_FALSE;
371 p_input->b_restart = VLC_FALSE;
376 /*****************************************************************************
377 * aout_InputDelete : delete an input
378 *****************************************************************************
379 * This function must be entered with the mixer lock.
380 *****************************************************************************/
381 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
383 if ( p_input->b_error ) return 0;
385 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
386 p_input->i_nb_filters );
387 p_input->i_nb_filters = 0;
388 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
389 p_input->i_nb_resamplers );
390 p_input->i_nb_resamplers = 0;
391 aout_FifoDestroy( p_aout, &p_input->fifo );
396 /*****************************************************************************
397 * aout_InputPlay : play a buffer
398 *****************************************************************************
399 * This function must be entered with the input lock.
400 *****************************************************************************/
401 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
402 aout_buffer_t * p_buffer )
406 if( p_input->b_restart )
408 aout_fifo_t fifo, dummy_fifo;
409 byte_t *p_first_byte_to_mix;
411 vlc_mutex_lock( &p_aout->mixer_lock );
413 /* A little trick to avoid loosing our input fifo */
414 aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );
415 p_first_byte_to_mix = p_input->p_first_byte_to_mix;
416 fifo = p_input->fifo;
417 p_input->fifo = dummy_fifo;
418 aout_InputDelete( p_aout, p_input );
419 aout_InputNew( p_aout, p_input );
420 p_input->p_first_byte_to_mix = p_first_byte_to_mix;
421 p_input->fifo = fifo;
423 vlc_mutex_unlock( &p_aout->mixer_lock );
426 /* We don't care if someone changes the start date behind our back after
427 * this. We'll deal with that when pushing the buffer, and compensate
428 * with the next incoming buffer. */
429 vlc_mutex_lock( &p_aout->input_fifos_lock );
430 start_date = aout_FifoNextStart( p_aout, &p_input->fifo );
431 vlc_mutex_unlock( &p_aout->input_fifos_lock );
433 if ( start_date != 0 && start_date < mdate() )
435 /* The decoder is _very_ late. This can only happen if the user
436 * pauses the stream (or if the decoder is buggy, which cannot
438 msg_Warn( p_aout, "computed PTS is out of range ("I64Fd"), "
439 "clearing out", mdate() - start_date );
440 vlc_mutex_lock( &p_aout->input_fifos_lock );
441 aout_FifoSet( p_aout, &p_input->fifo, 0 );
442 p_input->p_first_byte_to_mix = NULL;
443 vlc_mutex_unlock( &p_aout->input_fifos_lock );
444 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
445 msg_Warn( p_aout, "timing screwed, stopping resampling" );
446 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
447 if ( p_input->i_nb_resamplers != 0 )
449 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
450 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
453 if( p_input->p_input_thread )
455 vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock);
456 stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL );
457 vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock);
461 if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
463 /* The decoder gives us f*cked up PTS. It's its business, but we
464 * can't present it anyway, so drop the buffer. */
465 msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
466 mdate() - p_buffer->start_date );
467 if( p_input->p_input_thread )
469 vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock);
470 stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL );
471 vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock);
473 aout_BufferFree( p_buffer );
474 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
475 if ( p_input->i_nb_resamplers != 0 )
477 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
478 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
483 /* If the audio drift is too big then it's not worth trying to resample
485 if ( start_date != 0 &&
486 ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) )
488 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), clearing out",
489 start_date - p_buffer->start_date );
490 vlc_mutex_lock( &p_aout->input_fifos_lock );
491 aout_FifoSet( p_aout, &p_input->fifo, 0 );
492 p_input->p_first_byte_to_mix = NULL;
493 vlc_mutex_unlock( &p_aout->input_fifos_lock );
494 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
495 msg_Warn( p_aout, "timing screwed, stopping resampling" );
496 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
497 if ( p_input->i_nb_resamplers != 0 )
499 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
500 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
504 else if ( start_date != 0 &&
505 ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) )
507 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
508 start_date - p_buffer->start_date );
509 aout_BufferFree( p_buffer );
510 if( p_input->p_input_thread )
512 vlc_mutex_lock( &p_input->p_input_thread->counters.counters_lock);
513 stats_UpdateInteger( p_aout, p_input->p_input_thread->counters.p_lost_abuffers, 1, NULL );
514 vlc_mutex_unlock( &p_input->p_input_thread->counters.counters_lock);
519 if ( start_date == 0 ) start_date = p_buffer->start_date;
521 /* Run pre-filters. */
523 aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,
526 /* Run the resampler if needed.
527 * We first need to calculate the output rate of this resampler. */
528 if ( ( p_input->i_resampling_type == AOUT_RESAMPLING_NONE ) &&
529 ( start_date < p_buffer->start_date - AOUT_PTS_TOLERANCE
530 || start_date > p_buffer->start_date + AOUT_PTS_TOLERANCE ) &&
531 p_input->i_nb_resamplers > 0 )
533 /* Can happen in several circumstances :
534 * 1. A problem at the input (clock drift)
535 * 2. A small pause triggered by the user
536 * 3. Some delay in the output stage, causing a loss of lip
538 * Solution : resample the buffer to avoid a scratch.
540 mtime_t drift = p_buffer->start_date - start_date;
542 p_input->i_resamp_start_date = mdate();
543 p_input->i_resamp_start_drift = (int)drift;
546 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
548 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
550 msg_Warn( p_aout, "buffer is "I64Fd" %s, triggering %ssampling",
551 drift > 0 ? drift : -drift,
552 drift > 0 ? "in advance" : "late",
553 drift > 0 ? "down" : "up");
556 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
558 /* Resampling has been triggered previously (because of dates
559 * mismatch). We want the resampling to happen progressively so
560 * it isn't too audible to the listener. */
562 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
564 p_input->pp_resamplers[0]->input.i_rate += 2; /* Hz */
568 p_input->pp_resamplers[0]->input.i_rate -= 2; /* Hz */
571 /* Check if everything is back to normal, in which case we can stop the
573 if( p_input->pp_resamplers[0]->input.i_rate ==
574 p_input->input.i_rate )
576 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
577 msg_Warn( p_aout, "resampling stopped after "I64Fi" usec "
579 mdate() - p_input->i_resamp_start_date,
580 p_buffer->start_date - start_date);
582 else if( abs( (int)(p_buffer->start_date - start_date) ) <
583 abs( p_input->i_resamp_start_drift ) / 2 )
585 /* if we reduced the drift from half, then it is time to switch
586 * back the resampling direction. */
587 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
588 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
590 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
591 p_input->i_resamp_start_drift = 0;
593 else if( p_input->i_resamp_start_drift &&
594 ( abs( (int)(p_buffer->start_date - start_date) ) >
595 abs( p_input->i_resamp_start_drift ) * 3 / 2 ) )
597 /* If the drift is increasing and not decreasing, than something
598 * is bad. We'd better stop the resampling right now. */
599 msg_Warn( p_aout, "timing screwed, stopping resampling" );
600 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
601 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
605 /* Adding the start date will be managed by aout_FifoPush(). */
606 p_buffer->end_date = start_date +
607 (p_buffer->end_date - p_buffer->start_date);
608 p_buffer->start_date = start_date;
610 /* Actually run the resampler now. */
611 if ( p_input->i_nb_resamplers > 0 )
613 aout_FiltersPlay( p_aout, p_input->pp_resamplers,
614 p_input->i_nb_resamplers,
618 vlc_mutex_lock( &p_aout->input_fifos_lock );
619 aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
620 vlc_mutex_unlock( &p_aout->input_fifos_lock );
625 /*****************************************************************************
627 *****************************************************************************/
629 static void inputFailure( aout_instance_t * p_aout, aout_input_t * p_input,
630 char * psz_error_message )
633 msg_Err( p_aout, "couldn't set an input pipeline" );
636 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
637 p_input->i_nb_filters );
638 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
639 p_input->i_nb_resamplers );
640 aout_FifoDestroy( p_aout, &p_input->fifo );
641 var_Destroy( p_aout, "visual" );
642 var_Destroy( p_aout, "equalizer" );
643 var_Destroy( p_aout, "audio-filter" );
644 var_Destroy( p_aout, "audio-visual" );
647 p_input->b_error = 1;
650 static int ChangeFiltersString( aout_instance_t * p_aout, char* psz_variable,
651 char *psz_name, vlc_bool_t b_add )
656 var_Get( p_aout, psz_variable, &val );
658 if( !val.psz_string ) val.psz_string = strdup("");
660 psz_parser = strstr( val.psz_string, psz_name );
666 psz_parser = val.psz_string;
667 asprintf( &val.psz_string, (*val.psz_string) ? "%s:%s" : "%s%s",
668 val.psz_string, psz_name );
680 memmove( psz_parser, psz_parser + strlen(psz_name) +
681 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
682 strlen(psz_parser + strlen(psz_name)) + 1 );
686 free( val.psz_string );
691 var_Set( p_aout, psz_variable, val );
692 free( val.psz_string );
696 static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
697 vlc_value_t oldval, vlc_value_t newval, void *p_data )
699 aout_instance_t *p_aout = (aout_instance_t *)p_this;
700 char *psz_mode = newval.psz_string;
704 if( !psz_mode || !*psz_mode )
706 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
707 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
708 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE );
712 if( !strcmp( "goom", psz_mode ) )
714 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
715 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_TRUE );
716 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
718 else if( !strcmp( "galaktos", psz_mode ) )
720 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
721 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
722 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_TRUE );
726 val.psz_string = psz_mode;
727 var_Create( p_aout, "effect-list", VLC_VAR_STRING );
728 var_Set( p_aout, "effect-list", val );
730 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
731 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_TRUE );
732 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
737 for( i = 0; i < p_aout->i_nb_inputs; i++ )
739 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
745 static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd,
746 vlc_value_t oldval, vlc_value_t newval, void *p_data )
748 aout_instance_t *p_aout = (aout_instance_t *)p_this;
749 char *psz_mode = newval.psz_string;
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;