]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/equalizer.m
macosx: added missing pl locks
[vlc] / modules / gui / macosx / equalizer.m
index e3dae3be0650e0fe57df30e689eba36194e1cc88..b198f7d637cd26bfe53d1cae48e48974cd540aa7 100644 (file)
@@ -29,7 +29,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_aout.h>
 
 #include "intf.h"
 @implementation VLCEqualizer
 
 static void ChangeFiltersString( intf_thread_t *p_intf,
-                                 char *psz_name, vlc_bool_t b_add )
+                                 char *psz_name, bool b_add )
 {
     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;
-    if( p_object == NULL )
-        p_object = vlc_object_find( p_intf,
-                                 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    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" );
 
@@ -75,6 +74,7 @@ static void ChangeFiltersString( intf_thread_t *p_intf,
         }
         else
         {
+            vlc_object_release( p_object );
             return;
         }
     }
@@ -93,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;
          }
     }
 
@@ -103,7 +104,7 @@ static void ChangeFiltersString( intf_thread_t *p_intf,
     {
         for( i = 0; i < p_aout->i_nb_inputs; i++ )
         {
-            p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
+            p_aout->pp_inputs[i]->b_restart = true;
         }
     }
     
@@ -111,26 +112,20 @@ 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 );
     vlc_object_release( p_object );
 }
 
-static vlc_bool_t GetFiltersStatus( intf_thread_t *p_intf,
+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 );
     if( p_object == NULL )
-        p_object = vlc_object_find( p_intf,
-                                 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_object == NULL )
-        return VLC_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" );
@@ -140,16 +135,16 @@ static vlc_bool_t GetFiltersStatus( intf_thread_t *p_intf,
 
     vlc_object_release( p_object );
 
-    if( !psz_string ) return VLC_FALSE;
+    if( !psz_string ) return false;
 
     psz_parser = strstr( psz_string, psz_name );
 
     free( psz_string );
 
     if ( psz_parser )
-        return VLC_TRUE;
+        return true;
     else
-        return VLC_FALSE;
+        return false;
 }
 
 - (void)initStrings
@@ -179,17 +174,14 @@ static vlc_bool_t GetFiltersStatus( intf_thread_t *p_intf,
     intf_thread_t *p_intf = VLCIntf;
     float f_preamp, f_band[10];
     char *psz_bands, *psz_bands_init, *p_next;
-    vlc_bool_t b_2p;
+    bool b_2p;
     int i;
-    vlc_bool_t b_enabled = GetFiltersStatus( p_intf, (char *)"equalizer" );
+    bool b_enabled = GetFiltersStatus( p_intf, (char *)"equalizer" );
     vlc_object_t *p_object = vlc_object_find( p_intf,
                                               VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
     if( p_object == NULL )
-        p_object = vlc_object_find( p_intf,
-                                    VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    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 );
@@ -249,10 +241,7 @@ static vlc_bool_t GetFiltersStatus( intf_thread_t *p_intf,
                                               VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
     if( p_object == NULL )
-        p_object = vlc_object_find( p_intf,
-                                    VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_object == NULL )
-        return;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     char psz_values[102];
     memset( psz_values, 0, 102 );
@@ -292,10 +281,7 @@ static vlc_bool_t 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 = vlc_object_find( p_intf,
-                                    VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_object == NULL )
-        return;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     char psz_values[102];
     memset( psz_values, 0, 102 );
@@ -338,10 +324,7 @@ static vlc_bool_t 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 = vlc_object_find( p_intf,
-                                    VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_object == NULL )
-        return;
+        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
     var_SetFloat( p_object, "equalizer-preamp", f_preamp );
 
@@ -374,15 +357,12 @@ static vlc_bool_t GetFiltersStatus( intf_thread_t *p_intf,
 - (IBAction)twopass:(id)sender
 {
     intf_thread_t *p_intf = VLCIntf;
-    vlc_bool_t b_2p = [sender state] ? VLC_TRUE : VLC_FALSE;
+    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;
     if( p_object == NULL )
-        p_object = vlc_object_find( p_intf,
-                                    VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    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 ) )
@@ -390,7 +370,7 @@ static vlc_bool_t GetFiltersStatus( intf_thread_t *p_intf,
         int i;
         for( i = 0; i < p_aout->i_nb_inputs; i++ )
         {
-            p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
+            p_aout->pp_inputs[i]->b_restart = true;
         }
     }
 
@@ -417,8 +397,7 @@ static vlc_bool_t 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 = vlc_object_find( VLCIntf,
-                                    VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+        p_object = (vlc_object_t *)pl_Hold( VLCIntf );
 
     [o_window setExcludedFromWindowsMenu: TRUE];