*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
*****************************************************************************/
#include <string.h> /* strerror() */
#include <stdlib.h> /* calloc(), malloc(), free() */
-#include <math.h> /* roundf() */
#include <vlc/vlc.h>
#include <vlc/aout.h>
*****************************************************************************/
#ifdef UNDER_CE
# define DWORD_PTR DWORD
+# ifdef waveOutGetDevCaps
+# undef waveOutGetDevCaps
+ MMRESULT WINAPI waveOutGetDevCaps(UINT, LPWAVEOUTCAPS, UINT);
+# endif
#endif
#ifndef WAVE_FORMAT_IEEE_FLOAT
}
else
{
+ WAVEOUTCAPS wocaps;
+
if( val.i_int == AOUT_VAR_5_1 )
{
p_aout->output.output.i_physical_channels
aout_VolumeSoftInit( p_aout );
- p_aout->output.pf_volume_infos = VolumeInfos;
- p_aout->output.pf_volume_get = VolumeGet;
- p_aout->output.pf_volume_set = VolumeSet;
+ /* Check for hardware volume support */
+ if( waveOutGetDevCaps( (UINT_PTR)p_aout->output.p_sys->h_waveout,
+ &wocaps, sizeof(wocaps) ) == MMSYSERR_NOERROR &&
+ wocaps.dwSupport & WAVECAPS_VOLUME )
+ {
+ DWORD i_dummy;
+ if( waveOutGetVolume( p_aout->output.p_sys->h_waveout, &i_dummy )
+ == MMSYSERR_NOERROR )
+ {
+ p_aout->output.pf_volume_infos = VolumeInfos;
+ p_aout->output.pf_volume_get = VolumeGet;
+ p_aout->output.pf_volume_set = VolumeSet;
+ }
+ }
}
#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 =
- (audio_volume_t)roundf((float)i_waveout_vol * AOUT_VOLUME_MAX
- / 2.0 / 0xFFFF);
+ (i_waveout_vol * AOUT_VOLUME_MAX + 0xFFFF /*rounding*/) / 2 / 0xFFFF;
return 0;
}