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 void inputDrop( aout_instance_t *, aout_input_t * );
48 static int VisualizationCallback( vlc_object_t *, char const *,
49 vlc_value_t, vlc_value_t, void * );
50 static int EqualizerCallback( vlc_object_t *, char const *,
51 vlc_value_t, vlc_value_t, void * );
53 /*****************************************************************************
54 * aout_InputNew : allocate a new input and rework the filter pipeline
55 *****************************************************************************/
56 int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
58 audio_sample_format_t chain_input_format;
59 audio_sample_format_t chain_output_format;
60 vlc_value_t val, text;
61 char * psz_filters, *psz_visual;
64 aout_FormatPrint( p_aout, "input", &p_input->input );
66 p_input->i_nb_resamplers = p_input->i_nb_filters = 0;
69 aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
70 p_input->p_first_byte_to_mix = NULL;
72 /* Prepare format structure */
73 memcpy( &chain_input_format, &p_input->input,
74 sizeof(audio_sample_format_t) );
75 memcpy( &chain_output_format, &p_aout->mixer.mixer,
76 sizeof(audio_sample_format_t) );
77 chain_output_format.i_rate = p_input->input.i_rate;
78 aout_FormatPrepare( &chain_output_format );
80 /* Now add user filters */
81 if( var_Type( p_aout, "visual" ) == 0 )
84 var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
85 text.psz_string = _("Visualizations");
86 var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL );
87 val.psz_string = ""; text.psz_string = _("Disable");
88 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
89 val.psz_string = "spectrometer"; text.psz_string = _("Spectrometer");
90 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
91 val.psz_string = "scope"; text.psz_string = _("Scope");
92 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
93 val.psz_string = "spectrum"; text.psz_string = _("Spectrum");
94 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
96 /* Look for goom plugin */
97 p_module = config_FindModule( VLC_OBJECT(p_aout), "goom" );
100 val.psz_string = "goom"; text.psz_string = "Goom";
101 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
104 /* Look for galaktos plugin */
105 p_module = config_FindModule( VLC_OBJECT(p_aout), "galaktos" );
108 val.psz_string = "galaktos"; text.psz_string = "GaLaktos";
109 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
112 if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )
114 var_Set( p_aout, "visual", val );
115 if( val.psz_string ) free( val.psz_string );
117 var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );
120 if( var_Type( p_aout, "equalizer" ) == 0 )
122 module_config_t *p_config;
125 p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );
126 if( p_config && p_config->i_list )
128 var_Create( p_aout, "equalizer",
129 VLC_VAR_STRING | VLC_VAR_HASCHOICE );
130 text.psz_string = _("Equalizer");
131 var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );
133 val.psz_string = ""; text.psz_string = _("Disable");
134 var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );
136 for( i = 0; i < p_config->i_list; i++ )
138 val.psz_string = (char *)p_config->ppsz_list[i];
139 text.psz_string = (char *)p_config->ppsz_list_text[i];
140 var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
144 var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
148 if( var_Type( p_aout, "audio-filter" ) == 0 )
150 var_Create( p_aout, "audio-filter",
151 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
152 text.psz_string = _("Audio filters");
153 var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );
155 if( var_Type( p_aout, "audio-visual" ) == 0 )
157 var_Create( p_aout, "audio-visual",
158 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
159 text.psz_string = _("Audio visualizations");
160 var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL );
163 var_Get( p_aout, "audio-filter", &val );
164 psz_filters = val.psz_string;
165 var_Get( p_aout, "audio-visual", &val );
166 psz_visual = val.psz_string;
168 /* parse user filter lists */
169 for( i_visual = 0; i_visual < 2; i_visual++ )
171 char *psz_next = NULL;
172 char *psz_parser = i_visual ? psz_visual : psz_filters;
174 if( psz_parser == NULL || !*psz_parser )
177 while( psz_parser && *psz_parser )
179 aout_filter_t * p_filter = NULL;
181 if( p_input->i_nb_filters >= AOUT_MAX_FILTERS )
183 msg_Dbg( p_aout, "max filters reached (%d)", AOUT_MAX_FILTERS );
187 while( *psz_parser == ' ' && *psz_parser == ':' )
191 if( ( psz_next = strchr( psz_parser , ':' ) ) )
195 if( *psz_parser =='\0' )
200 /* Create a VLC object */
201 p_filter = vlc_object_create( p_aout, sizeof(aout_filter_t) );
202 if( p_filter == NULL )
204 msg_Err( p_aout, "cannot add user filter %s (skipped)",
206 psz_parser = psz_next;
210 vlc_object_attach( p_filter , p_aout );
212 /* try to find the requested filter */
213 if( i_visual == 1 ) /* this can only be a visualization module */
216 memcpy( &p_filter->input, &chain_output_format,
217 sizeof(audio_sample_format_t) );
218 memcpy( &p_filter->output, &chain_output_format,
219 sizeof(audio_sample_format_t) );
221 p_filter->p_module = module_Need( p_filter, "visualization",
222 psz_parser, VLC_TRUE );
224 else /* this can be a audio filter module as well as a visualization module */
227 memcpy( &p_filter->input, &chain_input_format,
228 sizeof(audio_sample_format_t) );
229 memcpy( &p_filter->output, &chain_output_format,
230 sizeof(audio_sample_format_t) );
232 p_filter->p_module = module_Need( p_filter, "audio filter",
233 psz_parser, VLC_TRUE );
235 if ( p_filter->p_module == NULL )
237 /* if the filter requested a special format, retry */
238 if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input,
239 &chain_input_format )
240 && AOUT_FMTS_IDENTICAL( &p_filter->output,
241 &chain_output_format ) ) )
243 aout_FormatPrepare( &p_filter->input );
244 aout_FormatPrepare( &p_filter->output );
245 p_filter->p_module = module_Need( p_filter,
247 psz_parser, VLC_TRUE );
249 /* try visual filters */
252 memcpy( &p_filter->input, &chain_output_format,
253 sizeof(audio_sample_format_t) );
254 memcpy( &p_filter->output, &chain_output_format,
255 sizeof(audio_sample_format_t) );
256 p_filter->p_module = module_Need( p_filter,
258 psz_parser, VLC_TRUE );
264 if ( p_filter->p_module == NULL )
266 msg_Err( p_aout, "cannot add user filter %s (skipped)",
269 vlc_object_detach( p_filter );
270 vlc_object_destroy( p_filter );
272 psz_parser = psz_next;
276 /* complete the filter chain if necessary */
277 if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) )
279 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
280 &p_input->i_nb_filters,
282 &p_filter->input ) < 0 )
284 msg_Err( p_aout, "cannot add user filter %s (skipped)",
287 module_Unneed( p_filter, p_filter->p_module );
288 vlc_object_detach( p_filter );
289 vlc_object_destroy( p_filter );
291 psz_parser = psz_next;
297 p_filter->b_continuity = VLC_FALSE;
298 p_input->pp_filters[p_input->i_nb_filters++] = p_filter;
299 memcpy( &chain_input_format, &p_filter->output,
300 sizeof( audio_sample_format_t ) );
302 /* next filter if any */
303 psz_parser = psz_next;
306 if( psz_filters ) free( psz_filters );
307 if( psz_visual ) free( psz_visual );
309 /* complete the filter chain if necessary */
310 if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) )
312 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
313 &p_input->i_nb_filters,
315 &chain_output_format ) < 0 )
317 inputFailure( p_aout, p_input, "couldn't set an input pipeline" );
322 /* Prepare hints for the buffer allocator. */
323 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
324 p_input->input_alloc.i_bytes_per_sec = -1;
326 /* Create resamplers. */
327 if ( !AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) )
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 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,
338 &p_input->i_nb_resamplers,
339 &chain_output_format,
340 &p_aout->mixer.mixer ) < 0 )
342 inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");
346 aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,
347 p_input->i_nb_resamplers,
348 &p_input->input_alloc );
349 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
351 /* Setup the initial rate of the resampler */
352 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
354 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
356 aout_FiltersHintBuffers( p_aout, p_input->pp_filters,
357 p_input->i_nb_filters,
358 &p_input->input_alloc );
359 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
361 /* i_bytes_per_sec is still == -1 if no filters */
362 p_input->input_alloc.i_bytes_per_sec = __MAX(
363 p_input->input_alloc.i_bytes_per_sec,
364 (int)(p_input->input.i_bytes_per_frame
365 * p_input->input.i_rate
366 / p_input->input.i_frame_length) );
369 p_input->b_error = VLC_FALSE;
370 p_input->b_restart = VLC_FALSE;
375 /*****************************************************************************
376 * aout_InputDelete : delete an input
377 *****************************************************************************
378 * This function must be entered with the mixer lock.
379 *****************************************************************************/
380 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
382 if ( p_input->b_error ) return 0;
384 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
385 p_input->i_nb_filters );
386 p_input->i_nb_filters = 0;
387 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
388 p_input->i_nb_resamplers );
389 p_input->i_nb_resamplers = 0;
390 aout_FifoDestroy( p_aout, &p_input->fifo );
395 /*****************************************************************************
396 * aout_InputPlay : play a buffer
397 *****************************************************************************
398 * This function must be entered with the input lock.
399 *****************************************************************************/
400 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
401 aout_buffer_t * p_buffer )
405 if( p_input->b_restart )
407 aout_fifo_t fifo, dummy_fifo;
408 byte_t *p_first_byte_to_mix;
410 vlc_mutex_lock( &p_aout->mixer_lock );
412 /* A little trick to avoid loosing our input fifo */
413 aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );
414 p_first_byte_to_mix = p_input->p_first_byte_to_mix;
415 fifo = p_input->fifo;
416 p_input->fifo = dummy_fifo;
417 aout_InputDelete( p_aout, p_input );
418 aout_InputNew( p_aout, p_input );
419 p_input->p_first_byte_to_mix = p_first_byte_to_mix;
420 p_input->fifo = fifo;
422 vlc_mutex_unlock( &p_aout->mixer_lock );
425 /* We don't care if someone changes the start date behind our back after
426 * this. We'll deal with that when pushing the buffer, and compensate
427 * with the next incoming buffer. */
428 vlc_mutex_lock( &p_aout->input_fifos_lock );
429 start_date = aout_FifoNextStart( p_aout, &p_input->fifo );
430 vlc_mutex_unlock( &p_aout->input_fifos_lock );
432 if ( start_date != 0 && start_date < mdate() )
434 /* The decoder is _very_ late. This can only happen if the user
435 * pauses the stream (or if the decoder is buggy, which cannot
437 msg_Warn( p_aout, "computed PTS is out of range ("I64Fd"), "
438 "clearing out", mdate() - start_date );
439 vlc_mutex_lock( &p_aout->input_fifos_lock );
440 aout_FifoSet( p_aout, &p_input->fifo, 0 );
441 p_input->p_first_byte_to_mix = NULL;
442 vlc_mutex_unlock( &p_aout->input_fifos_lock );
443 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
444 msg_Warn( p_aout, "timing screwed, stopping resampling" );
445 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
446 if ( p_input->i_nb_resamplers != 0 )
448 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
449 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
452 inputDrop( p_aout, p_input );
455 if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
457 /* The decoder gives us f*cked up PTS. It's its business, but we
458 * can't present it anyway, so drop the buffer. */
459 msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
460 mdate() - p_buffer->start_date );
462 inputDrop( p_aout, p_input );
463 aout_BufferFree( p_buffer );
464 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
465 if ( p_input->i_nb_resamplers != 0 )
467 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
468 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
473 /* If the audio drift is too big then it's not worth trying to resample
475 if ( start_date != 0 &&
476 ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) )
478 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), clearing out",
479 start_date - p_buffer->start_date );
480 vlc_mutex_lock( &p_aout->input_fifos_lock );
481 aout_FifoSet( p_aout, &p_input->fifo, 0 );
482 p_input->p_first_byte_to_mix = NULL;
483 vlc_mutex_unlock( &p_aout->input_fifos_lock );
484 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
485 msg_Warn( p_aout, "timing screwed, stopping resampling" );
486 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
487 if ( p_input->i_nb_resamplers != 0 )
489 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
490 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
494 else if ( start_date != 0 &&
495 ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) )
497 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
498 start_date - p_buffer->start_date );
499 aout_BufferFree( p_buffer );
500 inputDrop( p_aout, p_input );
504 if ( start_date == 0 ) start_date = p_buffer->start_date;
506 /* Run pre-filters. */
508 aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,
511 /* Run the resampler if needed.
512 * We first need to calculate the output rate of this resampler. */
513 if ( ( p_input->i_resampling_type == AOUT_RESAMPLING_NONE ) &&
514 ( start_date < p_buffer->start_date - AOUT_PTS_TOLERANCE
515 || start_date > p_buffer->start_date + AOUT_PTS_TOLERANCE ) &&
516 p_input->i_nb_resamplers > 0 )
518 /* Can happen in several circumstances :
519 * 1. A problem at the input (clock drift)
520 * 2. A small pause triggered by the user
521 * 3. Some delay in the output stage, causing a loss of lip
523 * Solution : resample the buffer to avoid a scratch.
525 mtime_t drift = p_buffer->start_date - start_date;
527 p_input->i_resamp_start_date = mdate();
528 p_input->i_resamp_start_drift = (int)drift;
531 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
533 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
535 msg_Warn( p_aout, "buffer is "I64Fd" %s, triggering %ssampling",
536 drift > 0 ? drift : -drift,
537 drift > 0 ? "in advance" : "late",
538 drift > 0 ? "down" : "up");
541 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
543 /* Resampling has been triggered previously (because of dates
544 * mismatch). We want the resampling to happen progressively so
545 * it isn't too audible to the listener. */
547 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
549 p_input->pp_resamplers[0]->input.i_rate += 2; /* Hz */
553 p_input->pp_resamplers[0]->input.i_rate -= 2; /* Hz */
556 /* Check if everything is back to normal, in which case we can stop the
558 if( p_input->pp_resamplers[0]->input.i_rate ==
559 p_input->input.i_rate )
561 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
562 msg_Warn( p_aout, "resampling stopped after "I64Fi" usec "
564 mdate() - p_input->i_resamp_start_date,
565 p_buffer->start_date - start_date);
567 else if( abs( (int)(p_buffer->start_date - start_date) ) <
568 abs( p_input->i_resamp_start_drift ) / 2 )
570 /* if we reduced the drift from half, then it is time to switch
571 * back the resampling direction. */
572 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
573 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
575 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
576 p_input->i_resamp_start_drift = 0;
578 else if( p_input->i_resamp_start_drift &&
579 ( abs( (int)(p_buffer->start_date - start_date) ) >
580 abs( p_input->i_resamp_start_drift ) * 3 / 2 ) )
582 /* If the drift is increasing and not decreasing, than something
583 * is bad. We'd better stop the resampling right now. */
584 msg_Warn( p_aout, "timing screwed, stopping resampling" );
585 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
586 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
590 /* Adding the start date will be managed by aout_FifoPush(). */
591 p_buffer->end_date = start_date +
592 (p_buffer->end_date - p_buffer->start_date);
593 p_buffer->start_date = start_date;
595 /* Actually run the resampler now. */
596 if ( p_input->i_nb_resamplers > 0 )
598 aout_FiltersPlay( p_aout, p_input->pp_resamplers,
599 p_input->i_nb_resamplers,
603 vlc_mutex_lock( &p_aout->input_fifos_lock );
604 aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
605 vlc_mutex_unlock( &p_aout->input_fifos_lock );
610 /*****************************************************************************
612 *****************************************************************************/
614 static void inputFailure( aout_instance_t * p_aout, aout_input_t * p_input,
615 const char * psz_error_message )
618 msg_Err( p_aout, "%s", psz_error_message );
621 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
622 p_input->i_nb_filters );
623 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
624 p_input->i_nb_resamplers );
625 aout_FifoDestroy( p_aout, &p_input->fifo );
626 var_Destroy( p_aout, "visual" );
627 var_Destroy( p_aout, "equalizer" );
628 var_Destroy( p_aout, "audio-filter" );
629 var_Destroy( p_aout, "audio-visual" );
632 p_input->b_error = 1;
635 static void inputDrop( aout_instance_t *p_aout, aout_input_t *p_input )
637 if( !p_input->p_input_thread )
640 vlc_mutex_lock( &p_input->p_input_thread->p->counters.counters_lock);
641 stats_UpdateInteger( p_aout, p_input->p_input_thread->p->counters.p_lost_abuffers, 1, NULL );
642 vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock);
645 static int ChangeFiltersString( aout_instance_t * p_aout, const char* psz_variable,
646 const char *psz_name, vlc_bool_t b_add )
651 var_Get( p_aout, psz_variable, &val );
653 if( !val.psz_string ) val.psz_string = strdup("");
655 psz_parser = strstr( val.psz_string, psz_name );
661 psz_parser = val.psz_string;
662 asprintf( &val.psz_string, (*val.psz_string) ? "%s:%s" : "%s%s",
663 val.psz_string, psz_name );
675 memmove( psz_parser, psz_parser + strlen(psz_name) +
676 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
677 strlen(psz_parser + strlen(psz_name)) + 1 );
681 free( val.psz_string );
686 var_Set( p_aout, psz_variable, val );
687 free( val.psz_string );
691 static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
692 vlc_value_t oldval, vlc_value_t newval, void *p_data )
694 aout_instance_t *p_aout = (aout_instance_t *)p_this;
695 char *psz_mode = newval.psz_string;
698 (void)psz_cmd; (void)oldval; (void)p_data;
700 if( !psz_mode || !*psz_mode )
702 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
703 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
704 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE );
708 if( !strcmp( "goom", psz_mode ) )
710 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
711 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_TRUE );
712 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
714 else if( !strcmp( "galaktos", psz_mode ) )
716 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
717 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
718 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_TRUE );
722 val.psz_string = psz_mode;
723 var_Create( p_aout, "effect-list", VLC_VAR_STRING );
724 var_Set( p_aout, "effect-list", val );
726 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
727 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_TRUE );
728 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
733 for( i = 0; i < p_aout->i_nb_inputs; i++ )
735 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
741 static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd,
742 vlc_value_t oldval, vlc_value_t newval, void *p_data )
744 aout_instance_t *p_aout = (aout_instance_t *)p_this;
745 char *psz_mode = newval.psz_string;
749 (void)psz_cmd; (void)oldval; (void)p_data;
751 if( !psz_mode || !*psz_mode )
753 i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
758 val.psz_string = psz_mode;
759 var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING );
760 var_Set( p_aout, "equalizer-preset", val );
761 i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
769 for( i = 0; i < p_aout->i_nb_inputs; i++ )
771 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;