Commit b092d34b authored by Rémi Denis-Courmont's avatar 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.
parent b7797c07
...@@ -110,15 +110,16 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, ...@@ -110,15 +110,16 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
/* Set the volume from the config */ /* Set the volume from the config */
libUpdateVolume(); libUpdateVolume();
/* Force the update at build time in order to have a muted icon if needed */ /* Sync mute status */
updateMuteStatus(); if( aout_MuteGet( THEPL ) > 0 )
updateMuteStatus( true );
/* Volume control connection */ /* Volume control connection */
volumeSlider->setTracking( true ); volumeSlider->setTracking( true );
CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) ); CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) );
CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) ); CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) );
CONNECT( THEMIM, volumeChanged( void ), this, libUpdateVolume( void ) ); CONNECT( THEMIM, volumeChanged( void ), this, libUpdateVolume( void ) );
CONNECT( THEMIM, soundMuteChanged( void ), this, updateMuteStatus( void ) ); CONNECT( THEMIM, soundMuteChanged( bool ), this, updateMuteStatus( bool ) );
} }
SoundWidget::~SoundWidget() SoundWidget::~SoundWidget()
...@@ -179,14 +180,13 @@ void SoundWidget::valueChangedFilter( int i_val ) ...@@ -179,14 +180,13 @@ void SoundWidget::valueChangedFilter( int i_val )
} }
/* libvlc mute/unmute event slot */ /* libvlc mute/unmute event slot */
void SoundWidget::updateMuteStatus() void SoundWidget::updateMuteStatus( bool mute )
{ {
playlist_t *p_playlist = pl_Get( p_intf ); b_is_muted = mute;
b_is_muted = aout_MuteGet( p_playlist ) > 0;
SoundSlider *soundSlider = qobject_cast<SoundSlider *>(volumeSlider); SoundSlider *soundSlider = qobject_cast<SoundSlider *>(volumeSlider);
if( soundSlider ) if( soundSlider )
soundSlider->setMuted( b_is_muted ); soundSlider->setMuted( mute );
refreshLabels(); refreshLabels();
} }
......
...@@ -118,7 +118,7 @@ private: ...@@ -118,7 +118,7 @@ private:
protected slots: protected slots:
void userUpdateVolume( int ); void userUpdateVolume( int );
void libUpdateVolume( void ); void libUpdateVolume( void );
void updateMuteStatus( void ); void updateMuteStatus( bool );
void refreshLabels( void ); void refreshLabels( void );
void showVolumeMenu( QPoint pos ); void showVolumeMenu( QPoint pos );
void valueChangedFilter( int ); void valueChangedFilter( int );
......
...@@ -53,8 +53,6 @@ static int PLItemRemoved( vlc_object_t *, const char *, ...@@ -53,8 +53,6 @@ static int PLItemRemoved( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int VolumeChanged( vlc_object_t *, const char *, static int VolumeChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * ); 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 *, static int InputEvent( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
...@@ -946,7 +944,8 @@ void InputManager::AtoBLoop( float, int64_t i_time, int ) ...@@ -946,7 +944,8 @@ void InputManager::AtoBLoop( float, int64_t i_time, int )
MainInputManager::MainInputManager( intf_thread_t *_p_intf ) MainInputManager::MainInputManager( intf_thread_t *_p_intf )
: QObject(NULL), p_intf( _p_intf ), : QObject(NULL), p_intf( _p_intf ),
random( VLC_OBJECT(THEPL), "random" ), 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; p_input = NULL;
im = new InputManager( this, p_intf ); im = new InputManager( this, p_intf );
...@@ -962,7 +961,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) ...@@ -962,7 +961,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) ); loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
var_AddCallback( THEPL, "volume", VolumeChanged, this ); 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 */ /* Warn our embedded IM about input changes */
DCONNECT( this, inputChanged( input_thread_t * ), DCONNECT( this, inputChanged( input_thread_t * ),
...@@ -988,7 +987,6 @@ MainInputManager::~MainInputManager() ...@@ -988,7 +987,6 @@ MainInputManager::~MainInputManager()
} }
var_DelCallback( THEPL, "volume", VolumeChanged, this ); var_DelCallback( THEPL, "volume", VolumeChanged, this );
var_DelCallback( THEPL, "mute", SoundMuteChanged, this );
var_DelCallback( THEPL, "activity", PLItemChanged, this ); var_DelCallback( THEPL, "activity", PLItemChanged, this );
var_DelCallback( THEPL, "item-change", ItemChanged, im ); var_DelCallback( THEPL, "item-change", ItemChanged, im );
...@@ -1021,9 +1019,6 @@ void MainInputManager::customEvent( QEvent *event ) ...@@ -1021,9 +1019,6 @@ void MainInputManager::customEvent( QEvent *event )
case VolumeChanged_Type: case VolumeChanged_Type:
emit volumeChanged(); emit volumeChanged();
return; return;
case SoundMuteChanged_Type:
emit soundMuteChanged();
return;
case PLItemAppended_Type: case PLItemAppended_Type:
plEv = static_cast<PLEvent*>( event ); plEv = static_cast<PLEvent*>( event );
emit playlistItemAppended( plEv->i_item, plEv->i_parent ); emit playlistItemAppended( plEv->i_item, plEv->i_parent );
...@@ -1241,16 +1236,9 @@ static int VolumeChanged( vlc_object_t *p_this, const char *psz_var, ...@@ -1241,16 +1236,9 @@ static int VolumeChanged( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int SoundMuteChanged( vlc_object_t *p_this, const char *psz_var, void MainInputManager::notifyMute( bool mute )
vlc_value_t oldval, vlc_value_t newval, void *param )
{ {
VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( newval ); emit soundMuteChanged(mute);
MainInputManager *mim = (MainInputManager*)param;
IMEvent *event = new IMEvent( SoundMuteChanged_Type );
QApplication::postEvent( mim, event );
return VLC_SUCCESS;
} }
static int PLItemAppended static int PLItemAppended
......
...@@ -46,7 +46,6 @@ enum { ...@@ -46,7 +46,6 @@ enum {
ItemTitleChanged_Type, ItemTitleChanged_Type,
ItemRateChanged_Type, ItemRateChanged_Type,
VolumeChanged_Type, VolumeChanged_Type,
SoundMuteChanged_Type,
ItemEsChanged_Type, ItemEsChanged_Type,
ItemTeletextChanged_Type, ItemTeletextChanged_Type,
InterfaceVoutUpdate_Type, InterfaceVoutUpdate_Type,
...@@ -277,6 +276,7 @@ private: ...@@ -277,6 +276,7 @@ private:
input_thread_t *p_input; input_thread_t *p_input;
intf_thread_t *p_intf; intf_thread_t *p_intf;
QVLCBool random, repeat, loop; QVLCBool random, repeat, loop;
QVLCBool mute;
public slots: public slots:
void togglePlayPause(); void togglePlayPause();
...@@ -293,10 +293,11 @@ public slots: ...@@ -293,10 +293,11 @@ public slots:
private slots: private slots:
void notifyRandom( bool ); void notifyRandom( bool );
void notifyRepeatLoop( bool ); void notifyRepeatLoop( bool );
void notifyMute( bool );
signals: signals:
void inputChanged( input_thread_t * ); void inputChanged( input_thread_t * );
void volumeChanged(); void volumeChanged();
void soundMuteChanged(); void soundMuteChanged(bool);
void playlistItemAppended( int itemId, int parentId ); void playlistItemAppended( int itemId, int parentId );
void playlistItemRemoved( int itemId ); void playlistItemRemoved( int itemId );
void playlistNotEmpty( bool ); void playlistNotEmpty( bool );
......
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