]> git.sesse.net Git - vlc/commitdiff
don't poll volume-change, change volumecontrol to use signal from
authorIlkka Ollakka <ileoo@videolan.org>
Thu, 17 Jan 2008 22:08:45 +0000 (22:08 +0000)
committerIlkka Ollakka <ileoo@videolan.org>
Thu, 17 Jan 2008 22:08:45 +0000 (22:08 +0000)
maininputmanager which listens p_intf->p_libvlc "volume-change" variable
for volumechange. ref #1365

modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/input_manager.hpp
modules/gui/qt4/main_interface.cpp

index bb8f44bf65f99c036d6d9ff77ade24748debb388..7c98a09728e72f8e737c0136c6fee0643518b60f 100644 (file)
@@ -581,6 +581,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
 
     /* Volume control connection */
     CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
+    CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
 }
 
 ControlsWidget::~ControlsWidget()
@@ -655,7 +656,7 @@ void ControlsWidget::updateVolume( int i_sliderVolume )
     else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-medium.png" ) );
 }
 
-void ControlsWidget::updateOnTimer()
+void ControlsWidget::updateVolume()
 {
     /* Audio part */
     audio_volume_t i_volume;
index 66caa58a1bb48efbc489f12ca524f71ba55f21c4..1ca5f43b7bfca6776c2d1cc83c97381cd251d42a 100644 (file)
@@ -152,7 +152,6 @@ public:
     void enableVideo( bool );
 public slots:
     void setNavigation( int );
-    void updateOnTimer();
 protected:
     friend class MainInterface;
     friend class VolumeClickHandler;
@@ -176,6 +175,7 @@ private slots:
     void prev();
     void next();
     void updateVolume( int );
+    void updateVolume( void );
     void fullscreen();
     void extSettings();
     void faster();
index 409c08ec628861f55c53cc3173f3132d34006565..129d545fb3d98c249186b796d36de015e43e3266 100644 (file)
@@ -39,6 +39,8 @@ static int ItemRateChanged( vlc_object_t *, const char *,
                         vlc_value_t, vlc_value_t, void * );
 static int ItemTitleChanged( 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 * );
 
 /**********************************************************************
  * InputManager implementation
@@ -178,6 +180,16 @@ static int InputChanged( 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 )
+{
+    MainInputManager *im = (MainInputManager*)param;
+
+    IMEvent *event = new IMEvent( VolumeChanged_Type, newval.i_int );
+    QApplication::postEvent( im, static_cast<QEvent*>(event) );
+    return VLC_SUCCESS;
+}
+
 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *param )
 {
@@ -329,11 +341,6 @@ void InputManager::UpdateMeta( void )
 
 }
 
-void InputManager::update()
-{
-
-}
-
 void InputManager::sliderUpdate( float new_pos )
 {
     if( hasInput() ) var_SetFloat( p_input, "position", new_pos );
@@ -464,6 +471,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) : QObject(NULL),
     im = new InputManager( this, p_intf );
     var_AddCallback( THEPL, "playlist-current", InputChanged, this );
     var_AddCallback( THEPL, "activity", InputChanged, this );
+    var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
     /* Warn our embedded IM about input changes */
     CONNECT( this, inputChanged( input_thread_t * ),
              im,   setInput( input_thread_t * ) );
@@ -476,6 +484,7 @@ MainInputManager::~MainInputManager()
        vlc_object_release( p_input );
        emit inputChanged( NULL );
     }
+    var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
     var_DelCallback( THEPL, "playlist-current", InputChanged, this );
     var_DelCallback( THEPL, "activity", InputChanged, this );
 }
@@ -483,8 +492,14 @@ MainInputManager::~MainInputManager()
 void MainInputManager::customEvent( QEvent *event )
 {
     int type = event->type();
-    if ( type != ItemChanged_Type )
+    if ( type != ItemChanged_Type && type != VolumeChanged_Type )
+        return;
+
+    if( type == VolumeChanged_Type )
+    {
+        emit volumeChanged();
         return;
+    }
     
     if( VLC_OBJECT_INTF == p_intf->i_object_type )
     {
@@ -551,6 +566,8 @@ void MainInputManager::togglePlayPause()
     getIM()->togglePlayPause();
 }
 
+
+
 static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o,
                         vlc_value_t n, void *param )
 {
@@ -566,3 +583,4 @@ static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o,
     im->b_has_video = true;
     return VLC_SUCCESS;
 }
+
index b36220b57c8714bcc6eb4b4fcdbec6ad069ee864..e738e744538b613de3a00af626afec330acd4afd 100644 (file)
@@ -35,6 +35,7 @@ static int ItemChanged_Type = QEvent::User + 7;
 static int ItemRateChanged_Type = QEvent::User + 8;
 static int ItemTitleChanged_Type = QEvent::User + 9;
 static int ItemStateChanged_Type = QEvent::User + 10;
+static int VolumeChanged_Type = QEvent::User + 11;
 
 class IMEvent : public QEvent
 {
@@ -75,7 +76,6 @@ private:
     int             i_rate;
 public slots:
     void togglePlayPause();
-    void update(); ///< Periodic updates
     void setInput( input_thread_t * ); ///< Our controlled input changed
     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
     void slower();
@@ -140,6 +140,7 @@ private slots:
     //void updateInput();
 signals:
     void inputChanged( input_thread_t * );
+    void volumeChanged( void );
 };
 
 #endif
index 7bfeb55fc7fbb1e17319252dbc78ef2eee1b1d2c..34d63a31de6734983a877aa948192754e3d1c1a1 100644 (file)
@@ -889,8 +889,6 @@ void MainInterface::updateOnTimer()
         need_components_update = false;
     }
 #endif
-
-    controls->updateOnTimer();
 }
 
 /*****************************************************************************