[vlc-commits] playlist: convert "volume" to float
Rémi Denis-Courmont
git at videolan.org
Sat Jul 21 16:40:58 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jul 21 17:36:08 2012 +0300| [9778203f762a90e96f7b04b24bfe90c8c251b860] | committer: Rémi Denis-Courmont
playlist: convert "volume" to float
...and simplify accordingly.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9778203f762a90e96f7b04b24bfe90c8c251b860
---
lib/media_player.c | 2 +-
modules/control/rc.c | 3 ++-
modules/gui/qt4/input_manager.cpp | 6 +++---
modules/gui/qt4/input_manager.hpp | 4 ++--
src/audio_output/common.c | 15 +++------------
src/playlist/engine.c | 3 ++-
6 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/lib/media_player.c b/lib/media_player.c
index 967593e..f30f184 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -465,7 +465,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
/* Audio */
var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
var_Create (mp, "mute", VLC_VAR_BOOL);
- var_Create (mp, "volume", VLC_VAR_INTEGER);
+ var_Create (mp, "volume", VLC_VAR_FLOAT);
var_Create (mp, "find-input-callback", VLC_VAR_ADDRESS);
var_SetAddress (mp, "find-input-callback", find_input);
var_Create (mp, "amem-data", VLC_VAR_ADDRESS);
diff --git a/modules/control/rc.c b/modules/control/rc.c
index f9688f8..efa2db4 100644
--- a/modules/control/rc.c
+++ b/modules/control/rc.c
@@ -902,7 +902,8 @@ static int VolumeChanged( vlc_object_t *p_this, char const *psz_cmd,
intf_thread_t *p_intf = (intf_thread_t*)p_data;
vlc_mutex_lock( &p_intf->p_sys->status_lock );
- msg_rc( STATUS_CHANGE "( audio volume: %"PRId64" )", newval.i_int );
+ msg_rc( STATUS_CHANGE "( audio volume: %ld )",
+ lroundf(newval.f_float * AOUT_VOLUME_DEFAULT) );
vlc_mutex_unlock( &p_intf->p_sys->status_lock );
return VLC_SUCCESS;
}
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 83a722e..6de8c16 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -958,7 +958,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
repeat.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
- volume.addCallback( this, SLOT(notifyVolume(qlonglong)) );
+ volume.addCallback( this, SLOT(notifyVolume(float)) );
mute.addCallback( this, SLOT(notifyMute(bool)) );
/* Warn our embedded IM about input changes */
@@ -1217,9 +1217,9 @@ static int LeafToParent( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS;
}
-void MainInputManager::notifyVolume( qlonglong volume )
+void MainInputManager::notifyVolume( float volume )
{
- emit volumeChanged( volume / (float)AOUT_VOLUME_DEFAULT );
+ emit volumeChanged( volume );
}
void MainInputManager::notifyMute( bool mute )
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index dd857a0..f234d48 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -274,7 +274,7 @@ private:
input_thread_t *p_input;
intf_thread_t *p_intf;
QVLCBool random, repeat, loop;
- QVLCInteger volume;
+ QVLCFloat volume;
QVLCBool mute;
public slots:
@@ -292,7 +292,7 @@ public slots:
private slots:
void notifyRandom( bool );
void notifyRepeatLoop( bool );
- void notifyVolume( qlonglong );
+ void notifyVolume( float );
void notifyMute( bool );
signals:
void inputChanged( input_thread_t * );
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 803a449..5c2394e 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -55,16 +55,6 @@ static int var_Copy (vlc_object_t *src, const char *name, vlc_value_t prev,
return var_Set (dst, name, value);
}
-static int var_CopyVolume (vlc_object_t *src, const char *name,
- vlc_value_t prev, vlc_value_t value, void *data)
-{
- vlc_object_t *dst = data;
- long volume = lroundf (value.f_float * (float)AOUT_VOLUME_DEFAULT);
-
- (void) src; (void) prev;
- return var_SetInteger (dst, name, volume);
-}
-
#undef aout_New
/*****************************************************************************
* aout_New: initialize aout structure
@@ -95,7 +85,7 @@ audio_output_t *aout_New( vlc_object_t * p_parent )
char *str;
var_Create (aout, "volume", VLC_VAR_FLOAT);
- var_AddCallback (aout, "volume", var_CopyVolume, p_parent);
+ var_AddCallback (aout, "volume", var_Copy, p_parent);
var_Create (aout, "mute", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
var_AddCallback (aout, "mute", var_Copy, p_parent);
@@ -206,7 +196,8 @@ void aout_Destroy (audio_output_t *aout)
aout_Shutdown (aout);
var_DelCallback (aout, "mute", var_Copy, aout->p_parent);
- var_DelCallback (aout, "volume", var_CopyVolume, aout->p_parent);
+ var_SetFloat (aout, "volume", -1.f);
+ var_DelCallback (aout, "volume", var_Copy, aout->p_parent);
vlc_object_release (aout);
}
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index aa418ad..6038375 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -437,7 +437,8 @@ static void VariablesInit( playlist_t *p_playlist )
/* Audio output parameters */
var_Create( p_playlist, "mute", VLC_VAR_BOOL );
- var_Create( p_playlist, "volume", VLC_VAR_INTEGER );
+ var_Create( p_playlist, "volume", VLC_VAR_FLOAT );
+ var_SetFloat( p_playlist, "volume", -1.f );
/* FIXME: horrible hack for audio output interface code */
var_Create( p_playlist, "find-input-callback", VLC_VAR_ADDRESS );
var_SetAddress( p_playlist, "find-input-callback", playlist_FindInput );
More information about the vlc-commits
mailing list