[vlc-devel] [PATCH 6/7] config/chain: respect ranges when creating variables

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


When creating variables that has their origin in a config-chain, we need to
make sure that their lower and upperbound is honored.

fixes #17431
---
 src/config/chain.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/config/chain.c b/src/config/chain.c
index e20585d..0e42fb8 100644
--- a/src/config/chain.c
+++ b/src/config/chain.c
@@ -34,8 +34,10 @@
 #include <vlc_common.h>
 #include "libvlc.h"
 #include <vlc_charset.h>
+#include <vlc_plugin.h>
 
 #include "vlc_interface.h"
+#include "configuration.h"
 
 /*****************************************************************************
  * Local prototypes
@@ -287,6 +289,25 @@ void config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
             if( var_Create( p_this, name, config_GetType( p_this, name ) |
                                           VLC_VAR_DOINHERIT ) )
                 return /* VLC_xxx */;
+
+            module_config_t* p_conf = config_FindConfig( p_this, name );
+
+            if( p_conf )
+            {
+                switch( CONFIG_CLASS( p_conf->i_type ) )
+                {
+                    case CONFIG_ITEM_INTEGER:
+                        var_Change( p_this, name, VLC_VAR_SETMINMAX,
+                            &(vlc_value_t){ .i_int = p_conf->min.i },
+                            &(vlc_value_t){ .i_int = p_conf->max.i } );
+                        break;
+                    case CONFIG_ITEM_FLOAT:
+                        var_Change( p_this, name, VLC_VAR_SETMINMAX,
+                            &(vlc_value_t){ .f_float = p_conf->min.f },
+                            &(vlc_value_t){ .f_float = p_conf->max.f } );
+                        break;
+                }
+            }
         }
     }
 
-- 
2.10.0



More information about the vlc-devel mailing list