]> git.sesse.net Git - vlc/blobdiff - include/vlc_variables.h
Better file name
[vlc] / include / vlc_variables.h
index 082660f8735c76ae1984746d85164d9ab7458e6e..a7ce058cfdcdaf608eea9ce30501fcd0f3834875 100644 (file)
@@ -61,6 +61,8 @@
 #define VLC_VAR_ISCOMMAND 0x2000
 
 /** Creation flag */
+/* If the variable is not found on the current module
+   search all parents and finally module config until found */
 #define VLC_VAR_DOINHERIT 0x8000
 /**@}*/
 
@@ -275,6 +277,23 @@ static inline int __var_SetVoid( vlc_object_t *p_obj, const char *psz_name )
 }
 #define var_SetVoid(a,b)        __var_SetVoid( VLC_OBJECT(a),b)
 
+/**
+ * Set the value of a pointer variable
+ *
+ * \param p_obj The object that holds the variable
+ * \param psz_name The name of the variable
+ * \param ptr The new pointer value of this variable
+ */
+static inline
+int var_SetAddress( vlc_object_t *p_obj, const char *psz_name, void *ptr )
+{
+    vlc_value_t val;
+    val.p_address = ptr;
+    return var_SetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, val );
+}
+#define var_SetAddress(o, n, p) var_SetAddress(VLC_OBJECT(o), n, p)
+
+
 /**
  * __var_SetBool() with automatic casting
  */
@@ -380,7 +399,7 @@ static inline char *__var_GetNonEmptyString( vlc_object_t *p_obj, const char *ps
     vlc_value_t val;
     if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
         return NULL;
-    if( *val.psz_string )
+    if( val.psz_string && *val.psz_string )
         return val.psz_string;
     free( val.psz_string );
     return NULL;
@@ -632,6 +651,19 @@ static inline char *__var_CreateGetNonEmptyStringCommand( vlc_object_t *p_obj,
  */
 #define var_CreateGetStringCommand(a,b)   __var_CreateGetStringCommand( VLC_OBJECT(a),b)
 #define var_CreateGetNonEmptyStringCommand(a,b)   __var_CreateGetNonEmptyStringCommand( VLC_OBJECT(a),b)
+
+static inline int __var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
+{
+    vlc_value_t count;
+    if( __var_Change( p_obj, psz_name, VLC_VAR_CHOICESCOUNT, &count, NULL ) )
+        return 0;
+    return count.i_int;
+}
+/**
+ * __var_CountChoices() with automatic casting
+ */
+#define var_CountChoices(a,b) __var_CountChoices( VLC_OBJECT(a),b)
+
 /**
  * @}
  */