Add VLC_VAR_GET{MIN,MAX,STEP} commands. Make it possible to use VLC_VAR_INHERITVALUE...
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 8 Dec 2007 16:53:56 +0000 (16:53 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 8 Dec 2007 16:53:56 +0000 (16:53 +0000)
include/vlc_variables.h
src/misc/variables.c

index 2b57a61..2755f7e 100644 (file)
 #define VLC_VAR_SETTEXT             0x0014
 #define VLC_VAR_GETTEXT             0x0015
 
+#define VLC_VAR_GETMIN              0x0016
+#define VLC_VAR_GETMAX              0x0017
+#define VLC_VAR_GETSTEP             0x0018
+
 #define VLC_VAR_ADDCHOICE           0x0020
 #define VLC_VAR_DELCHOICE           0x0021
 #define VLC_VAR_CLEARCHOICES        0x0022
index 9d95eec..15e9b56 100644 (file)
@@ -241,7 +241,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
             p_var->pf_cmp = CmpString;
             p_var->pf_dup = DupString;
             p_var->pf_free = FreeString;
-            p_var->val.psz_string = "";
+            p_var->val.psz_string = strdup( "" );
             break;
         case VLC_VAR_FLOAT:
             p_var->pf_cmp = CmpFloat;
@@ -420,6 +420,12 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
             p_var->pf_dup( &p_var->min );
             CheckValue( p_var, &p_var->val );
             break;
+        case VLC_VAR_GETMIN:
+            if( p_var->i_type & VLC_VAR_HASMIN )
+            {
+                *p_val = p_var->min;
+            }
+            break;
         case VLC_VAR_SETMAX:
             if( p_var->i_type & VLC_VAR_HASMAX )
             {
@@ -430,6 +436,12 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
             p_var->pf_dup( &p_var->max );
             CheckValue( p_var, &p_var->val );
             break;
+        case VLC_VAR_GETMAX:
+            if( p_var->i_type & VLC_VAR_HASMAX )
+            {
+                *p_val = p_var->max;
+            }
+            break;
         case VLC_VAR_SETSTEP:
             if( p_var->i_type & VLC_VAR_HASSTEP )
             {
@@ -440,6 +452,12 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
             p_var->pf_dup( &p_var->step );
             CheckValue( p_var, &p_var->val );
             break;
+        case VLC_VAR_GETSTEP:
+            if( p_var->i_type & VLC_VAR_HASSTEP )
+            {
+                *p_val = p_var->step;
+            }
+            break;
         case VLC_VAR_ADDCHOICE:
             /* FIXME: the list is sorted, dude. Use something cleverer. */
             for( i = p_var->choices.i_count ; i-- ; )
@@ -622,7 +640,9 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
             {
                 vlc_value_t val;
 
-                if( InheritValue( p_this, psz_name, &val, p_var->i_type )
+                if( InheritValue( p_this,
+                                  p_val2 ? p_val2->psz_string :  psz_name,
+                                  &val, p_var->i_type )
                     == VLC_SUCCESS )
                 {
                     /* Duplicate already done */
@@ -1092,6 +1112,7 @@ void __var_OptionParse( vlc_object_t *p_obj, const char *psz_option )
     case VLC_VAR_MODULE:
     case VLC_VAR_FILE:
     case VLC_VAR_DIRECTORY:
+        if( val.psz_string ) free( val.psz_string );
         val.psz_string = psz_value;
         break;