[vlc-devel] commit: DBus: Round volume to nearest integer - fixes #1561 ( Rafaël Carré )
git version control
git at videolan.org
Mon May 5 20:55:53 CEST 2008
vlc | branch: master | Rafaël Carré <funman at videolan.org> | Mon May 5 20:57:25 2008 +0200| [a88db7865f48317763547133843e590621c09657]
DBus: Round volume to nearest integer - fixes #1561
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a88db7865f48317763547133843e590621c09657
---
configure.ac | 3 +++
modules/control/dbus.c | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index a47a4b0..ae6dbd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -637,6 +637,9 @@ AC_CHECK_LIB(m,ceil,[
AC_CHECK_LIB(m,exp,[
VLC_ADD_LIBS([gaussianblur],[-lm])
])
+AC_CHECK_LIB(m,round,[
+ VLC_ADD_LIBS([dbus],[-lm])
+])
AC_CHECK_LIB(mx,sqrtf,[
VLC_ADD_LIBS([x264],[-lmx])
])
diff --git a/modules/control/dbus.c b/modules/control/dbus.c
index 2eae9d1..43ee28b 100644
--- a/modules/control/dbus.c
+++ b/modules/control/dbus.c
@@ -54,6 +54,8 @@
#include <vlc_input.h>
#include <vlc_playlist.h>
+#include <math.h>
+
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
@@ -221,7 +223,8 @@ DBUS_METHOD( VolumeGet )
audio_volume_t i_vol;
/* 2nd argument of aout_VolumeGet is int32 */
aout_VolumeGet( (vlc_object_t*) p_this, &i_vol );
- i_dbus_vol = ( 100 * i_vol ) / AOUT_VOLUME_MAX;
+ double f_vol = 100. * i_vol / AOUT_VOLUME_MAX;
+ i_dbus_vol = round( f_vol );
ADD_INT32( &i_dbus_vol );
REPLY_SEND;
}
@@ -248,7 +251,8 @@ DBUS_METHOD( VolumeSet )
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- i_vol = ( AOUT_VOLUME_MAX / 100 ) *i_dbus_vol;
+ double f_vol = AOUT_VOLUME_MAX * i_dbus_vol / 100.;
+ i_vol = round( f_vol );
aout_VolumeSet( (vlc_object_t*) p_this, i_vol );
REPLY_SEND;
More information about the vlc-devel
mailing list