]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/equalizer.m
legacy OS X intf: removed unfinished VLM interface
[vlc] / modules / gui / macosx / equalizer.m
index 367ff0b477a29eb60dec7fb927c471baf6f37b79..55ef7386f00526ee9acc3e00d24c579f4fb256ee 100644 (file)
@@ -49,12 +49,11 @@ static void ChangeFiltersString( intf_thread_t *p_intf,
 {
     char *psz_parser, *psz_string;
     int i;
-    vlc_object_t *p_object = vlc_object_find( p_intf,
-                                VLC_OBJECT_AOUT, FIND_ANYWHERE );
-    aout_instance_t *p_aout = (aout_instance_t *)p_object;
+    aout_instance_t *p_aout = getAout();
+    vlc_object_t *p_object = VLC_OBJECT(p_aout);
     if( !p_object )
     {
-        p_object = (vlc_object_t *)pl_Hold( p_intf );
+        p_object = vlc_object_hold(pl_Get( p_intf ));
     }
 
     psz_string = var_GetNonEmptyString( p_object, "audio-filter" );
@@ -99,21 +98,14 @@ static void ChangeFiltersString( intf_thread_t *p_intf,
          }
     }
 
-    var_SetString( p_object, "audio-filter", psz_string );
-    if( p_aout )
-    {
-        for( i = 0; i < p_aout->i_nb_inputs; i++ )
-        {
-            p_aout->pp_inputs[i]->b_restart = true;
-        }
-    }
-    
+    aout_EnableFilter( p_object, psz_string, false);
+
     if( (BOOL)config_GetInt( p_object, "macosx-eq-keep" ) == YES )
     {
         /* save changed to config */
         config_PutPsz( p_object, "audio-filter", psz_string );
     }
-    
+
     free( psz_string );
     vlc_object_release( p_object );
 }
@@ -122,10 +114,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
                                  char *psz_name )
 {
     char *psz_parser, *psz_string;
-    vlc_object_t *p_object = vlc_object_find( p_intf,
-                                VLC_OBJECT_AOUT, FIND_ANYWHERE );
+    vlc_object_t *p_object = VLC_OBJECT(getAout());
     if( p_object == NULL )
-        p_object = (vlc_object_t *)pl_Hold( p_intf );
+        p_object = vlc_object_hold(pl_Get( p_intf ));
 
     if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES )
         psz_string = config_GetPsz( p_intf, "audio-filter" );
@@ -178,11 +169,10 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     bool b_2p;
     int i;
     bool b_enabled = GetFiltersStatus( p_intf, (char *)"equalizer" );
-    vlc_object_t *p_object = vlc_object_find( p_intf,
-                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
+    vlc_object_t *p_object = VLC_OBJECT(getAout());
 
     if( p_object == NULL )
-        p_object = (vlc_object_t *)pl_Hold( p_intf );
+        p_object = vlc_object_hold(pl_Get( p_intf ));
 
     var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
                 VLC_VAR_DOINHERIT );
@@ -206,7 +196,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     }
 
     vlc_object_release( p_object );
-    
+
     /* Set the preamp slider */
     [o_slider_preamp setFloatValue: f_preamp];
 
@@ -218,7 +208,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
         /* Read dB -20/20 */
         f_band[i] = strtof( psz_bands, &p_next );
         if( !p_next || p_next == psz_bands ) break; /* strtof() failed */
-    
+
         if( !*psz_bands ) break; /* end of line */
         psz_bands = p_next+1;
     }
@@ -228,35 +218,30 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     /* Set the the checkboxes */
     [o_ckb_enable setState: b_enabled];
 
-    [o_ckb_2pass setState: b_2p];        
+    [o_ckb_2pass setState: b_2p];
 }
 
 - (IBAction)bandSliderUpdated:(id)sender
 {
     intf_thread_t *p_intf = VLCIntf;
-    vlc_object_t *p_object = vlc_object_find( p_intf,
-                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
+    vlc_object_t *p_object = VLC_OBJECT(getAout());
 
     if( p_object == NULL )
-        p_object = (vlc_object_t *)pl_Hold( p_intf );
-
-    char psz_values[102];
-    memset( psz_values, 0, 102 );
-
-    /* Write the new bands values */
-    /* TODO: write a generic code instead of ten times the same thing */
-
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band1 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band2 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band3 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band4 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band5 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band6 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band7 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band8 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band9 floatValue] );
-    sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band10 floatValue] );
-
+        p_object = vlc_object_hold(pl_Get( p_intf ));
+
+    const char *psz_values;
+    NSString *preset = [NSString stringWithFormat:@"%.1f", [o_slider_band1 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band2 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band3 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band4 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band5 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band6 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band7 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band8 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band9 floatValue] ];
+    preset = [preset stringByAppendingFormat:@"%.1f", [o_slider_band10 floatValue] ];
+
+    psz_values = [preset UTF8String];
     var_SetString( p_object, "equalizer-bands", psz_values );
 
     if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES )
@@ -275,18 +260,19 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
 {
     intf_thread_t *p_intf = VLCIntf;
     int i;
-    vlc_object_t *p_object= vlc_object_find( p_intf,
-                                             VLC_OBJECT_AOUT, FIND_ANYWHERE );
+    vlc_object_t *p_object= VLC_OBJECT(getAout());
     if( p_object == NULL )
-        p_object = (vlc_object_t *)pl_Hold( p_intf );
-
-    char psz_values[102];
-    memset( psz_values, 0, 102 );
+        p_object = vlc_object_hold(pl_Get( p_intf ));
 
     var_SetString( p_object , "equalizer-preset" , preset_list[[sender indexOfSelectedItem]] );
 
+    NSString *preset = @"";
+    const char *psz_values;
     for( i = 0; i < 10; i++ )
-        sprintf( psz_values, "%s %.1f", psz_values, eqz_preset_10b[[sender indexOfSelectedItem]]->f_amp[i] );
+    {
+        preset = [preset stringByAppendingFormat:@"%.1f ", eqz_preset_10b[[sender indexOfSelectedItem]]->f_amp[i] ];
+    }
+    psz_values = [preset UTF8String];
     var_SetString( p_object, "equalizer-bands", psz_values );
     var_SetFloat( p_object, "equalizer-preamp", eqz_preset_10b[[sender indexOfSelectedItem]]->f_preamp);
 
@@ -318,10 +304,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     intf_thread_t *p_intf = VLCIntf;
     float f_preamp = [sender floatValue] ;
 
-    vlc_object_t *p_object = vlc_object_find( p_intf,
-                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
+    vlc_object_t *p_object = VLC_OBJECT(getAout());
     if( p_object == NULL )
-        p_object = (vlc_object_t *)pl_Hold( p_intf );
+        p_object = vlc_object_hold(pl_Get( p_intf ));
 
     var_SetFloat( p_object, "equalizer-preamp", f_preamp );
 
@@ -357,21 +342,12 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
 {
     intf_thread_t *p_intf = VLCIntf;
     bool b_2p = [sender state] ? true : false;
-    vlc_object_t *p_object= vlc_object_find( p_intf,
-                                             VLC_OBJECT_AOUT, FIND_ANYWHERE );
-    aout_instance_t *p_aout = (aout_instance_t *)p_object;
+    aout_instance_t *p_aout = getAout();
+    vlc_object_t *p_object= VLC_OBJECT(p_aout);
     if( p_object == NULL )
-        p_object = (vlc_object_t *)pl_Hold( p_intf );
+        p_object = vlc_object_hold(pl_Get( p_intf ));
 
     var_SetBool( p_object, "equalizer-2pass", b_2p );
-    if( ( [o_ckb_enable state] ) && ( p_aout != NULL ) )
-    {
-        int i;
-        for( i = 0; i < p_aout->i_nb_inputs; i++ )
-        {
-            p_aout->pp_inputs[i]->b_restart = true;
-        }
-    }
 
     if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES )
     {
@@ -393,10 +369,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
 - (void)awakeFromNib
 {
     int i;
-    vlc_object_t *p_object= vlc_object_find( VLCIntf,
-                                             VLC_OBJECT_AOUT, FIND_ANYWHERE );
+    vlc_object_t *p_object= VLC_OBJECT(getAout());
     if( p_object == NULL )
-        p_object = (vlc_object_t *)pl_Hold( VLCIntf );
+        p_object = vlc_object_hold(pl_Get( VLCIntf ));
 
     [o_window setExcludedFromWindowsMenu: TRUE];
 
@@ -414,9 +389,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
         {
             if( strcmp( preset_list[i], psz_preset ) )
                 continue;
-    
+
             [o_popup_presets selectItemAtIndex: i];
-        
+
 
             [o_slider_preamp setFloatValue: eqz_preset_10b[i]->f_preamp];
             [self setBandSlidersValues: (float *)eqz_preset_10b[i]->f_amp];
@@ -424,7 +399,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
             if( strcmp( psz_preset, "flat" ) )
             {
                 char psz_bands[100];
-    
+
                 snprintf( psz_bands, sizeof( psz_bands ),
                           "%.1f %.1f %.1f %.1f %.1f %.1f %.1f "
                           "%.1f %.1f %.1f",
@@ -438,7 +413,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
                           eqz_preset_10b[i]->f_amp[7],
                           eqz_preset_10b[i]->f_amp[8],
                           eqz_preset_10b[i]->f_amp[9] );
-    
+
                 var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
                             VLC_VAR_DOINHERIT );
                 var_Create( p_object, "equalizer-bands", VLC_VAR_STRING |
@@ -452,7 +427,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
         vlc_object_release( p_object );
     }
 
-    [self equalizerUpdated];    
+    [self equalizerUpdated];
 }