]> git.sesse.net Git - vlc/blobdiff - src/misc/variables.c
aout_BufferAlloc : returns the allocated buffer
[vlc] / src / misc / variables.c
index 74e99f89c7385888d975be50e05901a9d5aaa531..1134326984892e023bff96ff6c5c141456bd117d 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "libvlc.h"
 
-#include "vlc_interface.h"
 #include <assert.h>
 
 /*****************************************************************************
@@ -182,6 +181,9 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
     int i_new;
     variable_t *p_var;
     static vlc_list_t dummy_null_list = {0, NULL, NULL};
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -195,7 +197,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
     if( i_new >= 0 )
     {
         /* If the types differ, variable creation failed. */
-        if( (i_type & VLC_VAR_TYPE) != (p_priv->p_vars[i_new].i_type & VLC_VAR_TYPE) )
+        if( (i_type & VLC_VAR_CLASS) != (p_priv->p_vars[i_new].i_type & VLC_VAR_CLASS) )
         {
             msg_Err( p_this, "Variable '%s' (0x%04x) already exist but with a different type (0x%04x)",
                      psz_name, p_priv->p_vars[i_new].i_type, i_type );
@@ -336,6 +338,9 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
 {
     int i_var, i;
     variable_t *p_var;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -372,10 +377,7 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
     }
 
     /* Free callbacks if needed */
-    if( p_var->p_entries )
-    {
-        free( p_var->p_entries );
-    }
+    free( p_var->p_entries );
 
     free( p_var->psz_name );
     free( p_var->psz_text );
@@ -412,6 +414,9 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
     int i_var, i;
     variable_t *p_var;
     vlc_value_t oldval;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -681,6 +686,9 @@ int __var_GetAndSet( vlc_object_t *p_this, const char *psz_name, int i_action,
     int i_ret = VLC_SUCCESS;
     variable_t *p_var;
     vlc_value_t oldval;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -738,6 +746,9 @@ int __var_GetAndSet( vlc_object_t *p_this, const char *psz_name, int i_action,
 int __var_Type( vlc_object_t *p_this, const char *psz_name )
 {
     int i_var, i_type;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -764,6 +775,9 @@ int var_SetChecked( vlc_object_t *p_this, const char *psz_name,
     int i_ret = VLC_SUCCESS;
     variable_t *p_var;
     vlc_value_t oldval;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -776,7 +790,7 @@ int var_SetChecked( vlc_object_t *p_this, const char *psz_name,
     }
 
     p_var = &p_priv->p_vars[i_var];
-    assert( (p_var->i_type & VLC_VAR_CLASS) == 0 || expected_type == 0 ||
+    assert( expected_type == 0 ||
             (p_var->i_type & VLC_VAR_CLASS) == expected_type );
 
     /* Duplicate data if needed */
@@ -819,6 +833,8 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
 int var_GetChecked( vlc_object_t *p_this, const char *psz_name,
                     int expected_type, vlc_value_t *p_val )
 {
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
     int i_var, err = VLC_SUCCESS;
 
@@ -829,7 +845,7 @@ int var_GetChecked( vlc_object_t *p_this, const char *psz_name,
     {
         variable_t *p_var = &p_priv->p_vars[i_var];
 
-        assert( (p_var->i_type & VLC_VAR_CLASS) == 0 || expected_type == 0 ||
+        assert( expected_type == 0 ||
                 (p_var->i_type & VLC_VAR_CLASS) == expected_type );
 
         /* Really get the variable */
@@ -886,6 +902,9 @@ int __var_AddCallback( vlc_object_t *p_this, const char *psz_name,
     int i_var;
     variable_t *p_var;
     callback_entry_t entry;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     entry.pf_callback = pf_callback;
@@ -923,6 +942,12 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name,
 {
     int i_entry, i_var;
     variable_t *p_var;
+#ifndef NDEBUG
+    bool b_found_similar = false;
+#endif
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -945,15 +970,18 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name,
         }
 #ifndef NDEBUG
         else if( p_var->p_entries[i_entry].pf_callback == pf_callback )
-        {
-            msg_Warn( p_this, "Calling var_DelCallback for '%s' with the same "
-                      "function but not the same data.", psz_name );
-        }
+            b_found_similar = true;
 #endif
     }
 
     if( i_entry < 0 )
     {
+#ifndef NDEBUG
+        if( b_found_similar )
+            fprintf( stderr, "Calling var_DelCallback for '%s' with the same "
+                             "function but not the same data.", psz_name );
+        assert( 0 );
+#endif
         vlc_mutex_unlock( &p_priv->var_lock );
         return VLC_EGENERIC;
     }
@@ -976,6 +1004,9 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
     int i_var;
     int i_ret = VLC_SUCCESS;
     variable_t *p_var;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     vlc_mutex_lock( &p_priv->var_lock );
@@ -1134,7 +1165,7 @@ void var_OptionParse( vlc_object_t *p_obj, const char *psz_option,
         goto cleanup;
     }
 
-    var_Set( p_obj, psz_name, val );
+    __var_Set( p_obj, psz_name, val );
 
     /* If that's a list, remove all elements allocated */
     if( i_type == VLC_VAR_LIST )
@@ -1155,6 +1186,8 @@ cleanup:
  *****************************************************************************/
 static int GetUnused( vlc_object_t *p_this, const char *psz_name )
 {
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     while( true )
@@ -1497,6 +1530,9 @@ static int TriggerCallback( vlc_object_t *p_this, variable_t **pp_var,
     int i_var;
     int i_entries = (*pp_var)->i_entries;
     callback_entry_t *p_entries = (*pp_var)->p_entries;
+
+    assert( p_this );
+
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
     (*pp_var)->b_incallback = true;