Commit c90fcbb3 authored by Erwan Tulou's avatar Erwan Tulou

skins2: update following volume change from Integer to float

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