[vlc-commits] skins2: update following volume change from Integer to float
Erwan Tulou
git at videolan.org
Sat Jul 21 20:15:30 CEST 2012
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sat Jul 21 20:05:56 2012 +0200| [c90fcbb316574c960d6ec1c6f59c5bbcd80d5400] | committer: Erwan Tulou
skins2: update following volume change from Integer to float
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c90fcbb316574c960d6ec1c6f59c5bbcd80d5400
---
modules/gui/skins2/src/vlcproc.cpp | 8 +++-----
modules/gui/skins2/vars/volume.cpp | 15 ++++++++-------
modules/gui/skins2/vars/volume.hpp | 4 +---
3 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index 36b557b..7867a9a 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -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 );
diff --git a/modules/gui/skins2/vars/volume.cpp b/modules/gui/skins2/vars/volume.cpp
index baf417a..e3910ac 100644
--- a/modules/gui/skins2/vars/volume.cpp
+++ b/modules/gui/skins2/vars/volume.cpp
@@ -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;
}
diff --git a/modules/gui/skins2/vars/volume.hpp b/modules/gui/skins2/vars/volume.hpp
index 3651d71..e4a1d94 100644
--- a/modules/gui/skins2/vars/volume.hpp
+++ b/modules/gui/skins2/vars/volume.hpp
@@ -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; }
More information about the vlc-commits
mailing list