[vlc-devel] [PATCH 2/3] src/input: add a new input option flag to replace values of existing options

David Fuhrmann david.fuhrmann at gmail.com
Sun May 11 11:45:50 CEST 2014


Hi Remi,

Am 11.05.2014 um 03:42 schrieb Rémi Denis-Courmont <remi at remlab.net>:

> Le 2014-05-10 18:42, david.fuhrmann at gmail.com a écrit :
>> From: David Fuhrmann <dfuhrmann at videolan.org>
>> 
>> This flag can be used with input_item_AddOption to replace the value
>> of an input option, if this option already exists. Otherwise, the
>> new option is added as usual.
>> 
>> This can be used for instance to change the starttime option.
>> 
>> refs #11471
>> ---
>> include/vlc_input_item.h |  5 +++++
>> src/input/item.c         | 23 +++++++++++++++++++++++
>> 2 files changed, 28 insertions(+)
>> 
>> diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
>> index 944ac2f..d8ffd34 100644
>> --- a/include/vlc_input_item.h
>> +++ b/include/vlc_input_item.h
>> @@ -179,6 +179,11 @@ enum input_item_option_e
>>     /* Add the option, unless the same option
>>      * is already present. */
>>     VLC_INPUT_OPTION_UNIQUE  = 0x100,
>> +
>> +    /* Search for an existing option in the format
>> +     * option=value and replaces the first one found.
>> +     * Else, the new option is added. */
>> +    VLC_INPUT_OPTION_REPLACE = 0x400,
>> };
>> 
>> /**
>> diff --git a/src/input/item.c b/src/input/item.c
>> index b27250b..36e1279 100644
>> --- a/src/input/item.c
>> +++ b/src/input/item.c
>> @@ -473,6 +473,29 @@ int input_item_AddOption( input_item_t *p_input,
>> const char *psz_option,
>>                 goto out;
>>     }
>> 
>> +    if (flags & VLC_INPUT_OPTION_REPLACE)
> 
> That won't work if UNIQUE was set too.

UNIQUE and REPLACE are mutually exclusive. I will add this to the documentation. If someone still passes both flags, it looks fine that UNIQUE as the the „stronger“ variant take precedence. 

> 
>> +    {
>> +        /* search for option format "option=value" */
>> +
>> +        const char *psz_found = strchr( psz_option, '=' );
>> +        if( unlikely( psz_found == NULL ) )
>> +        {
>> +            err = VLC_EGENERIC;
>> +            goto out;
> 
> Uh, that does not seem right?

Looks like no caller checks for the return value anyway. So it make sense to have a softer fallback, indeed.

With best regards,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20140511/54a7bfde/attachment.html>


More information about the vlc-devel mailing list