Commit 96e872ee authored by Jean-Philippe André's avatar Jean-Philippe André

Audio output: fix integer overflow

This fixes the following bug:
When scrolling the mouse wheel down, volume jumps from 0% to 400%.
parent 87bb0a07
......@@ -76,7 +76,7 @@ int doVolumeChanges( unsigned action, vlc_object_t * p_object, int i_nb_steps,
bool b_mute )
{
int i_result = VLC_SUCCESS;
int i_volume_step = 1;
int i_volume_step = 1, i_new_volume = 0;
bool b_var_mute = false;
aout_instance_t *p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
......@@ -120,12 +120,16 @@ int doVolumeChanges( unsigned action, vlc_object_t * p_object, int i_nb_steps,
if ( !b_unmute_condition )
i_volume = config_GetInt( p_object, "volume" );
i_volume += i_volume_step * i_nb_steps;
if ( i_volume > AOUT_VOLUME_MAX )
i_new_volume = (int) i_volume + i_volume_step * i_nb_steps;
if ( i_new_volume > AOUT_VOLUME_MAX )
i_volume = AOUT_VOLUME_MAX;
else if ( i_volume < AOUT_VOLUME_MIN )
else if ( i_new_volume < AOUT_VOLUME_MIN )
i_volume = AOUT_VOLUME_MIN;
else
i_volume = i_new_volume;
if ( i_return_volume != NULL )
*i_return_volume = i_volume;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment