[vlc-devel] [PATCH 1/7] vlc_variables: add VLC_VAR_SETMINMAX

Filip Roséen filip at atch.se
Wed Oct 12 19:39:33 CEST 2016


Most of the time when you wanna limit the range of possible values for
a variable you do so my specifying both the lower and upper bound.

As such it certainly make sense to have a var_Change specifier to set
both, instead of doing one at a time.
---
 include/vlc_variables.h |  1 +
 src/misc/variables.c    | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index 77b4682..072f537 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -115,6 +115,7 @@
 #define VLC_VAR_GETCHOICES          0x0024
 
 #define VLC_VAR_CHOICESCOUNT        0x0026
+#define VLC_VAR_SETMINMAX           0x0027
 
 /**@}*/
 
diff --git a/src/misc/variables.c b/src/misc/variables.c
index c2ed69a..66c94f6 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -529,6 +529,25 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
             else
                 ret = VLC_EGENERIC;
             break;
+        case VLC_VAR_SETMINMAX:
+            if( p_var->i_type & VLC_VAR_HASMIN )
+            {
+                p_var->ops->pf_free( &p_var->min );
+            }
+            p_var->i_type |= VLC_VAR_HASMIN;
+            p_var->min = *p_val;
+            p_var->ops->pf_dup( &p_var->min );
+
+            if( p_var->i_type & VLC_VAR_HASMAX )
+            {
+                p_var->ops->pf_free( &p_var->max );
+            }
+            p_var->i_type |= VLC_VAR_HASMAX;
+            p_var->max = *p_val2;
+            p_var->ops->pf_dup( &p_var->max );
+
+            break;
+
         case VLC_VAR_SETSTEP:
             if( p_var->i_type & VLC_VAR_HASSTEP )
             {
-- 
2.10.0



More information about the vlc-devel mailing list