]> git.sesse.net Git - vlc/commitdiff
skins2: update following volume change from Integer to float
authorErwan Tulou <erwan10@videolan.org>
Sat, 21 Jul 2012 18:05:56 +0000 (20:05 +0200)
committerErwan Tulou <erwan10@videolan.org>
Sat, 21 Jul 2012 18:12:39 +0000 (20:12 +0200)
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/vars/volume.cpp
modules/gui/skins2/vars/volume.hpp

index 36b557bea3101b43bdec9f74edde2ff1630b7bf1..7867a9a1180b4fa401fb4d53abee5e34a3191b9c 100644 (file)
@@ -79,7 +79,7 @@ void VlcProc::destroy( intf_thread_t *pIntf )
 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
 #define SET_TEXT(m,v)         ((VarText*)(m).get())->set(v)
 #define SET_STRING(m,v)       ((VarString*)(m).get())->set(v)
-#define SET_VOLUME(m,v,b)     ((Volume*)(m).get())->set(v,b)
+#define SET_VOLUME(m,v,b)     ((Volume*)(m).get())->setVolume(v,b)
 
 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL ),
@@ -693,8 +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;
 
-    int volume = var_GetInteger( pPlaylist, "volume" );
-    SET_VOLUME( m_cVarVolume, volume, false );
+    SET_VOLUME( m_cVarVolume, var_GetFloat( pPlaylist, "volume" ), false );
     bool b_is_muted = aout_MuteGet( pPlaylist ) > 0;
     SET_BOOL( m_cVarMute, b_is_muted );
 }
@@ -798,8 +797,7 @@ void VlcProc::init_variables()
     SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
     SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
 
-    int volume = var_GetInteger( pPlaylist, "volume" );
-    SET_VOLUME( m_cVarVolume, volume, false );
+    SET_VOLUME( m_cVarVolume, var_GetFloat( pPlaylist, "volume" ), false );
     bool b_is_muted = aout_MuteGet( pPlaylist ) > 0;
     SET_BOOL( m_cVarMute, b_is_muted );
 
index baf417a7a0ff872b4f7fb206df78feb2198e2c85..e3910ac91143896740a76d4fd339e571ffd2af85 100644 (file)
@@ -41,8 +41,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
 
     // set current volume from the playlist
     playlist_t* pPlaylist = pIntf->p_sys->p_playlist;
-    int volume = var_GetInteger( pPlaylist, "volume" );
-    set( volume, false );
+    setVolume( var_GetFloat( pPlaylist, "volume" ), false );
 }
 
 
@@ -57,18 +56,20 @@ void Volume::set( float percentage, bool updateVLC )
 }
 
 
-void Volume::set( int volume, bool updateVLC )
+void Volume::setVolume( float volume, bool updateVLC )
 {
-    // volume is kept by the playlist in [0,AOUT_VOLUME_MAX] range
-    // this class keeps it in [0.,1.] range
-    set( (float)volume/(float)AOUT_VOLUME_MAX, updateVLC );
+    // translate from [0.,AOUT_VOLUME_MAX/AOUT_VOLUME_DEFAULT] into [0.,1.]
+    float percentage = (volume > 0.f ) ?
+                       volume * AOUT_VOLUME_DEFAULT / AOUT_VOLUME_MAX :
+                       0.f;
+    set( percentage, updateVLC );
 }
 
 
 float Volume::getVolume() const
 {
     // translate from [0.,1.] into [0.,AOUT_VOLUME_MAX/AOUT_VOLUME_DEFAULT]
-    return get() * AOUT_VOLUME_MAX/AOUT_VOLUME_DEFAULT;
+    return get() * AOUT_VOLUME_MAX / AOUT_VOLUME_DEFAULT;
 }
 
 
index 3651d7171be52dda7caa803bd89cf2f521aa6d5e..e4a1d942deff3e5b0dc7b885a1a232cfaa5b022c 100644 (file)
@@ -38,12 +38,10 @@ public:
     virtual ~Volume() { }
 
     virtual void set( float percentage, bool updateVLC );
-
-    virtual void set( int volume, bool updateVLC );
-
     virtual void set( float percentage ) { set( percentage, true ); }
 
     virtual float getVolume() const;
+    virtual void setVolume( float volume, bool updateVLC );
 
     virtual float getStep() const { return m_step; }