Commit 49bbf8dd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

variables: remove VLC_VAR_HASSTEP

parent 7a7d863f
......@@ -62,7 +62,6 @@
#define VLC_VAR_HASCHOICE 0x0100
#define VLC_VAR_HASMIN 0x0200
#define VLC_VAR_HASMAX 0x0400
#define VLC_VAR_HASSTEP 0x0800
#define VLC_VAR_ISCOMMAND 0x2000
......
......@@ -219,8 +219,7 @@ static void CheckValue(variable_t *var, vlc_value_t *val)
val->i_int = var->min.i_int;
if ((var->i_type & VLC_VAR_HASMAX) && val->i_int > var->max.i_int)
val->i_int = var->max.i_int;
if ((var->i_type & VLC_VAR_HASSTEP) && var->step.i_int
&& (val->i_int % var->step.i_int))
if (var->step.i_int != 0 && (val->i_int % var->step.i_int))
val->i_int = (val->i_int + (var->step.i_int / 2))
/ var->step.i_int * var->step.i_int;
break;
......@@ -232,7 +231,7 @@ static void CheckValue(variable_t *var, vlc_value_t *val)
if ((var->i_type & VLC_VAR_HASMAX)
&& isgreater(val->f_float, var->max.f_float))
val->f_float = var->max.f_float;
if ((var->i_type & VLC_VAR_HASSTEP) && var->step.f_float)
if (var->step.f_float != 0.f)
val->f_float = var->step.f_float
* roundf(val->f_float / var->step.f_float);
break;
......@@ -549,20 +548,29 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
break;
case VLC_VAR_SETSTEP:
if( p_var->i_type & VLC_VAR_HASSTEP )
{
p_var->ops->pf_free( &p_var->step );
}
p_var->i_type |= VLC_VAR_HASSTEP;
p_var->ops->pf_free( &p_var->step );
p_var->step = *p_val;
p_var->ops->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;
else
ret = VLC_EGENERIC;
switch (p_var->i_type & VLC_VAR_TYPE)
{
case VLC_VAR_INTEGER:
if (p_var->step.i_int != 0)
*p_val = p_var->step;
else
ret = VLC_EGENERIC;
break;
case VLC_VAR_FLOAT:
if (p_var->step.f_float != 0.f)
*p_val = p_var->step;
else
ret = VLC_EGENERIC;
break;
default:
ret = VLC_EGENERIC;
}
break;
case VLC_VAR_ADDCHOICE:
{
......
......@@ -440,9 +440,9 @@ static void test_creation_and_type( libvlc_int_t *p_libvlc )
var_Change( p_libvlc, "bla", VLC_VAR_SETMAX, &val, NULL );
var_Change( p_libvlc, "bla", VLC_VAR_SETSTEP, &val, NULL );
assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ) == VLC_SUCCESS );
assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMAX | VLC_VAR_HASSTEP) );
assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMAX) );
assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ) == VLC_SUCCESS );
assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMAX | VLC_VAR_HASSTEP | VLC_VAR_HASCHOICE) );
assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMAX | VLC_VAR_HASCHOICE) );
var_Destroy( p_libvlc, "bla" );
var_Destroy( p_libvlc, "bla" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment