]> git.sesse.net Git - vlc/commitdiff
DBus: Round volume to nearest integer - fixes #1561
authorRafaël Carré <funman@videolan.org>
Mon, 5 May 2008 18:57:25 +0000 (20:57 +0200)
committerRafaël Carré <funman@videolan.org>
Mon, 5 May 2008 18:57:25 +0000 (20:57 +0200)
configure.ac
modules/control/dbus.c

index a47a4b017e0a2e2f31cc0bb6a0f28500d293c4d5..ae6dbd0b0424413f2592ccabe652d42e6167c0e7 100644 (file)
@@ -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])
 ])
index 2eae9d128b2d5bc6e81ec9068a43b8e274829c0e..43ee28b05e9cdbf8b3baf682d7663ab4f5904a19 100644 (file)
@@ -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;