Commit a88db786 authored by Rafaël Carré's avatar Rafaël Carré

DBus: Round volume to nearest integer - fixes #1561

parent ed57b5bd
...@@ -637,6 +637,9 @@ AC_CHECK_LIB(m,ceil,[ ...@@ -637,6 +637,9 @@ AC_CHECK_LIB(m,ceil,[
AC_CHECK_LIB(m,exp,[ AC_CHECK_LIB(m,exp,[
VLC_ADD_LIBS([gaussianblur],[-lm]) VLC_ADD_LIBS([gaussianblur],[-lm])
]) ])
AC_CHECK_LIB(m,round,[
VLC_ADD_LIBS([dbus],[-lm])
])
AC_CHECK_LIB(mx,sqrtf,[ AC_CHECK_LIB(mx,sqrtf,[
VLC_ADD_LIBS([x264],[-lmx]) VLC_ADD_LIBS([x264],[-lmx])
]) ])
......
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_playlist.h> #include <vlc_playlist.h>
#include <math.h>
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
*****************************************************************************/ *****************************************************************************/
...@@ -221,7 +223,8 @@ DBUS_METHOD( VolumeGet ) ...@@ -221,7 +223,8 @@ DBUS_METHOD( VolumeGet )
audio_volume_t i_vol; audio_volume_t i_vol;
/* 2nd argument of aout_VolumeGet is int32 */ /* 2nd argument of aout_VolumeGet is int32 */
aout_VolumeGet( (vlc_object_t*) p_this, &i_vol ); 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 ); ADD_INT32( &i_dbus_vol );
REPLY_SEND; REPLY_SEND;
} }
...@@ -248,7 +251,8 @@ DBUS_METHOD( VolumeSet ) ...@@ -248,7 +251,8 @@ DBUS_METHOD( VolumeSet )
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 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 ); aout_VolumeSet( (vlc_object_t*) p_this, i_vol );
REPLY_SEND; REPLY_SEND;
......
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