[vlc-devel] [PATCH 2/2] equalizer: load the equalizer-preset only if equalizer-bands is not set

Adrien Maglo magsoft at videolan.org
Tue Jun 24 16:21:50 CEST 2014


Le 24/06/2014 14:14, Rémi Denis-Courmont a écrit :
>      Hello,
>
> Le 2014-06-18 22:33, Adrien Maglo a écrit :
>> When using the libVLC equalizer API, this prevents the band settings
>> to be overridden on start by the default "flat" preset.
>> ---
>>  modules/audio_filter/equalizer.c | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/modules/audio_filter/equalizer.c
>> b/modules/audio_filter/equalizer.c
>> index a7ce684..f8ca033 100644
>> --- a/modules/audio_filter/equalizer.c
>> +++ b/modules/audio_filter/equalizer.c
>> @@ -341,11 +341,13 @@ static int EqzInit( filter_t *p_filter, int
>> i_rate )
>>
>>      /* Get initial values */
>>      var_Get( p_aout, "equalizer-preset", &val1 );
>> -    PresetCallback( VLC_OBJECT( p_aout ), NULL, val1, val1, p_sys );
>> -    free( val1.psz_string );
>> -
>>      var_Get( p_aout, "equalizer-bands", &val2 );
>>      var_Get( p_aout, "equalizer-preamp", &val3 );
>> +
>> +    /* Load the preset only if equalizer-bands is not set. */
>> +    if (val2.psz_string != NULL && *val2.psz_string != "\0")
>
> Comparing a character with a pointer cannot be correct. And I think val2
> cannot be NULL (aside from memory errors which this code does not handle
> correctly anyway).

Thanks for pointing that out. I think I have just fixed the wrong 
comparison part.

However, I don't know what to do about the memory error handling.
I guess strdup("") of var_Inherit() in line 1219 of src/misc/variables.c 
can theoretically return a NULL pointer even if it does not seem 
plausible...
I have actually copied the check pattern of line 355 in equalizer.c:
/* Exit if we have no preset and no bands value */
if (!val2.psz_string || !*val2.psz_string)

Best regards,


-- 
MagSoft




More information about the vlc-devel mailing list