]> git.sesse.net Git - vlc/commitdiff
aout_Volume*: use float rather than integer
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 2 Jul 2012 15:48:56 +0000 (18:48 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 3 Jul 2012 15:04:08 +0000 (18:04 +0300)
16 files changed:
configure.ac
include/vlc_aout_intf.h
lib/audio.c
modules/control/dbus/dbus_player.c
modules/control/hotkeys.c
modules/control/rc.c
modules/gui/macosx/CoreInteraction.m
modules/gui/macosx/MainWindow.m
modules/gui/ncurses.c
modules/gui/qt4/components/controller_widget.cpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/vars/volume.cpp
modules/lua/libs/volume.c
src/audio_output/intf.c
src/audio_output/output.c
src/text/strings.c

index 3fecbaf623547b09cedf9af0155a35d1f35ae6ef..455db897760c7e5455b8562c7ef558e587a369b1 100644 (file)
@@ -628,7 +628,7 @@ AC_CHECK_FUNC(getopt_long,, [
 AC_SUBST(GNUGETOPT_LIBS)
 
 AC_CHECK_LIB(m,cos,[
-  VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo mp4 quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x26410b hqdn3d anaglyph],[-lm])
+  VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo mp4 quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x26410b hqdn3d anaglyph oldrc ncurses],[-lm])
   LIBM="-lm"
 ], [
   LIBM=""
index dd2354194742c3e3596cf5bed1a3c3043e1a65ee..dbd1b3061f3d92d5492407f95c4aec8a4ab13f72 100644 (file)
 #define AOUT_VOLUME_DEFAULT             256
 #define AOUT_VOLUME_MAX                 512
 
-VLC_API audio_volume_t aout_VolumeGet( vlc_object_t * );
+VLC_API float aout_VolumeGet( vlc_object_t * );
 #define aout_VolumeGet(a) aout_VolumeGet(VLC_OBJECT(a))
-VLC_API int aout_VolumeSet( vlc_object_t *, audio_volume_t );
+VLC_API int aout_VolumeSet( vlc_object_t *, float );
 #define aout_VolumeSet(a, b) aout_VolumeSet(VLC_OBJECT(a), b)
-VLC_API int aout_VolumeUp( vlc_object_t *, int, audio_volume_t * );
+VLC_API int aout_VolumeUp( vlc_object_t *, int, float * );
 #define aout_VolumeUp(a, b, c) aout_VolumeUp(VLC_OBJECT(a), b, c)
 #define aout_VolumeDown(a, b, c) aout_VolumeUp(a, -(b), c)
 VLC_API int aout_MuteToggle( vlc_object_t * );
index c7cf02a250b834248c068d22c2edf10374e9946e..27d7cd41a957d0a53a2b7c8e7c17bce08519ac6f 100644 (file)
@@ -27,6 +27,7 @@
 #endif
 
 #include <assert.h>
+#include <math.h>
 
 #include <vlc/libvlc.h>
 #include <vlc/libvlc_media.h>
@@ -323,29 +324,21 @@ void libvlc_audio_set_mute( libvlc_media_player_t *mp, int mute )
     aout_MuteSet( VLC_OBJECT(mp), mute != 0 );
 }
 
-/*****************************************************************************
- * libvlc_audio_get_volume : Get the current volume
- *****************************************************************************/
 int libvlc_audio_get_volume( libvlc_media_player_t *mp )
 {
-    unsigned volume = aout_VolumeGet( mp );
-
-    return (volume * 100 + AOUT_VOLUME_DEFAULT / 2) / AOUT_VOLUME_DEFAULT;
+    float vol = aout_VolumeGet( mp );
+    return ( vol >= 0.f ) ? lroundf( vol * 100.f ) : -1;
 }
 
-
-/*****************************************************************************
- * libvlc_audio_set_volume : Set the current volume
- *****************************************************************************/
 int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
 {
-    volume = (volume * AOUT_VOLUME_DEFAULT + 50) / 100;
-    if (volume < 0 || volume > AOUT_VOLUME_MAX)
+    float vol = volume / 100.f;
+    if (vol < 0.f)
     {
         libvlc_printerr( "Volume out of range" );
         return -1;
     }
-    aout_VolumeSet (mp, volume);
+    aout_VolumeSet (mp, vol);
     return 0;
 }
 
index 4aa255ab9c08d6cc6ed55b5befaab155905779de..c3dc60433fdad05708b085a577a920dd47897d2a 100644 (file)
@@ -167,11 +167,11 @@ DBUS_METHOD( Seek )
 static void
 MarshalVolume( intf_thread_t *p_intf, DBusMessageIter *container )
 {
-    audio_volume_t i_vol = aout_VolumeGet( p_intf->p_sys->p_playlist );
-
-    /* A volume of 1.0 represents a sensible maximum, ie: 0dB */
-    double d_vol = (double) i_vol / AOUT_VOLUME_DEFAULT;
+    float f_vol = aout_VolumeGet( p_intf->p_sys->p_playlist );
+    if( f_vol < 0.f )
+        f_vol = 1.f; /* ? */
 
+    double d_vol = f_vol;
     dbus_message_iter_append_basic( container, DBUS_TYPE_DOUBLE, &d_vol );
 }
 
@@ -204,9 +204,7 @@ DBUS_METHOD( VolumeSet )
     d_dbus_vol *= AOUT_VOLUME_DEFAULT;
     if( d_dbus_vol < 0. )
         d_dbus_vol = 0.;
-    if( d_dbus_vol > AOUT_VOLUME_MAX )
-        d_dbus_vol = AOUT_VOLUME_MAX;
-    aout_VolumeSet( PL, lround(d_dbus_vol) );
+    aout_VolumeSet( PL, d_dbus_vol );
 
     REPLY_SEND;
 }
index 868d5230b046d9abf691ce205b72c470076ae722..dcbef2803fdd8821aea5531c2e49eb3adc898f95 100644 (file)
@@ -70,7 +70,7 @@ static int  SpecialKeyEvent( vlc_object_t *, char const *,
 static void PlayBookmark( intf_thread_t *, int );
 static void SetBookmark ( intf_thread_t *, int );
 static void DisplayPosition( intf_thread_t *, vout_thread_t *, input_thread_t * );
-static void DisplayVolume  ( intf_thread_t *, vout_thread_t *, audio_volume_t );
+static void DisplayVolume( intf_thread_t *, vout_thread_t *, float );
 static void DisplayRate ( vout_thread_t *, float );
 static float AdjustRateFine( input_thread_t *, const int );
 static void ClearChannels  ( intf_thread_t *, vout_thread_t * );
@@ -186,33 +186,31 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
         /* Volume and audio actions */
         case ACTIONID_VOL_UP:
         {
-            audio_volume_t i_newvol;
-            aout_VolumeUp( p_playlist, 1, &i_newvol );
-            DisplayVolume( p_intf, p_vout, i_newvol );
+            float vol;
+            if( aout_VolumeUp( p_playlist, 1, &vol ) == 0 )
+                DisplayVolume( p_intf, p_vout, vol );
             break;
         }
 
         case ACTIONID_VOL_DOWN:
         {
-            audio_volume_t i_newvol;
-            aout_VolumeDown( p_playlist, 1, &i_newvol );
-            DisplayVolume( p_intf, p_vout, i_newvol );
+            float vol;
+            if( aout_VolumeDown( p_playlist, 1, &vol ) == 0 )
+                DisplayVolume( p_intf, p_vout, vol );
             break;
         }
 
         case ACTIONID_VOL_MUTE:
-            if( aout_MuteToggle( p_playlist ) == 0 && p_vout != NULL )
+            if( aout_MuteToggle( p_playlist ) == 0 )
             {
-                if( aout_MuteGet( p_playlist ) > 0 )
+                float vol = aout_VolumeGet( p_playlist );
+                if( aout_MuteGet( p_playlist ) > 0 || vol == 0.f )
                 {
                     ClearChannels( p_intf, p_vout );
                     DisplayIcon( p_vout, OSD_MUTE_ICON );
                 }
                 else
-                {
-                    audio_volume_t i_vol = aout_VolumeGet( p_playlist );
-                    DisplayVolume( p_intf, p_vout, i_vol );
-                }
+                    DisplayVolume( p_intf, p_vout, vol );
             }
             break;
 
@@ -1013,21 +1011,17 @@ static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
 }
 
 static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
-                           audio_volume_t i_vol )
+                           float vol )
 {
     if( p_vout == NULL )
-    {
         return;
-    }
     ClearChannels( p_intf, p_vout );
 
     if( var_GetBool( p_vout, "fullscreen" ) )
-    {
-        vout_OSDSlider( p_vout, VOLUME_WIDGET_CHAN,
-            i_vol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );
-    }
-    DisplayMessage( p_vout, VOLUME_TEXT_CHAN, _( "Volume %d%%" ),
-                    i_vol*100/AOUT_VOLUME_DEFAULT );
+        vout_OSDSlider( p_vout, VOLUME_WIDGET_CHAN, lround(vol * 100.),
+                        OSD_VERT_SLIDER );
+    DisplayMessage( p_vout, VOLUME_TEXT_CHAN, _( "Volume %ld%%" ),
+                    lround(vol * 100.) );
 }
 
 static void DisplayRate( vout_thread_t *p_vout, float f_rate )
index d7db6527a26772f041203684bdfda09c1b5b0480..b28be4ebf6036063998726a46b08b883ea646fd6 100644 (file)
@@ -36,6 +36,7 @@
 #include <errno.h>                                                 /* ENOMEM */
 #include <signal.h>
 #include <assert.h>
+#include <math.h>
 
 #include <vlc_interface.h>
 #include <vlc_aout_intf.h>
@@ -1497,8 +1498,9 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
     if ( *newval.psz_string )
     {
         /* Set. */
-        audio_volume_t i_volume = atoi( newval.psz_string );
-        if( !aout_VolumeSet( p_playlist, i_volume ) )
+        int i_volume = atoi( newval.psz_string );
+        if( !aout_VolumeSet( p_playlist,
+                             i_volume / (float)AOUT_VOLUME_DEFAULT ) )
             i_error = VLC_SUCCESS;
         aout_MuteSet( p_playlist, i_volume == 0 );
         osd_Volume( p_this );
@@ -1507,8 +1509,8 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
     else
     {
         /* Get. */
-        audio_volume_t i_volume = aout_VolumeGet( p_playlist );
-        msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
+        msg_rc( STATUS_CHANGE "( audio volume: %ld )",
+               lroundf( aout_VolumeGet( p_playlist ) * AOUT_VOLUME_DEFAULT ) );
         i_error = VLC_SUCCESS;
     }
 
@@ -1520,7 +1522,7 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
 {
     VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
-    audio_volume_t i_volume;
+    float volume;
     input_thread_t *p_input =
         playlist_CurrentInput( p_intf->p_sys->p_playlist );
     int i_nb_steps = atoi(newval.psz_string);
@@ -1539,11 +1541,13 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
 
     if( !strcmp(psz_cmd, "voldown") )
         i_nb_steps *= -1;
-    if( aout_VolumeUp( p_intf->p_sys->p_playlist, i_nb_steps, &i_volume ) < 0 )
+    if( aout_VolumeUp( p_intf->p_sys->p_playlist, i_nb_steps, &volume ) < 0 )
         i_error = VLC_EGENERIC;
     osd_Volume( p_this );
 
-    if ( !i_error ) msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
+    if ( !i_error )
+        msg_rc( STATUS_CHANGE "( audio volume: %ld )",
+                lroundf( volume * AOUT_VOLUME_DEFAULT ) );
     return i_error;
 }
 
index c9144bf8869c209099890f57354e7a8d08358ada..8a88e79bb109f7db07190b6eaf34f6b247cd7bb8 100644 (file)
@@ -25,6 +25,7 @@
 #import "intf.h"
 #import "open.h"
 #import "playlist.h"
+#import <math.h>
 #import <vlc_playlist.h>
 #import <vlc_input.h>
 #import <vlc_keys.h>
@@ -515,9 +516,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
     if( !p_intf )
         return 0;
 
-    audio_volume_t i_volume = aout_VolumeGet( pl_Get( p_intf ) );
+    float volume = aout_VolumeGet( pl_Get( p_intf ) );
 
-    return (int)i_volume;
+    return lroundf(volume * AOUT_VOLUME_DEFAULT);
 }
 
 - (void)setVolume: (int)i_value
@@ -526,7 +527,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
     if( !p_intf )
         return;
 
-    aout_VolumeSet( pl_Get( p_intf ), i_value );
+    aout_VolumeSet( pl_Get( p_intf ), i_value / (float)AOUT_VOLUME_DEFAULT );
 }
 
 #pragma mark -
index 61f0fa05e0af6fec431aa15c40a76840b0c1e8df..98a0ba8c7dab395be23a1c4f443e9a7aa886986d 100644 (file)
@@ -34,6 +34,7 @@
 #import "controls.h" // TODO: remove me
 #import "playlist.h"
 #import "SideBarItem.h"
+#import <math.h>
 #import <vlc_playlist.h>
 #import <vlc_aout_intf.h>
 #import <vlc_url.h>
@@ -1515,10 +1516,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (void)updateVolumeSlider
 {
-    audio_volume_t i_volume;
     playlist_t * p_playlist = pl_Get( VLCIntf );
-
-    i_volume = aout_VolumeGet( p_playlist );
+    int i_volume = lroundf(aout_VolumeGet( p_playlist ) * AOUT_VOLUME_DEFAULT);
     BOOL b_muted = [[VLCCoreInteraction sharedInstance] isMuted];
 
     if( !b_muted )
index bf082e1dcf22a8e757c58dbfc38369bd6dc9f12e..a20ad50df4ac933d553e8b20fdd9181a762ad663 100644 (file)
@@ -39,6 +39,7 @@
 #include <assert.h>
 #include <wchar.h>
 #include <sys/stat.h>
+#include <math.h>
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -1068,7 +1069,7 @@ static int DrawStatus(intf_thread_t *intf)
             };
             char buf1[MSTRTIME_MAX_SIZE];
             char buf2[MSTRTIME_MAX_SIZE];
-            unsigned i_volume;
+            float volume;
 
         case INIT_S:
         case END_S:
@@ -1089,9 +1090,13 @@ static int DrawStatus(intf_thread_t *intf)
 
             mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2);
 
-            i_volume = aout_VolumeGet(p_playlist);
-            mvnprintw(y++, 0, COLS, _(" Volume   : %u%%"),
-                      i_volume*100/AOUT_VOLUME_DEFAULT);
+            volume = aout_VolumeGet(p_playlist);
+            if (volume >= 0.f)
+                mvnprintw(y++, 0, COLS, _(" Volume   : %3ld%%"),
+                          lroundf(volume * 100.f));
+            else
+                mvnprintw(y++, 0, COLS, _(" Volume   : ----"),
+                          lroundf(volume * 100.f));
 
             if (!var_Get(p_input, "title", &val)) {
                 int i_title_count = var_CountChoices(p_input, "title");
index f0df35353793f73cd40be3ea2c0235a845bd532f..bdd154a9fe5c9efe21eb0bd01a0478bd7cfcbc83 100644 (file)
@@ -31,6 +31,7 @@
 #include "input_manager.hpp"         /* Get notification of Volume Change */
 #include "util/input_slider.hpp"     /* SoundSlider */
 
+#include <math.h>
 #include <vlc_aout_intf.h>           /* Volume functions */
 
 #include <QLabel>
@@ -151,8 +152,7 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
     /* Only if volume is set by user action on slider */
     setMuted( false );
     playlist_t *p_playlist = pl_Get( p_intf );
-    int i_res = i_sliderVolume * (AOUT_VOLUME_DEFAULT * 2) / VOLUME_MAX;
-    aout_VolumeSet( p_playlist, i_res );
+    aout_VolumeSet( p_playlist, i_sliderVolume / 100.f );
     refreshLabels();
 }
 
@@ -160,11 +160,8 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
 void SoundWidget::libUpdateVolume()
 {
     /* Audio part */
-    audio_volume_t i_volume;
     playlist_t *p_playlist = pl_Get( p_intf );
-
-    i_volume = aout_VolumeGet( p_playlist );
-    i_volume = (i_volume * VOLUME_MAX ) / (AOUT_VOLUME_DEFAULT * 2);
+    long i_volume = lroundf(aout_VolumeGet( p_playlist ) * 100.f);
 
     if ( i_volume - volumeSlider->value() != 0 )
     {
index 119b095773dc3f7ea65d69cf660b9e2cb4101bd6..504514e61049676fd3ade80a7cfb584cc96d2606 100644 (file)
@@ -693,7 +693,7 @@ void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
     (void)p_obj; (void)newVal;
     playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
 
-    audio_volume_t volume = aout_VolumeGet( pPlaylist );
+    float volume = aout_VolumeGet( pPlaylist ) * 100.f;
     SET_VOLUME( m_cVarVolume, volume, false );
     bool b_is_muted = aout_MuteGet( pPlaylist ) > 0;
     SET_BOOL( m_cVarMute, b_is_muted );
@@ -798,7 +798,7 @@ void VlcProc::init_variables()
     SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
     SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
 
-    audio_volume_t volume = aout_VolumeGet( pPlaylist );
+    float volume = aout_VolumeGet( pPlaylist ) * 100.f;
     SET_VOLUME( m_cVarVolume, volume, false );
     bool b_is_muted = aout_MuteGet( pPlaylist ) > 0;
     SET_BOOL( m_cVarMute, b_is_muted );
index 8d01619254350bba44782317fc42d43045c6a103..2dafb4bae1bc26d4df12ad07272990d939413e94 100644 (file)
@@ -38,7 +38,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
     m_volumeMax = AOUT_VOLUME_DEFAULT * 2;
 
     // Initial value
-    audio_volume_t val = aout_VolumeGet( getIntf()->p_sys->p_playlist );
+    float val = aout_VolumeGet( getIntf()->p_sys->p_playlist ) * 100.f;
     set( val, false );
 }
 
index bae1534149e5fbc931b35128ec4349102f34d5cc..36c2859a4ab1f94a1dbc992dfe70253e53f55bb2 100644 (file)
@@ -33,6 +33,7 @@
 # include "config.h"
 #endif
 
+#include <math.h>
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_meta.h>
 static int vlclua_volume_set( lua_State *L )
 {
     playlist_t *p_this = vlclua_get_playlist_internal( L );
-    int i_volume = VLC_CLIP( luaL_checkint( L, 1 ), 0, AOUT_VOLUME_MAX );
-    int i_ret = aout_VolumeSet( p_this, i_volume );
+    int i_volume = luaL_checkint( L, 1 );
+    if( i_volume < 0 )
+        i_volume = 0;
+    int i_ret = aout_VolumeSet( p_this, i_volume/(float)AOUT_VOLUME_DEFAULT );
     return vlclua_push_ret( L, i_ret );
 }
 
 static int vlclua_volume_get( lua_State *L )
 {
     playlist_t *p_this = vlclua_get_playlist_internal( L );
-    audio_volume_t i_volume = aout_VolumeGet( p_this );
+    long i_volume = lroundf(aout_VolumeGet( p_this ) * AOUT_VOLUME_DEFAULT);
     lua_pushnumber( L, i_volume );
     return 1;
 }
 
 static int vlclua_volume_up( lua_State *L )
 {
-    audio_volume_t i_volume;
     playlist_t *p_this = vlclua_get_playlist_internal( L );
-    aout_VolumeUp( p_this, luaL_optint( L, 1, 1 ), &i_volume );
-    lua_pushnumber( L, i_volume );
+    float volume;
+
+    aout_VolumeUp( p_this, luaL_optint( L, 1, 1 ), &volume );
+    lua_pushnumber( L, lroundf(volume * AOUT_VOLUME_DEFAULT) );
     return 1;
 }
 
 static int vlclua_volume_down( lua_State *L )
 {
-    audio_volume_t i_volume;
     playlist_t *p_this = vlclua_get_playlist_internal( L );
-    aout_VolumeDown( p_this, luaL_optint( L, 1, 1 ), &i_volume );
-    lua_pushnumber( L, i_volume );
+    float volume;
+
+    aout_VolumeDown( p_this, luaL_optint( L, 1, 1 ), &volume );
+    lua_pushnumber( L, lroundf(volume * AOUT_VOLUME_DEFAULT) );
     return 1;
 }
 
index 044618e00fb1c65d3672903fd96991856b0d4a63..18c654ebd1b506ac826f70b6c6cfa00b9562e283 100644 (file)
@@ -127,15 +127,17 @@ static void cancelVolume (vlc_object_t *obj, audio_output_t *aout)
 #undef aout_VolumeGet
 /**
  * Gets the volume of the output device (independent of mute).
+ * \return Current audio volume (0 = silent, 1 = nominal),
+ * or a strictly negative value if undefined.
  */
-audio_volume_t aout_VolumeGet (vlc_object_t *obj)
+float aout_VolumeGet (vlc_object_t *obj)
 {
     audio_output_t *aout;
     float vol;
 
     prepareVolume (obj, &aout, &vol, NULL);
     cancelVolume (obj, aout);
-    return lroundf (vol * AOUT_VOLUME_DEFAULT);
+    return vol;
 }
 
 #undef aout_VolumeSet
@@ -143,10 +145,9 @@ audio_volume_t aout_VolumeGet (vlc_object_t *obj)
  * Sets the volume of the output device.
  * The mute status is not changed.
  */
-int aout_VolumeSet (vlc_object_t *obj, audio_volume_t volume)
+int aout_VolumeSet (vlc_object_t *obj, float vol)
 {
     audio_output_t *aout;
-    float vol = volume / (float)AOUT_VOLUME_DEFAULT;
     bool mute;
 
     prepareVolume (obj, &aout, NULL, &mute);
@@ -159,7 +160,7 @@ int aout_VolumeSet (vlc_object_t *obj, audio_volume_t volume)
  * \param value how much to increase (> 0) or decrease (< 0) the volume
  * \param volp if non-NULL, will contain contain the resulting volume
  */
-int aout_VolumeUp (vlc_object_t *obj, int value, audio_volume_t *volp)
+int aout_VolumeUp (vlc_object_t *obj, int value, float *volp)
 {
     audio_output_t *aout;
     int ret;
@@ -176,7 +177,7 @@ int aout_VolumeUp (vlc_object_t *obj, int value, audio_volume_t *volp)
         vol = AOUT_VOLUME_MAX / AOUT_VOLUME_DEFAULT;
     ret = commitVolume (obj, aout, vol, mute);
     if (volp != NULL)
-        *volp = lroundf (vol * AOUT_VOLUME_DEFAULT);
+        *volp = vol;
     return ret;
 }
 
index 5bf285c347cbf2ce2b8fbe256e71dd3ecbfb85ac..63793d27b74cc338d0bc315442670dc8478bdb54 100644 (file)
@@ -91,7 +91,7 @@ static void aout_OutputTimeReport (audio_output_t *aout, mtime_t ideal)
  */
 static void aout_OutputVolumeReport (audio_output_t *aout, float volume)
 {
-    audio_volume_t vol = lroundf (volume * (float)AOUT_VOLUME_DEFAULT);
+    long vol = lroundf (volume * (float)AOUT_VOLUME_DEFAULT);
 
     /* We cannot acquire the volume lock as this gets called from the audio
      * output plug-in (it would cause a lock inversion). */
@@ -365,7 +365,7 @@ static int aout_VolumeSoftSet (audio_output_t *aout, float volume, bool mute)
  */
 void aout_VolumeSoftInit (audio_output_t *aout)
 {
-    audio_volume_t volume = var_GetInteger (aout, "volume");
+    long volume = var_GetInteger (aout, "volume");
     bool mute = var_GetBool (aout, "mute");
 
     aout_assert_locked (aout);
index dc7d1f7a854f822142199183da3417c69d52bc99..d5268d6bc0f502d519a8de917e1063bb39835682 100644 (file)
@@ -37,6 +37,7 @@
 /* Needed by str_format_time */
 #include <time.h>
 #include <limits.h>
+#include <math.h>
 
 /* Needed by str_format_meta */
 #include <vlc_input.h>
@@ -889,12 +890,18 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
                     }
                     break;
                 case 'V':
+                {
+                    float vol = aout_VolumeGet( p_object );
+                    if( vol >= 0. )
                     {
-                        audio_volume_t volume = aout_VolumeGet( p_object );
-                        snprintf( buf, 10, "%d", volume );
+                        snprintf( buf, 10, "%ld",
+                                  lroundf(vol * AOUT_VOLUME_DEFAULT ) );
                         INSERT_STRING_NO_FREE( buf );
-                        break;
                     }
+                    else
+                         INSERT_STRING_NO_FREE( "---" );
+                    break;
+                }
                 case '_':
                     *(dst+d) = '\n';
                     d++;