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,
/* 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();
}
......
......@@ -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 );
......
......@@ -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
......
......@@ -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 );
......
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