[vlc-commits] Qt4: simplify and partly fix mute tracking
Rémi Denis-Courmont
git at videolan.org
Tue Jul 3 17:04:17 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 3 17:42:56 2012 +0300| [b092d34b5912504ea8653b106c4ec02ca9f45978] | committer: Rémi Denis-Courmont
Qt4: simplify and partly fix mute tracking
This fixes a race between requesting mute and the aout actually muting.
There are still at least two known bugs with the mute widget:
- Qt tries to sets the LibVLC status when LibVLC status changes
(there is a hack around this for volume but not for mute).
- Qt tracks the playlist "mute" variable instead of the aout one.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b092d34b5912504ea8653b106c4ec02ca9f45978
---
modules/gui/qt4/components/controller_widget.cpp | 14 +++++++-------
modules/gui/qt4/components/controller_widget.hpp | 2 +-
modules/gui/qt4/input_manager.cpp | 22 +++++-----------------
modules/gui/qt4/input_manager.hpp | 5 +++--
4 files changed, 16 insertions(+), 27 deletions(-)
diff --git a/modules/gui/qt4/components/controller_widget.cpp b/modules/gui/qt4/components/controller_widget.cpp
index bdd154a..90b36a1 100644
--- a/modules/gui/qt4/components/controller_widget.cpp
+++ b/modules/gui/qt4/components/controller_widget.cpp
@@ -110,15 +110,16 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
/* Set the volume from the config */
libUpdateVolume();
- /* Force the update at build time in order to have a muted icon if needed */
- updateMuteStatus();
+ /* Sync mute status */
+ if( aout_MuteGet( THEPL ) > 0 )
+ updateMuteStatus( true );
/* Volume control connection */
volumeSlider->setTracking( true );
CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) );
CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) );
CONNECT( THEMIM, volumeChanged( void ), this, libUpdateVolume( void ) );
- CONNECT( THEMIM, soundMuteChanged( void ), this, updateMuteStatus( void ) );
+ CONNECT( THEMIM, soundMuteChanged( bool ), this, updateMuteStatus( bool ) );
}
SoundWidget::~SoundWidget()
@@ -179,14 +180,13 @@ void SoundWidget::valueChangedFilter( int i_val )
}
/* libvlc mute/unmute event slot */
-void SoundWidget::updateMuteStatus()
+void SoundWidget::updateMuteStatus( bool mute )
{
- playlist_t *p_playlist = pl_Get( p_intf );
- b_is_muted = aout_MuteGet( p_playlist ) > 0;
+ b_is_muted = mute;
SoundSlider *soundSlider = qobject_cast<SoundSlider *>(volumeSlider);
if( soundSlider )
- soundSlider->setMuted( b_is_muted );
+ soundSlider->setMuted( mute );
refreshLabels();
}
diff --git a/modules/gui/qt4/components/controller_widget.hpp b/modules/gui/qt4/components/controller_widget.hpp
index fa13ee0..49de57b 100644
--- a/modules/gui/qt4/components/controller_widget.hpp
+++ b/modules/gui/qt4/components/controller_widget.hpp
@@ -118,7 +118,7 @@ private:
protected slots:
void userUpdateVolume( int );
void libUpdateVolume( void );
- void updateMuteStatus( void );
+ void updateMuteStatus( bool );
void refreshLabels( void );
void showVolumeMenu( QPoint pos );
void valueChangedFilter( int );
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index b4ec7ef..bfeafce 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -53,8 +53,6 @@ static int PLItemRemoved( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int VolumeChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
-static int SoundMuteChanged( vlc_object_t *, const char *,
- vlc_value_t, vlc_value_t, void * );
static int InputEvent( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
@@ -946,7 +944,8 @@ void InputManager::AtoBLoop( float, int64_t i_time, int )
MainInputManager::MainInputManager( intf_thread_t *_p_intf )
: QObject(NULL), p_intf( _p_intf ),
random( VLC_OBJECT(THEPL), "random" ),
- repeat( VLC_OBJECT(THEPL), "repeat" ), loop( VLC_OBJECT(THEPL), "loop" )
+ repeat( VLC_OBJECT(THEPL), "repeat" ), loop( VLC_OBJECT(THEPL), "loop" ),
+ mute( VLC_OBJECT(THEPL), "mute" )
{
p_input = NULL;
im = new InputManager( this, p_intf );
@@ -962,7 +961,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
var_AddCallback( THEPL, "volume", VolumeChanged, this );
- var_AddCallback( THEPL, "mute", SoundMuteChanged, this );
+ mute.addCallback( this, SLOT(notifyMute(bool)) );
/* Warn our embedded IM about input changes */
DCONNECT( this, inputChanged( input_thread_t * ),
@@ -988,7 +987,6 @@ MainInputManager::~MainInputManager()
}
var_DelCallback( THEPL, "volume", VolumeChanged, this );
- var_DelCallback( THEPL, "mute", SoundMuteChanged, this );
var_DelCallback( THEPL, "activity", PLItemChanged, this );
var_DelCallback( THEPL, "item-change", ItemChanged, im );
@@ -1021,9 +1019,6 @@ void MainInputManager::customEvent( QEvent *event )
case VolumeChanged_Type:
emit volumeChanged();
return;
- case SoundMuteChanged_Type:
- emit soundMuteChanged();
- return;
case PLItemAppended_Type:
plEv = static_cast<PLEvent*>( event );
emit playlistItemAppended( plEv->i_item, plEv->i_parent );
@@ -1241,16 +1236,9 @@ static int VolumeChanged( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS;
}
-static int SoundMuteChanged( vlc_object_t *p_this, const char *psz_var,
- vlc_value_t oldval, vlc_value_t newval, void *param )
+void MainInputManager::notifyMute( bool mute )
{
- VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( newval );
-
- MainInputManager *mim = (MainInputManager*)param;
-
- IMEvent *event = new IMEvent( SoundMuteChanged_Type );
- QApplication::postEvent( mim, event );
- return VLC_SUCCESS;
+ emit soundMuteChanged(mute);
}
static int PLItemAppended
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index b7dabdd..31165a2 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -46,7 +46,6 @@ enum {
ItemTitleChanged_Type,
ItemRateChanged_Type,
VolumeChanged_Type,
- SoundMuteChanged_Type,
ItemEsChanged_Type,
ItemTeletextChanged_Type,
InterfaceVoutUpdate_Type,
@@ -277,6 +276,7 @@ private:
input_thread_t *p_input;
intf_thread_t *p_intf;
QVLCBool random, repeat, loop;
+ QVLCBool mute;
public slots:
void togglePlayPause();
@@ -293,10 +293,11 @@ public slots:
private slots:
void notifyRandom( bool );
void notifyRepeatLoop( bool );
+ void notifyMute( bool );
signals:
void inputChanged( input_thread_t * );
void volumeChanged();
- void soundMuteChanged();
+ void soundMuteChanged(bool);
void playlistItemAppended( int itemId, int parentId );
void playlistItemRemoved( int itemId );
void playlistNotEmpty( bool );
More information about the vlc-commits
mailing list