]> git.sesse.net Git - vlc/blobdiff - src/audio_output/input.c
Improvements to preferences
[vlc] / src / audio_output / input.c
index f6a48def42bcf964e499623e36bef298ca1c027f..59c653cc001a9bb9340575702f9226d256d507e7 100644 (file)
@@ -53,7 +53,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
     audio_sample_format_t user_filter_format;
     audio_sample_format_t intermediate_format;/* input of resampler */
     vlc_value_t val, text;
-    char * psz_filters;
+    char * psz_filters, *psz_visual;
     aout_filter_t * p_user_channel_mixer;
 
     aout_FormatPrint( p_aout, "input", &p_input->input );
@@ -141,29 +141,29 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
     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 = ""; 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 = p_config->ppsz_list[i];
-               text.psz_string = p_config->ppsz_list_text[i];
-               var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
-                           &val, &text );
-           }
-
-           var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
-       }
+        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 = ""; 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 = p_config->ppsz_list[i];
+                text.psz_string = 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 )
@@ -173,14 +173,35 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
         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 );
+    }
 
     var_Get( p_aout, "audio-filter", &val );
     psz_filters = val.psz_string;
+    var_Get( p_aout, "audio-visual", &val );
+    psz_visual = val.psz_string;
+
+    if( psz_filters && *psz_filters && psz_visual && *psz_visual )
+    {
+        psz_filters = (char *)realloc( psz_filters, strlen( psz_filters ) +
+                                                    strlen( psz_visual )  + 1);
+        sprintf( psz_filters, "%s,%s", psz_filters, psz_visual );
+    }
+    else if(  psz_visual && *psz_visual )
+    {
+        if( psz_filters ) free( psz_filters );
+        psz_filters = strdup( psz_visual );
+    }
+
     if( psz_filters && *psz_filters )
     {
         char *psz_parser = psz_filters;
         char *psz_next;
-
         while( psz_parser && *psz_parser )
         {
             aout_filter_t * p_filter;
@@ -227,14 +248,19 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
 
             if( p_filter->p_module== NULL )
             {
-                msg_Err( p_aout, "cannot add user filter %s (skipped)",
-                         psz_parser );
-
-                vlc_object_detach( p_filter );
-                vlc_object_destroy( p_filter );
-                psz_parser = psz_next;
-                continue;
-
+                p_filter->p_module =
+                    module_Need( p_filter,"visualization", psz_parser,
+                                                           VLC_TRUE );
+                if( p_filter->p_module == NULL )
+                {
+                    msg_Err( p_aout, "cannot add user filter %s (skipped)",
+                             psz_parser );
+
+                    vlc_object_detach( p_filter );
+                    vlc_object_destroy( p_filter );
+                    psz_parser = psz_next;
+                    continue;
+                }
             }
             p_filter->b_continuity = VLC_FALSE;
 
@@ -245,6 +271,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
         }
     }
     if( psz_filters ) free( psz_filters );
+    if( psz_visual ) free( psz_visual );
 
     /* Attach the user channel mixer */
     if ( p_user_channel_mixer )