]> git.sesse.net Git - vlc/blobdiff - include/vlc_variables.h
Cosmetics (K&R of picture_fifo).
[vlc] / include / vlc_variables.h
index 0efe910d03641ca2f69a3152b2e3bb5c1f24afd5..06ae899f327b3f29e313f03dcecff2e8b21c0916 100644 (file)
 #define VLC_VAR_SETISCOMMAND        0x0040
 /**@}*/
 
+/** \defgroup var_GetAndSet Variable actions
+ * These are the different actions that can be used with __var_GetAndSet()
+ * @{
+ */
+/**
+ * Toggle the value of this boolean
+ * \param val Unused
+ */
+#define VLC_VAR_TOGGLE_BOOL         0x0010
+/**
+ * Increment or decrement an integer of a given value
+ * \param val the value
+ */
+#define VLC_VAR_INTEGER_INCDEC      0x0020
+/**@}*/
+
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
@@ -128,6 +144,7 @@ VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
 VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
 VLC_EXPORT( int, var_SetChecked, ( vlc_object_t *, const char *, int, vlc_value_t ) );
 VLC_EXPORT( int, var_GetChecked, ( vlc_object_t *, const char *, int, vlc_value_t * ) );
+VLC_EXPORT( int, __var_GetAndSet, ( vlc_object_t *, const char *, int, vlc_value_t ) );
 
 #define var_Command(a,b,c,d,e) __var_Command( VLC_OBJECT( a ), b, c, d, e )
 VLC_EXPORT( int, __var_Command, ( vlc_object_t *, const char *, const char *, const char *, char ** ) );
@@ -160,6 +177,10 @@ VLC_EXPORT( void, var_FreeList, ( vlc_value_t *, vlc_value_t * ) );
  * __var_Get() with automatic casting
  */
 #define var_Get(a,b,c) __var_Get( VLC_OBJECT(a), b, c )
+/**
+ * __var_GetAndSet() with automatic casting
+ */
+#define var_GetAndSet(a,b,c,d) __var_GetAndSet(VLC_OBJECT(a), b, c, d)
 
 /*****************************************************************************
  * Variable callbacks
@@ -427,8 +448,9 @@ static inline char *__var_GetNonEmptyString( vlc_object_t *p_obj, const char *ps
  */
 static inline void __var_IncInteger( vlc_object_t *p_obj, const char *psz_name )
 {
-    int i_val = __var_GetInteger( p_obj, psz_name );
-    __var_SetInteger( p_obj, psz_name, ++i_val );
+    vlc_value_t val;
+    val.i_int = 1;
+    __var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_INCDEC, val );
 }
 #define var_IncInteger(a,b) __var_IncInteger( VLC_OBJECT(a), b )
 
@@ -439,8 +461,9 @@ static inline void __var_IncInteger( vlc_object_t *p_obj, const char *psz_name )
  */
 static inline void __var_DecInteger( vlc_object_t *p_obj, const char *psz_name )
 {
-    int i_val = __var_GetInteger( p_obj, psz_name );
-    __var_SetInteger( p_obj, psz_name, --i_val );
+    vlc_value_t val;
+    val.i_int = -1;
+    __var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_INCDEC, val );
 }
 #define var_DecInteger(a,b) __var_DecInteger( VLC_OBJECT(a), b )
 
@@ -642,6 +665,7 @@ 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)
 
+LIBVLC_USED
 static inline int __var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
 {
     vlc_value_t count;
@@ -654,6 +678,16 @@ static inline int __var_CountChoices( vlc_object_t *p_obj, const char *psz_name
  */
 #define var_CountChoices(a,b) __var_CountChoices( VLC_OBJECT(a),b)
 
+
+static inline int __var_ToggleBool( vlc_object_t *p_obj, const char *psz_name )
+{
+    vlc_value_t val;
+    return __var_GetAndSet( p_obj, psz_name, VLC_VAR_TOGGLE_BOOL, val );
+}
+/**
+ * __var_ToggleBool() with automatic casting
+ */
+#define var_ToggleBool(a,b) __var_ToggleBool( VLC_OBJECT(a),b )
 /**
  * @}
  */