From: Olivier Teulière Date: Sat, 23 Jul 2005 19:55:00 +0000 (+0000) Subject: * modules/audio_output/waveout.c: Fixed a rounding issue X-Git-Tag: 0.8.4~1181 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=46fb23ef96d895215c4f15f72a71c4fd3d32df65;p=vlc * modules/audio_output/waveout.c: Fixed a rounding issue --- diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c index 8c681f4375..86ff0107f0 100644 --- a/modules/audio_output/waveout.c +++ b/modules/audio_output/waveout.c @@ -5,12 +5,12 @@ * $Id$ * * Authors: Gildas Bazin - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -26,6 +26,7 @@ *****************************************************************************/ #include /* strerror() */ #include /* calloc(), malloc(), free() */ +#include /* roundf() */ #include #include @@ -698,7 +699,7 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg, } /***************************************************************************** - * WaveOutThread: this thread will capture play notification events. + * WaveOutThread: this thread will capture play notification events. ***************************************************************************** * We use this thread to feed new audio samples to the sound card because * we are not authorized to use waveOutWrite() directly in the waveout @@ -800,8 +801,11 @@ static int VolumeGet( aout_instance_t * p_aout, audio_volume_t * pi_volume ) #endif i_waveout_vol &= 0xFFFF; + /* Force float computation, otherwise VolumeGet does not return the value + * which was set with VolumeSet, because of rounding issues */ *pi_volume = p_aout->output.i_volume = - i_waveout_vol * AOUT_VOLUME_MAX / 2 / 0xFFFF; + (audio_volume_t)roundf((float)i_waveout_vol * AOUT_VOLUME_MAX + / 2.0 / 0xFFFF); return 0; }