]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/equalizer.m
macosx: merge Eric Dudiak's code from GSoC 2008
[vlc] / modules / gui / macosx / equalizer.m
index 02f1ba71902e9399987748adf4b98e6be0f8cc32..367ff0b477a29eb60dec7fb927c471baf6f37b79 100644 (file)
@@ -52,10 +52,10 @@ static void ChangeFiltersString( intf_thread_t *p_intf,
     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;
-    if( p_object == NULL )
-        p_object = pl_Yield( p_intf );
-    if( p_object == NULL )
-        return;
+    if( !p_object )
+    {
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
+    }
 
     psz_string = var_GetNonEmptyString( p_object, "audio-filter" );
 
@@ -74,6 +74,7 @@ static void ChangeFiltersString( intf_thread_t *p_intf,
         }
         else
         {
+            vlc_object_release( p_object );
             return;
         }
     }
@@ -92,8 +93,9 @@ static void ChangeFiltersString( intf_thread_t *p_intf,
          }
          else
          {
-             free( psz_string );
-             return;
+            free( psz_string );
+            vlc_object_release( p_object );
+            return;
          }
     }
 
@@ -110,9 +112,6 @@ static void ChangeFiltersString( intf_thread_t *p_intf,
     {
         /* save changed to config */
         config_PutPsz( p_object, "audio-filter", psz_string );
-
-        /* save to vlcrc */
-        config_SaveConfigFile( p_object, "main" );
     }
     
     free( psz_string );
@@ -126,9 +125,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     vlc_object_t *p_object = vlc_object_find( p_intf,
                                 VLC_OBJECT_AOUT, FIND_ANYWHERE );
     if( p_object == NULL )
-        p_object = pl_Yield( p_intf );
-    if( p_object == NULL )
-        return false;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES )
         psz_string = config_GetPsz( p_intf, "audio-filter" );
@@ -154,6 +151,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
 {
     int i;
     [o_btn_equalizer setToolTip: _NS("Equalizer")];
+    [o_btn_equalizer_embedded setToolTip: _NS("Equalizer")];
     [o_ckb_2pass setTitle: _NS("2 Pass")];
     [o_ckb_2pass setToolTip: _NS("Apply the "
         "equalizer filter twice. The effect will be sharper.")];
@@ -184,9 +182,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
                                               VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
     if( p_object == NULL )
-        p_object = pl_Yield( p_intf );
-    if( p_object == NULL )
-        return;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
                 VLC_VAR_DOINHERIT );
@@ -220,11 +216,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     for( i = 0; i < 10; i++ )
     {
         /* Read dB -20/20 */
-#ifdef HAVE_STRTOF
         f_band[i] = strtof( psz_bands, &p_next );
-#else
-        f_band[i] = (float)strtod( psz_bands, &p_next );
-#endif
         if( !p_next || p_next == psz_bands ) break; /* strtof() failed */
     
         if( !*psz_bands ) break; /* end of line */
@@ -246,9 +238,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
                                               VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
     if( p_object == NULL )
-        p_object = pl_Yield( p_intf );
-    if( p_object == NULL )
-        return;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     char psz_values[102];
     memset( psz_values, 0, 102 );
@@ -288,9 +278,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     vlc_object_t *p_object= vlc_object_find( p_intf,
                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
     if( p_object == NULL )
-        p_object = pl_Yield( p_intf );
-    if( p_object == NULL )
-        return;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     char psz_values[102];
     memset( psz_values, 0, 102 );
@@ -333,9 +321,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     vlc_object_t *p_object = vlc_object_find( p_intf,
                                               VLC_OBJECT_AOUT, FIND_ANYWHERE );
     if( p_object == NULL )
-        p_object = pl_Yield( p_intf );
-    if( p_object == NULL )
-        return;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     var_SetFloat( p_object, "equalizer-preamp", f_preamp );
 
@@ -357,11 +343,13 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     {
         [o_window orderOut:sender];
         [o_btn_equalizer setState:NSOffState];
+        [o_btn_equalizer_embedded setState:NSOffState];
     }
     else
     {
         [o_window makeKeyAndOrderFront:sender];
         [o_btn_equalizer setState:NSOnState];
+        [o_btn_equalizer_embedded setState:NSOnState];
     }
 }
 
@@ -373,9 +361,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
     aout_instance_t *p_aout = (aout_instance_t *)p_object;
     if( p_object == NULL )
-        p_object = pl_Yield( p_intf );
-    if( p_object == NULL )
-        return;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     var_SetBool( p_object, "equalizer-2pass", b_2p );
     if( ( [o_ckb_enable state] ) && ( p_aout != NULL ) )
@@ -410,7 +396,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
     vlc_object_t *p_object= vlc_object_find( VLCIntf,
                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
     if( p_object == NULL )
-        p_object = pl_Yield( VLCIntf );
+        p_object = (vlc_object_t *)pl_Hold( VLCIntf );
 
     [o_window setExcludedFromWindowsMenu: TRUE];
 
@@ -470,7 +456,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
 }
 
 
-- (id)getSliderByIndex:(int)index
+- (id)sliderByIndex:(int)index
 {
     switch(index)
     {
@@ -508,7 +494,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf,
 
 - (void)setValue:(float)value forSlider:(int)index
 {
-    id slider = [self getSliderByIndex:index];
+    id slider = [self sliderByIndex:index];
 
     if (slider != nil)
     {