diff --git a/modules/gui/qt4/components/controller_widget.cpp b/modules/gui/qt4/components/controller_widget.cpp index 90b36a1efa4141ce34a888134a671cd0546b6841..a6bfc9e20be1b1cb487a620197e3cdc3e0f0f629 100644 --- a/modules/gui/qt4/components/controller_widget.cpp +++ b/modules/gui/qt4/components/controller_widget.cpp @@ -109,7 +109,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, layout->addWidget( volumeSlider, 0, Qt::AlignBottom ); /* Set the volume from the config */ - libUpdateVolume(); + float volume = aout_VolumeGet( THEPL ); + libUpdateVolume( (volume >= 0.f) ? volume : 1.f ); /* Sync mute status */ if( aout_MuteGet( THEPL ) > 0 ) updateMuteStatus( true ); @@ -118,7 +119,7 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, 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, volumeChanged( float ), this, libUpdateVolume( float ) ); CONNECT( THEMIM, soundMuteChanged( bool ), this, updateMuteStatus( bool ) ); } @@ -152,19 +153,15 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume ) { /* Only if volume is set by user action on slider */ setMuted( false ); - playlist_t *p_playlist = pl_Get( p_intf ); - aout_VolumeSet( p_playlist, i_sliderVolume / 100.f ); + aout_VolumeSet( THEPL, i_sliderVolume / 100.f ); refreshLabels(); } /* libvlc changed value event slot */ -void SoundWidget::libUpdateVolume() +void SoundWidget::libUpdateVolume( float volume ) { - /* Audio part */ - playlist_t *p_playlist = pl_Get( p_intf ); - long i_volume = lroundf(aout_VolumeGet( p_playlist ) * 100.f); - - if ( i_volume - volumeSlider->value() != 0 ) + long i_volume = lroundf(volume * 100.f); + if( i_volume != volumeSlider->value() ) { b_ignore_valuechanged = true; volumeSlider->setValue( i_volume ); diff --git a/modules/gui/qt4/components/controller_widget.hpp b/modules/gui/qt4/components/controller_widget.hpp index 49de57b076db3c692c0065cf0c000c60b17acb3b..48a6d96b098aa5594d75e8bbba3b3f143f90f101 100644 --- a/modules/gui/qt4/components/controller_widget.hpp +++ b/modules/gui/qt4/components/controller_widget.hpp @@ -117,7 +117,7 @@ private: protected slots: void userUpdateVolume( int ); - void libUpdateVolume( void ); + void libUpdateVolume( float ); void updateMuteStatus( bool ); void refreshLabels( void ); void showVolumeMenu( QPoint pos ); diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp index bfeafce2a9e843c98bd32b32e0ec3ad600d3475c..2cda2c9bf585ddbd5c3775df002a7d73c5d0e510 100644 --- a/modules/gui/qt4/input_manager.cpp +++ b/modules/gui/qt4/input_manager.cpp @@ -51,8 +51,6 @@ static int PLItemAppended( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ); 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 InputEvent( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ); @@ -945,7 +943,7 @@ 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" ), - mute( VLC_OBJECT(THEPL), "mute" ) + volume( VLC_OBJECT(THEPL), "volume" ), mute( VLC_OBJECT(THEPL), "mute" ) { p_input = NULL; im = new InputManager( this, p_intf ); @@ -960,7 +958,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) repeat.addCallback( this, SLOT(notifyRepeatLoop(bool)) ); loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) ); - var_AddCallback( THEPL, "volume", VolumeChanged, this ); + volume.addCallback( this, SLOT(notifyVolume(int)) ); mute.addCallback( this, SLOT(notifyMute(bool)) ); /* Warn our embedded IM about input changes */ @@ -986,8 +984,6 @@ MainInputManager::~MainInputManager() vlc_object_release( p_input ); } - var_DelCallback( THEPL, "volume", VolumeChanged, this ); - var_DelCallback( THEPL, "activity", PLItemChanged, this ); var_DelCallback( THEPL, "item-change", ItemChanged, im ); var_DelCallback( THEPL, "leaf-to-parent", LeafToParent, this ); @@ -1016,9 +1012,6 @@ void MainInputManager::customEvent( QEvent *event ) // msg_Dbg( p_intf, "New MainIM Event of type: %i", type ); switch( type ) { - case VolumeChanged_Type: - emit volumeChanged(); - return; case PLItemAppended_Type: plEv = static_cast<PLEvent*>( event ); emit playlistItemAppended( plEv->i_item, plEv->i_parent ); @@ -1224,16 +1217,9 @@ static int LeafToParent( vlc_object_t *p_this, const char *psz_var, return VLC_SUCCESS; } -static int VolumeChanged( vlc_object_t *p_this, const char *psz_var, - vlc_value_t oldval, vlc_value_t newval, void *param ) +void MainInputManager::notifyVolume( int volume ) { - VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( newval ); - - MainInputManager *mim = (MainInputManager*)param; - - IMEvent *event = new IMEvent( VolumeChanged_Type ); - QApplication::postEvent( mim, event ); - return VLC_SUCCESS; + emit volumeChanged( volume / (float)AOUT_VOLUME_DEFAULT ); } void MainInputManager::notifyMute( bool mute ) diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp index 31165a29e40946514b6e3b91eef8a39f63c1fa35..fbc99a81808db0b5f20fe254eece37701ea68e64 100644 --- a/modules/gui/qt4/input_manager.hpp +++ b/modules/gui/qt4/input_manager.hpp @@ -38,14 +38,12 @@ #include <QObject> #include <QEvent> - enum { PositionUpdate_Type = QEvent::User + IMEventType + 1, ItemChanged_Type, ItemStateChanged_Type, ItemTitleChanged_Type, ItemRateChanged_Type, - VolumeChanged_Type, ItemEsChanged_Type, ItemTeletextChanged_Type, InterfaceVoutUpdate_Type, @@ -276,6 +274,7 @@ private: input_thread_t *p_input; intf_thread_t *p_intf; QVLCBool random, repeat, loop; + QVLCInteger volume; QVLCBool mute; public slots: @@ -293,11 +292,12 @@ public slots: private slots: void notifyRandom( bool ); void notifyRepeatLoop( bool ); + void notifyVolume( int ); void notifyMute( bool ); signals: void inputChanged( input_thread_t * ); - void volumeChanged(); - void soundMuteChanged(bool); + void volumeChanged( float ); + void soundMuteChanged( bool ); void playlistItemAppended( int itemId, int parentId ); void playlistItemRemoved( int itemId ); void playlistNotEmpty( bool );