- /* */
- if( p_request_vout )
- {
- p_input->request_vout = *p_request_vout;
- }
- else
- {
- p_input->request_vout.pf_request_vout = RequestVout;
- p_input->request_vout.p_private = p_aout;
- }
-
- /* Prepare format structure */
- memcpy( &chain_input_format, &p_input->input,
- sizeof(audio_sample_format_t) );
- memcpy( &chain_output_format, &p_aout->mixer.mixer,
- sizeof(audio_sample_format_t) );
- chain_output_format.i_rate = p_input->input.i_rate;
- aout_FormatPrepare( &chain_output_format );
-
- /* Now add user filters */
- if( var_Type( p_aout, "visual" ) == 0 )
- {
- var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
- text.psz_string = _("Visualizations");
- var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL );
- val.psz_string = (char*)""; text.psz_string = _("Disable");
- var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
- val.psz_string = (char*)"spectrometer"; text.psz_string = _("Spectrometer");
- var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
- val.psz_string = (char*)"scope"; text.psz_string = _("Scope");
- var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
- val.psz_string = (char*)"spectrum"; text.psz_string = _("Spectrum");
- var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
- val.psz_string = (char*)"vuMeter"; text.psz_string = _("Vu meter");
- var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
-
- /* Look for goom plugin */
- if( module_exists( "goom" ) )
- {
- val.psz_string = (char*)"goom"; text.psz_string = (char*)"Goom";
- var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
- }
-
- /* Look for galaktos plugin */
- if( module_exists( "galaktos" ) )
- {
- val.psz_string = (char*)"galaktos"; text.psz_string = (char*)"GaLaktos";
- var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
- }
-
- if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )
- {
- var_Set( p_aout, "visual", val );
- free( val.psz_string );
- }
- var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );
- }
-
- if( var_Type( p_aout, "equalizer" ) == 0 )
- {
- module_config_t *p_config;
- int i;
-
- p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );
- if( p_config && p_config->i_list )
- {
- var_Create( p_aout, "equalizer",
- VLC_VAR_STRING | VLC_VAR_HASCHOICE );
- text.psz_string = _("Equalizer");
- var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );
-
- val.psz_string = (char*)""; text.psz_string = _("Disable");
- var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );
-
- for( i = 0; i < p_config->i_list; i++ )
- {
- val.psz_string = (char *)p_config->ppsz_list[i];
- text.psz_string = (char *)p_config->ppsz_list_text[i];
- var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
- &val, &text );
- }
-
- var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
- }
- }
-
- if( var_Type( p_aout, "audio-filter" ) == 0 )
- {
- var_Create( p_aout, "audio-filter",
- VLC_VAR_STRING | VLC_VAR_DOINHERIT );
- text.psz_string = _("Audio filters");
- var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );
- }
- if( var_Type( p_aout, "audio-visual" ) == 0 )
- {
- var_Create( p_aout, "audio-visual",
- VLC_VAR_STRING | VLC_VAR_DOINHERIT );
- text.psz_string = _("Audio visualizations");
- var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL );
- }
-
- if( var_Type( p_aout, "audio-replay-gain-mode" ) == 0 )
- {
- module_config_t *p_config;
- int i;
-
- p_config = config_FindConfig( VLC_OBJECT(p_aout), "audio-replay-gain-mode" );
- if( p_config && p_config->i_list )
- {
- var_Create( p_aout, "audio-replay-gain-mode",
- VLC_VAR_STRING | VLC_VAR_DOINHERIT );
-
- text.psz_string = _("Replay gain");
- var_Change( p_aout, "audio-replay-gain-mode", VLC_VAR_SETTEXT, &text, NULL );
-
- for( i = 0; i < p_config->i_list; i++ )
- {
- val.psz_string = (char *)p_config->ppsz_list[i];
- text.psz_string = (char *)p_config->ppsz_list_text[i];
- var_Change( p_aout, "audio-replay-gain-mode", VLC_VAR_ADDCHOICE,
- &val, &text );
- }
-
- var_AddCallback( p_aout, "audio-replay-gain-mode", ReplayGainCallback, NULL );
- }
- }
- if( var_Type( p_aout, "audio-replay-gain-preamp" ) == 0 )
- {
- var_Create( p_aout, "audio-replay-gain-preamp",
- VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
- }
- if( var_Type( p_aout, "audio-replay-gain-default" ) == 0 )
- {
- var_Create( p_aout, "audio-replay-gain-default",
- VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
- }
- if( var_Type( p_aout, "audio-replay-gain-peak-protection" ) == 0 )
- {
- var_Create( p_aout, "audio-replay-gain-peak-protection",
- VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
- }
- if( var_Type( p_aout, "audio-time-stretch" ) == 0 )
- {
- var_Create( p_aout, "audio-time-stretch",
- VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
- }
-
- var_Get( p_aout, "audio-filter", &val );
- psz_filters = val.psz_string;
- var_Get( p_aout, "audio-visual", &val );
- psz_visual = val.psz_string;
-
- psz_scaletempo = var_GetBool( p_aout, "audio-time-stretch" ) ? strdup( "scaletempo" ) : NULL;
-
- /* parse user filter lists */
- for( i_visual = 0; i_visual < 3 && !AOUT_FMT_NON_LINEAR(&chain_output_format); i_visual++ )
- {
- char *ppsz_array[] = { psz_scaletempo, psz_filters, psz_visual };
- char *psz_next = NULL;
- char *psz_parser = ppsz_array[i_visual];
-
- if( psz_parser == NULL || !*psz_parser )
- continue;
-
- while( psz_parser && *psz_parser )
- {
- aout_filter_t * p_filter = NULL;
-
- if( p_input->i_nb_filters >= AOUT_MAX_FILTERS )
- {
- msg_Dbg( p_aout, "max filters reached (%d)", AOUT_MAX_FILTERS );
- break;
- }
-
- while( *psz_parser == ' ' && *psz_parser == ':' )
- {
- psz_parser++;
- }
- if( ( psz_next = strchr( psz_parser , ':' ) ) )
- {
- *psz_next++ = '\0';
- }
- if( *psz_parser =='\0' )
- {
- break;
- }
-
- /* Create a VLC object */
- static const char typename[] = "audio filter";
- p_filter = vlc_custom_create( p_aout, sizeof(*p_filter),
- VLC_OBJECT_GENERIC, typename );
- if( p_filter == NULL )
- {
- msg_Err( p_aout, "cannot add user filter %s (skipped)",
- psz_parser );
- psz_parser = psz_next;
- continue;
- }
-
- vlc_object_attach( p_filter , p_aout );
-
- p_filter->request_vout = p_input->request_vout;
- p_filter->p_owner = malloc( sizeof(*p_filter->p_owner) );
- p_filter->p_owner->p_aout = p_aout;
- p_filter->p_owner->p_input = p_input;
-
- /* try to find the requested filter */
- if( i_visual == 2 ) /* this can only be a visualization module */
- {
- /* request format */
- memcpy( &p_filter->input, &chain_output_format,
- sizeof(audio_sample_format_t) );
- memcpy( &p_filter->output, &chain_output_format,
- sizeof(audio_sample_format_t) );
-
- p_filter->p_module = module_need( p_filter, "visualization",
- psz_parser, true );
- }
- else /* this can be a audio filter module as well as a visualization module */
- {
- /* request format */
- memcpy( &p_filter->input, &chain_input_format,
- sizeof(audio_sample_format_t) );
- memcpy( &p_filter->output, &chain_output_format,
- sizeof(audio_sample_format_t) );
-
- p_filter->p_module = module_need( p_filter, "audio filter",
- psz_parser, true );
-
- if ( p_filter->p_module == NULL )
- {
- /* if the filter requested a special format, retry */
- if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input,
- &chain_input_format )
- && AOUT_FMTS_IDENTICAL( &p_filter->output,
- &chain_output_format ) ) )
- {
- aout_FormatPrepare( &p_filter->input );
- aout_FormatPrepare( &p_filter->output );
- p_filter->p_module = module_need( p_filter,
- "audio filter",
- psz_parser, true );
- }
- /* try visual filters */
- else
- {
- memcpy( &p_filter->input, &chain_output_format,
- sizeof(audio_sample_format_t) );
- memcpy( &p_filter->output, &chain_output_format,
- sizeof(audio_sample_format_t) );
- p_filter->p_module = module_need( p_filter,
- "visualization",
- psz_parser, true );
- }
- }
- }
-
- /* failure */
- if ( p_filter->p_module == NULL )
- {
- msg_Err( p_aout, "cannot add user filter %s (skipped)",
- psz_parser );
-
- free( p_filter->p_owner );
- vlc_object_detach( p_filter );
- vlc_object_release( p_filter );
-
- psz_parser = psz_next;
- continue;
- }
-
- /* complete the filter chain if necessary */
- if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) )
- {
- if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
- &p_input->i_nb_filters,
- &chain_input_format,
- &p_filter->input ) < 0 )
- {
- msg_Err( p_aout, "cannot add user filter %s (skipped)",
- psz_parser );
-
- module_unneed( p_filter, p_filter->p_module );
- free( p_filter->p_owner );
- vlc_object_detach( p_filter );
- vlc_object_release( p_filter );
-
- psz_parser = psz_next;
- continue;
- }
- }
-
- /* success */
- p_filter->b_continuity = false;
- p_input->pp_filters[p_input->i_nb_filters++] = p_filter;
- memcpy( &chain_input_format, &p_filter->output,
- sizeof( audio_sample_format_t ) );
-
- /* next filter if any */
- psz_parser = psz_next;
- }
- }
- free( psz_visual );
- free( psz_filters );
- free( psz_scaletempo );
-
- /* complete the filter chain if necessary */
- if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) )
- {
- if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
- &p_input->i_nb_filters,
- &chain_input_format,
- &chain_output_format ) < 0 )
- {
- inputFailure( p_aout, p_input, "couldn't set an input pipeline" );
- return -1;
- }
- }
-
- /* Prepare hints for the buffer allocator. */
- p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
- p_input->input_alloc.i_bytes_per_sec = -1;
-
- /* Create resamplers. */
- if ( !AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) )
- {
- chain_output_format.i_rate = (__MAX(p_input->input.i_rate,
- p_aout->mixer.mixer.i_rate)
- * (100 + AOUT_MAX_RESAMPLING)) / 100;
- if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate )
- {
- /* Just in case... */
- chain_output_format.i_rate++;
- }
- if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,
- &p_input->i_nb_resamplers,
- &chain_output_format,
- &p_aout->mixer.mixer ) < 0 )
- {
- inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");
- return -1;
- }
-
- aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,
- p_input->i_nb_resamplers,
- &p_input->input_alloc );
- p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
-
- /* Setup the initial rate of the resampler */
- p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
- }