[vlc-commits] lib: fix (pre)amplification range checks for equalizer
Rémi Denis-Courmont
git at videolan.org
Tue May 20 13:10:28 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May 19 19:05:00 2014 +0800| [2e8d457afe1dc56a86bcb3dc2d39d8c95c7ba3c3] | committer: Rémi Denis-Courmont
lib: fix (pre)amplification range checks for equalizer
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2e8d457afe1dc56a86bcb3dc2d39d8c95c7ba3c3
---
lib/audio.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/lib/audio.c b/lib/audio.c
index 9f42db1..26280bd 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -578,10 +578,12 @@ void libvlc_audio_equalizer_release( libvlc_equalizer_t *p_equalizer )
*****************************************************************************/
int libvlc_audio_equalizer_set_preamp( libvlc_equalizer_t *p_equalizer, float f_preamp )
{
- if ( f_preamp < -20.0f )
- f_preamp = -20.0f;
- else if ( f_preamp > 20.0f )
- f_preamp = 20.0f;
+ if( isnan(f_preamp) )
+ return -1;
+ if( f_preamp < -20.f )
+ f_preamp = -20.f;
+ else if( f_preamp > 20.f )
+ f_preamp = 20.f;
p_equalizer->f_preamp = f_preamp;
return 0;
@@ -600,13 +602,14 @@ float libvlc_audio_equalizer_get_preamp( libvlc_equalizer_t *p_equalizer )
*****************************************************************************/
int libvlc_audio_equalizer_set_amp_at_index( libvlc_equalizer_t *p_equalizer, float f_amp, unsigned u_band )
{
- if ( u_band >= EQZ_BANDS_MAX )
+ if( u_band >= EQZ_BANDS_MAX || isnan(f_amp) )
return -1;
- if ( f_amp < -20.0f )
- f_amp = -20.0f;
- else if ( f_amp > 20.0f )
- f_amp = 20.0f;
+
+ if( f_amp < -20.f )
+ f_amp = -20.f;
+ else if( f_amp > 20.f )
+ f_amp = 20.f;
p_equalizer->f_amp[ u_band ] = f_amp;
return 0;
More information about the vlc-commits
mailing list