[vlc-commits] variables: remove VLC_VAR_HASSTEP
Rémi Denis-Courmont
git at videolan.org
Sat Oct 22 11:14:46 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 22 11:26:48 2016 +0300| [49bbf8dd68310c160f571e07af2b42a17259deb9] | committer: Rémi Denis-Courmont
variables: remove VLC_VAR_HASSTEP
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=49bbf8dd68310c160f571e07af2b42a17259deb9
---
include/vlc_variables.h | 1 -
src/misc/variables.c | 32 ++++++++++++++++++++------------
test/src/misc/variables.c | 4 ++--
3 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index 072f537..28e0fd1 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -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
diff --git a/src/misc/variables.c b/src/misc/variables.c
index a09e848..1bb6568 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -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:
{
diff --git a/test/src/misc/variables.c b/test/src/misc/variables.c
index 6d2d039..b8cebe3 100644
--- a/test/src/misc/variables.c
+++ b/test/src/misc/variables.c
@@ -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" );
More information about the vlc-commits
mailing list