[vlc-commits] variables: fix rounding of negative integer values
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 12:08:32 2016 +0300| [735fcc19c02ff384632820e33c70e8813720ab99] | committer: Rémi Denis-Courmont
variables: fix rounding of negative integer values
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=735fcc19c02ff384632820e33c70e8813720ab99
---
src/misc/variables.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/misc/variables.c b/src/misc/variables.c
index c779d34..d404c59 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -221,8 +221,14 @@ static void CheckValue(variable_t *var, vlc_value_t *val)
if (val->i_int > var->max.i_int)
val->i_int = var->max.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;
+ {
+ if (val->i_int > 0)
+ val->i_int = (val->i_int + (var->step.i_int / 2))
+ / var->step.i_int * var->step.i_int;
+ else
+ val->i_int = (val->i_int - (var->step.i_int / 2))
+ / var->step.i_int * var->step.i_int;
+ }
break;
case VLC_VAR_FLOAT:
More information about the vlc-commits
mailing list