From: Antoine Cellerier Date: Sat, 8 Dec 2007 16:53:56 +0000 (+0000) Subject: Add VLC_VAR_GET{MIN,MAX,STEP} commands. Make it possible to use VLC_VAR_INHERITVALUE... X-Git-Tag: 0.9.0-test0~4234 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=02752dc7806ae5385f868faada5718e89aa76add;p=vlc Add VLC_VAR_GET{MIN,MAX,STEP} commands. Make it possible to use VLC_VAR_INHERITVALUE with a 2nd argument which will be used as the variable name to inherit (for example you want to inherit a variable named "v4l2-hue" into a variable named "hue": vlc_value_t val; val.psz_string = strdup( "v4l2-hue" ); var_Change( p_demux, "hue", VLC_VAR_INHERITVALUE, NULL, &val ); free( val.psz_string ); ) --- diff --git a/include/vlc_variables.h b/include/vlc_variables.h index 2b57a6104e..2755f7e350 100644 --- a/include/vlc_variables.h +++ b/include/vlc_variables.h @@ -94,6 +94,10 @@ #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 diff --git a/src/misc/variables.c b/src/misc/variables.c index 9d95eec4cb..15e9b56470 100644 --- a/src/misc/variables.c +++ b/src/misc/variables.c @@ -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;