00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <stdlib.h>
00028 #include <string.h>
00029
00030 #include <vlc/vlc.h>
00031 #include <vlc/input.h>
00032
00033 #ifdef HAVE_ALLOCA_H
00034 # include <alloca.h>
00035 #endif
00036
00037 #include "audio_output.h"
00038 #include "aout_internal.h"
00039
00040 static void inputFailure( aout_instance_t *, aout_input_t *, char * );
00041 static int VisualizationCallback( vlc_object_t *, char const *,
00042 vlc_value_t, vlc_value_t, void * );
00043 static int EqualizerCallback( vlc_object_t *, char const *,
00044 vlc_value_t, vlc_value_t, void * );
00045
00046
00047
00048
00049 int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
00050 {
00051 audio_sample_format_t chain_input_format;
00052 audio_sample_format_t chain_output_format;
00053 vlc_value_t val, text;
00054 char * psz_filters, *psz_visual;
00055 int i_visual;
00056
00057 aout_FormatPrint( p_aout, "input", &p_input->input );
00058
00059 p_input->i_nb_filters = 0;
00060
00061
00062 aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
00063 p_input->p_first_byte_to_mix = NULL;
00064
00065
00066 memcpy( &chain_input_format, &p_input->input,
00067 sizeof(audio_sample_format_t) );
00068 memcpy( &chain_output_format, &p_aout->mixer.mixer,
00069 sizeof(audio_sample_format_t) );
00070 chain_output_format.i_rate = p_input->input.i_rate;
00071 aout_FormatPrepare( &chain_output_format );
00072
00073
00074 if( var_Type( p_aout, "visual" ) == 0 )
00075 {
00076 module_t *p_module;
00077 var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
00078 text.psz_string = _("Visualizations");
00079 var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL );
00080 val.psz_string = ""; text.psz_string = _("Disable");
00081 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
00082 val.psz_string = "spectrometer"; text.psz_string = _("Spectrometer");
00083 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
00084 val.psz_string = "scope"; text.psz_string = _("Scope");
00085 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
00086 val.psz_string = "spectrum"; text.psz_string = _("Spectrum");
00087 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
00088
00089
00090 p_module = config_FindModule( VLC_OBJECT(p_aout), "goom" );
00091 if( p_module )
00092 {
00093 val.psz_string = "goom"; text.psz_string = "Goom";
00094 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
00095 }
00096
00097
00098 p_module = config_FindModule( VLC_OBJECT(p_aout), "galaktos" );
00099 if( p_module )
00100 {
00101 val.psz_string = "galaktos"; text.psz_string = "GaLaktos";
00102 var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
00103 }
00104
00105 if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )
00106 {
00107 var_Set( p_aout, "visual", val );
00108 if( val.psz_string ) free( val.psz_string );
00109 }
00110 var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );
00111 }
00112
00113 if( var_Type( p_aout, "equalizer" ) == 0 )
00114 {
00115 module_config_t *p_config;
00116 int i;
00117
00118 p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );
00119 if( p_config && p_config->i_list )
00120 {
00121 var_Create( p_aout, "equalizer",
00122 VLC_VAR_STRING | VLC_VAR_HASCHOICE );
00123 text.psz_string = _("Equalizer");
00124 var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );
00125
00126 val.psz_string = ""; text.psz_string = _("Disable");
00127 var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );
00128
00129 for( i = 0; i < p_config->i_list; i++ )
00130 {
00131 val.psz_string = p_config->ppsz_list[i];
00132 text.psz_string = p_config->ppsz_list_text[i];
00133 var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
00134 &val, &text );
00135 }
00136
00137 var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
00138 }
00139 }
00140
00141 if( var_Type( p_aout, "audio-filter" ) == 0 )
00142 {
00143 var_Create( p_aout, "audio-filter",
00144 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
00145 text.psz_string = _("Audio filters");
00146 var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );
00147 }
00148 if( var_Type( p_aout, "audio-visual" ) == 0 )
00149 {
00150 var_Create( p_aout, "audio-visual",
00151 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
00152 text.psz_string = _("Audio visualizations");
00153 var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL );
00154 }
00155
00156 var_Get( p_aout, "audio-filter", &val );
00157 psz_filters = val.psz_string;
00158 var_Get( p_aout, "audio-visual", &val );
00159 psz_visual = val.psz_string;
00160
00161
00162 for( i_visual = 0; i_visual < 2; i_visual++ )
00163 {
00164 char *psz_next = NULL;
00165 char *psz_parser = i_visual ? psz_visual : psz_filters;
00166
00167 if( psz_parser == NULL || !*psz_parser )
00168 continue;
00169
00170 while( psz_parser && *psz_parser )
00171 {
00172 aout_filter_t * p_filter = NULL;
00173
00174 if( p_input->i_nb_filters >= AOUT_MAX_FILTERS )
00175 {
00176 msg_Dbg( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS );
00177 break;
00178 }
00179
00180 while( *psz_parser == ' ' && *psz_parser == ':' )
00181 {
00182 psz_parser++;
00183 }
00184 if( ( psz_next = strchr( psz_parser , ':' ) ) )
00185 {
00186 *psz_next++ = '\0';
00187 }
00188 if( *psz_parser =='\0' )
00189 {
00190 break;
00191 }
00192
00193
00194 p_filter = vlc_object_create( p_aout, sizeof(aout_filter_t) );
00195 if( p_filter == NULL )
00196 {
00197 msg_Err( p_aout, "cannot add user filter %s (skipped)",
00198 psz_parser );
00199 psz_parser = psz_next;
00200 continue;
00201 }
00202
00203 vlc_object_attach( p_filter , p_aout );
00204
00205
00206 if( i_visual == 1 )
00207 {
00208
00209 memcpy( &p_filter->input, &chain_output_format,
00210 sizeof(audio_sample_format_t) );
00211 memcpy( &p_filter->output, &chain_output_format,
00212 sizeof(audio_sample_format_t) );
00213
00214 p_filter->p_module = module_Need( p_filter, "visualization",
00215 psz_parser, VLC_TRUE );
00216 }
00217 else
00218 {
00219
00220 memcpy( &p_filter->input, &chain_input_format,
00221 sizeof(audio_sample_format_t) );
00222 memcpy( &p_filter->output, &chain_output_format,
00223 sizeof(audio_sample_format_t) );
00224
00225 p_filter->p_module = module_Need( p_filter, "audio filter",
00226 psz_parser, VLC_TRUE );
00227
00228 if ( p_filter->p_module == NULL )
00229 {
00230
00231 if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input,
00232 &chain_input_format )
00233 && AOUT_FMTS_IDENTICAL( &p_filter->output,
00234 &chain_output_format ) ) )
00235 {
00236 aout_FormatPrepare( &p_filter->input );
00237 aout_FormatPrepare( &p_filter->output );
00238 p_filter->p_module = module_Need( p_filter, "audio filter",
00239 psz_parser, VLC_TRUE );
00240 }
00241
00242 else
00243 {
00244 memcpy( &p_filter->input, &chain_output_format,
00245 sizeof(audio_sample_format_t) );
00246 memcpy( &p_filter->output, &chain_output_format,
00247 sizeof(audio_sample_format_t) );
00248 p_filter->p_module = module_Need( p_filter, "visualization",
00249 psz_parser, VLC_TRUE );
00250 }
00251 }
00252 }
00253
00254
00255 if ( p_filter->p_module == NULL )
00256 {
00257 msg_Err( p_aout, "cannot add user filter %s (skipped)",
00258 psz_parser );
00259
00260 vlc_object_detach( p_filter );
00261 vlc_object_destroy( p_filter );
00262
00263 psz_parser = psz_next;
00264 continue;
00265 }
00266
00267
00268 if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) )
00269 {
00270 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
00271 &p_input->i_nb_filters,
00272 &chain_input_format,
00273 &p_filter->input ) < 0 )
00274 {
00275 msg_Err( p_aout, "cannot add user filter %s (skipped)",
00276 psz_parser );
00277
00278 module_Unneed( p_filter, p_filter->p_module );
00279 vlc_object_detach( p_filter );
00280 vlc_object_destroy( p_filter );
00281
00282 psz_parser = psz_next;
00283 continue;
00284 }
00285 }
00286
00287
00288 p_filter->b_continuity = VLC_FALSE;
00289 p_input->pp_filters[p_input->i_nb_filters++] = p_filter;
00290 memcpy( &chain_input_format, &p_filter->output,
00291 sizeof( audio_sample_format_t ) );
00292
00293
00294 psz_parser = psz_next;
00295 }
00296 }
00297 if( psz_filters ) free( psz_filters );
00298 if( psz_visual ) free( psz_visual );
00299
00300
00301 if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) )
00302 {
00303 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
00304 &p_input->i_nb_filters,
00305 &chain_input_format,
00306 &chain_output_format ) < 0 )
00307 {
00308 inputFailure( p_aout, p_input, "couldn't set an input pipeline" );
00309 return -1;
00310 }
00311 }
00312
00313
00314 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
00315 p_input->input_alloc.i_bytes_per_sec = -1;
00316
00317
00318 if ( AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) )
00319 {
00320 p_input->i_nb_resamplers = 0;
00321 }
00322 else
00323 {
00324 chain_output_format.i_rate = (__MAX(p_input->input.i_rate,
00325 p_aout->mixer.mixer.i_rate)
00326 * (100 + AOUT_MAX_RESAMPLING)) / 100;
00327 if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate )
00328 {
00329
00330 chain_output_format.i_rate++;
00331 }
00332 p_input->i_nb_resamplers = 0;
00333 if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,
00334 &p_input->i_nb_resamplers,
00335 &chain_output_format,
00336 &p_aout->mixer.mixer ) < 0 )
00337 {
00338 inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");
00339 return -1;
00340 }
00341
00342 aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,
00343 p_input->i_nb_resamplers,
00344 &p_input->input_alloc );
00345 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
00346
00347
00348 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
00349 }
00350 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
00351
00352 aout_FiltersHintBuffers( p_aout, p_input->pp_filters,
00353 p_input->i_nb_filters,
00354 &p_input->input_alloc );
00355 p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
00356
00357
00358 p_input->input_alloc.i_bytes_per_sec = __MAX(
00359 p_input->input_alloc.i_bytes_per_sec,
00360 (int)(p_input->input.i_bytes_per_frame
00361 * p_input->input.i_rate
00362 / p_input->input.i_frame_length) );
00363
00364
00365 p_input->b_error = VLC_FALSE;
00366 p_input->b_restart = VLC_FALSE;
00367
00368 return 0;
00369 }
00370
00371
00372
00373
00374
00375
00376 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
00377 {
00378 if ( p_input->b_error ) return 0;
00379
00380 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
00381 p_input->i_nb_filters );
00382 p_input->i_nb_filters = 0;
00383 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
00384 p_input->i_nb_resamplers );
00385 p_input->i_nb_resamplers = 0;
00386 aout_FifoDestroy( p_aout, &p_input->fifo );
00387
00388 return 0;
00389 }
00390
00391
00392
00393
00394
00395
00396 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
00397 aout_buffer_t * p_buffer )
00398 {
00399 mtime_t start_date;
00400
00401 if( p_input->b_restart )
00402 {
00403 aout_fifo_t fifo, dummy_fifo;
00404 byte_t *p_first_byte_to_mix;
00405
00406 vlc_mutex_lock( &p_aout->mixer_lock );
00407
00408
00409 aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );
00410 p_first_byte_to_mix = p_input->p_first_byte_to_mix;
00411 fifo = p_input->fifo;
00412 p_input->fifo = dummy_fifo;
00413 aout_InputDelete( p_aout, p_input );
00414 aout_InputNew( p_aout, p_input );
00415 p_input->p_first_byte_to_mix = p_first_byte_to_mix;
00416 p_input->fifo = fifo;
00417
00418 vlc_mutex_unlock( &p_aout->mixer_lock );
00419 }
00420
00421
00422
00423
00424 vlc_mutex_lock( &p_aout->input_fifos_lock );
00425 start_date = aout_FifoNextStart( p_aout, &p_input->fifo );
00426 vlc_mutex_unlock( &p_aout->input_fifos_lock );
00427
00428 if ( start_date != 0 && start_date < mdate() )
00429 {
00430
00431
00432
00433 msg_Warn( p_aout, "computed PTS is out of range ("I64Fd"), "
00434 "clearing out", mdate() - start_date );
00435 vlc_mutex_lock( &p_aout->input_fifos_lock );
00436 aout_FifoSet( p_aout, &p_input->fifo, 0 );
00437 p_input->p_first_byte_to_mix = NULL;
00438 vlc_mutex_unlock( &p_aout->input_fifos_lock );
00439 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
00440 msg_Warn( p_aout, "timing screwed, stopping resampling" );
00441 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
00442 if ( p_input->i_nb_resamplers != 0 )
00443 {
00444 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
00445 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
00446 }
00447 start_date = 0;
00448 }
00449
00450 if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
00451 {
00452
00453
00454 msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
00455 mdate() - p_buffer->start_date );
00456 aout_BufferFree( p_buffer );
00457 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
00458 if ( p_input->i_nb_resamplers != 0 )
00459 {
00460 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
00461 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
00462 }
00463 return 0;
00464 }
00465
00466
00467
00468 if ( start_date != 0 &&
00469 ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) )
00470 {
00471 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), clearing out",
00472 start_date - p_buffer->start_date );
00473 vlc_mutex_lock( &p_aout->input_fifos_lock );
00474 aout_FifoSet( p_aout, &p_input->fifo, 0 );
00475 p_input->p_first_byte_to_mix = NULL;
00476 vlc_mutex_unlock( &p_aout->input_fifos_lock );
00477 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
00478 msg_Warn( p_aout, "timing screwed, stopping resampling" );
00479 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
00480 if ( p_input->i_nb_resamplers != 0 )
00481 {
00482 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
00483 p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
00484 }
00485 start_date = 0;
00486 }
00487 else if ( start_date != 0 &&
00488 ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) )
00489 {
00490 msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
00491 start_date - p_buffer->start_date );
00492 aout_BufferFree( p_buffer );
00493 return 0;
00494 }
00495
00496 if ( start_date == 0 ) start_date = p_buffer->start_date;
00497
00498
00499
00500 aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,
00501 &p_buffer );
00502
00503
00504
00505 if ( ( p_input->i_resampling_type == AOUT_RESAMPLING_NONE ) &&
00506 ( start_date < p_buffer->start_date - AOUT_PTS_TOLERANCE
00507 || start_date > p_buffer->start_date + AOUT_PTS_TOLERANCE ) &&
00508 p_input->i_nb_resamplers > 0 )
00509 {
00510
00511
00512
00513
00514
00515
00516
00517 mtime_t drift = p_buffer->start_date - start_date;
00518
00519 p_input->i_resamp_start_date = mdate();
00520 p_input->i_resamp_start_drift = (int)drift;
00521
00522 if ( drift > 0 )
00523 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
00524 else
00525 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
00526
00527 msg_Warn( p_aout, "buffer is "I64Fd" %s, triggering %ssampling",
00528 drift > 0 ? drift : -drift,
00529 drift > 0 ? "in advance" : "late",
00530 drift > 0 ? "down" : "up");
00531 }
00532
00533 if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
00534 {
00535
00536
00537
00538
00539 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
00540 {
00541 p_input->pp_resamplers[0]->input.i_rate += 2;
00542 }
00543 else
00544 {
00545 p_input->pp_resamplers[0]->input.i_rate -= 2;
00546 }
00547
00548
00549
00550 if( p_input->pp_resamplers[0]->input.i_rate ==
00551 p_input->input.i_rate )
00552 {
00553 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
00554 msg_Warn( p_aout, "resampling stopped after "I64Fi" usec "
00555 "(drift: "I64Fi")",
00556 mdate() - p_input->i_resamp_start_date,
00557 p_buffer->start_date - start_date);
00558 }
00559 else if( abs( (int)(p_buffer->start_date - start_date) ) <
00560 abs( p_input->i_resamp_start_drift ) / 2 )
00561 {
00562
00563
00564 if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
00565 p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
00566 else
00567 p_input->i_resampling_type = AOUT_RESAMPLING_UP;
00568 p_input->i_resamp_start_drift = 0;
00569 }
00570 else if( p_input->i_resamp_start_drift &&
00571 ( abs( (int)(p_buffer->start_date - start_date) ) >
00572 abs( p_input->i_resamp_start_drift ) * 3 / 2 ) )
00573 {
00574
00575
00576 msg_Warn( p_aout, "timing screwed, stopping resampling" );
00577 p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
00578 p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
00579 }
00580 }
00581
00582
00583 p_buffer->end_date = start_date +
00584 (p_buffer->end_date - p_buffer->start_date);
00585 p_buffer->start_date = start_date;
00586
00587
00588 if ( p_input->i_nb_resamplers > 0 )
00589 {
00590 aout_FiltersPlay( p_aout, p_input->pp_resamplers,
00591 p_input->i_nb_resamplers,
00592 &p_buffer );
00593 }
00594
00595 vlc_mutex_lock( &p_aout->input_fifos_lock );
00596 aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
00597 vlc_mutex_unlock( &p_aout->input_fifos_lock );
00598
00599 return 0;
00600 }
00601
00602
00603
00604
00605
00606 static void inputFailure( aout_instance_t * p_aout, aout_input_t * p_input,
00607 char * psz_error_message )
00608 {
00609
00610 msg_Err( p_aout, "couldn't set an input pipeline" );
00611
00612
00613 aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
00614 p_input->i_nb_filters );
00615 aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
00616 p_input->i_nb_resamplers );
00617 aout_FifoDestroy( p_aout, &p_input->fifo );
00618 var_Destroy( p_aout, "visual" );
00619 var_Destroy( p_aout, "equalizer" );
00620 var_Destroy( p_aout, "audio-filter" );
00621 var_Destroy( p_aout, "audio-visual" );
00622
00623
00624 p_input->b_error = 1;
00625 }
00626
00627 static int ChangeFiltersString( aout_instance_t * p_aout, char* psz_variable,
00628 char *psz_name, vlc_bool_t b_add )
00629 {
00630 vlc_value_t val;
00631 char *psz_parser;
00632
00633 var_Get( p_aout, psz_variable, &val );
00634
00635 if( !val.psz_string ) val.psz_string = strdup("");
00636
00637 psz_parser = strstr( val.psz_string, psz_name );
00638
00639 if( b_add )
00640 {
00641 if( !psz_parser )
00642 {
00643 psz_parser = val.psz_string;
00644 asprintf( &val.psz_string, (*val.psz_string) ? "%s:%s" : "%s%s",
00645 val.psz_string, psz_name );
00646 free( psz_parser );
00647 }
00648 else
00649 {
00650 return 0;
00651 }
00652 }
00653 else
00654 {
00655 if( psz_parser )
00656 {
00657 memmove( psz_parser, psz_parser + strlen(psz_name) +
00658 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
00659 strlen(psz_parser + strlen(psz_name)) + 1 );
00660 }
00661 else
00662 {
00663 free( val.psz_string );
00664 return 0;
00665 }
00666 }
00667
00668 var_Set( p_aout, psz_variable, val );
00669 free( val.psz_string );
00670 return 1;
00671 }
00672
00673 static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
00674 vlc_value_t oldval, vlc_value_t newval, void *p_data )
00675 {
00676 aout_instance_t *p_aout = (aout_instance_t *)p_this;
00677 char *psz_mode = newval.psz_string;
00678 vlc_value_t val;
00679 int i;
00680
00681 if( !psz_mode || !*psz_mode )
00682 {
00683 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
00684 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
00685 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE );
00686 }
00687 else
00688 {
00689 if( !strcmp( "goom", psz_mode ) )
00690 {
00691 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
00692 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_TRUE );
00693 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
00694 }
00695 else if( !strcmp( "galaktos", psz_mode ) )
00696 {
00697 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
00698 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
00699 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_TRUE );
00700 }
00701 else
00702 {
00703 val.psz_string = psz_mode;
00704 var_Create( p_aout, "effect-list", VLC_VAR_STRING );
00705 var_Set( p_aout, "effect-list", val );
00706
00707 ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
00708 ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_TRUE );
00709 ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
00710 }
00711 }
00712
00713
00714 for( i = 0; i < p_aout->i_nb_inputs; i++ )
00715 {
00716 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
00717 }
00718
00719 return VLC_SUCCESS;
00720 }
00721
00722 static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd,
00723 vlc_value_t oldval, vlc_value_t newval, void *p_data )
00724 {
00725 aout_instance_t *p_aout = (aout_instance_t *)p_this;
00726 char *psz_mode = newval.psz_string;
00727 vlc_value_t val;
00728 int i;
00729 int i_ret;
00730
00731 if( !psz_mode || !*psz_mode )
00732 {
00733 i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
00734 VLC_FALSE );
00735 }
00736 else
00737 {
00738 val.psz_string = psz_mode;
00739 var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING );
00740 var_Set( p_aout, "equalizer-preset", val );
00741 i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
00742 VLC_TRUE );
00743
00744 }
00745
00746
00747 if( i_ret == 1 )
00748 {
00749 for( i = 0; i < p_aout->i_nb_inputs; i++ )
00750 {
00751 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
00752 }
00753 }
00754
00755 return VLC_SUCCESS;
00756 }