[vlc-devel] [PATCH 0/6, resubmit] command-line/config-chain: respect variable ranges

Filip Roséen filip at atch.se
Thu Oct 13 13:48:58 CEST 2016


Attached are all the patches in this patch-batch rebased to account
for the fact that original patch `#5` should not be merged.

See the below linked message for more information:

  - https://mailman.videolan.org/pipermail/vlc-devel/2016-October/109833.html

The final diff between the previous patch-batch and the ones attached to this
email is as the below (the indentation has changed due to one less if-branch,
other than that the code is equivalent).

    diff --git a/src/config/chain.c b/src/config/chain.c
    index 0e42fb8..660ad8f 100644
    --- a/src/config/chain.c
    +++ b/src/config/chain.c
    @@ -283,30 +283,25 @@ void config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
     
             char name[plen + strlen( optname )];
             snprintf( name, sizeof (name), "%s%s", psz_prefix, optname );
    +        if( var_Create( p_this, name,
    +                        config_GetType( p_this, name ) | VLC_VAR_DOINHERIT ) )
    +            return /* VLC_xxx */;
     
    -        if( var_Type( p_this, name ) == 0 )
    +        module_config_t* p_conf = config_FindConfig( p_this, name );
    +        if( p_conf )
             {
    -            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 ) )
                 {
    -                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;
    -                }
    +                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;
                 }
             }
         }

Best Regards,\
Filip

On 2016-10-12 19:39, Filip Roséen wrote:

> These patches are all related to have variables with ranges are handled when
> created through the command-line, or during config-chain parsing.
> 
> In short, the below tickets are fixed:
> 
>     - https://trac.videolan.org/vlc/ticket/17430
>     - https://trac.videolan.org/vlc/ticket/17431
> 
> It should however be noted that the changes in these patch also fixes
> modules that have been written under the assumption that their
> specified variable ranges are honored (in such a way that they cannot
> receive values outside of the specified range).
> 
> I found it hard to come up with some suitable ascii-art that is
> related to variables, so below is some sort of dancing bear/bunny
> hybrid.
> 
>                              (') (')
>                               (o.o)
>                             ,-(   )-'
>                              (")-(")
> 
> Filip Roséen (6):
>   vlc_variables: add VLC_VAR_SETMINMAX
>   access/v4l2: use VLC_VAR_SETMINMAX
>   modules/entry: specify default range for floats
>   config/chain: only create variable if it does not exists
>   config/chain: respect ranges when creating variables
>   config/cmdline: respect ranges when creating variables
> 
>  include/vlc_variables.h        |  1 +
>  modules/access/v4l2/controls.c | 28 ++++++++++++----------------
>  src/config/chain.c             | 31 ++++++++++++++++++++++++++++---
>  src/config/cmdline.c           |  6 ++++++
>  src/misc/variables.c           | 19 +++++++++++++++++++
>  src/modules/entry.c            |  6 ++++++
>  6 files changed, 72 insertions(+), 19 deletions(-)
> 
> -- 
> 2.10.0
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161013/0a788f2d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vlc_variables-add-VLC_VAR_SETMINMAX.patch
Type: text/x-diff
Size: 1900 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161013/0a788f2d/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-access-v4l2-use-VLC_VAR_SETMINMAX.patch
Type: text/x-diff
Size: 3079 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161013/0a788f2d/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-modules-entry-specify-default-range-for-floats.patch
Type: text/x-diff
Size: 1190 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161013/0a788f2d/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-config-help-only-print-variable-range-if-explicitly-.patch
Type: text/x-diff
Size: 1859 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161013/0a788f2d/attachment-0003.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-config-cmdline-respect-ranges-when-creating-variable.patch
Type: text/x-diff
Size: 1718 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161013/0a788f2d/attachment-0004.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-config-chain-respect-ranges-when-creating-variables.patch
Type: text/x-diff
Size: 1935 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161013/0a788f2d/attachment-0005.patch>


More information about the vlc-devel mailing list