]> git.sesse.net Git - vlc/commitdiff
stats-change variable for statistics/removing stats timer from qt4 interface
authorIlkka Ollakka <ileoo@videolan.org>
Sun, 12 Oct 2008 11:48:26 +0000 (14:48 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Sun, 12 Oct 2008 12:08:36 +0000 (15:08 +0300)
- Add stats-change variable for input to inform when statistics are computed
- Use that variable in qt4 interface to update statistics so no need to loop
  with timer ( ticket #1365)

modules/gui/qt4/components/info_panels.cpp
modules/gui/qt4/dialogs/mediainfo.cpp
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/input_manager.hpp
modules/video_output/x11/xcommon.c
src/input/input.c
src/input/var.c

index 1d4164a0f1b9ef623d2acb6f89d2aad904d353aa..35e784cafb3411c10aae59d88f2c73eb48986080 100644 (file)
@@ -546,6 +546,8 @@ InputStatsPanel::InputStatsPanel( QWidget *parent,
     StatsTree->setColumnWidth( 1 , 200 );
 
     layout->addWidget(StatsTree, 1, 0 );
+    CONNECT( THEMIM->getIM() , statisticsUpdated( input_item_t* ),
+            this, update( input_item_t* ) );
 }
 
 InputStatsPanel::~InputStatsPanel()
index 844c9232eaf4390d52692d239b39f95f2f2d6c0f..ccebec78640d44c99e62d2929c5609487dfcb973 100644 (file)
@@ -162,9 +162,9 @@ void MediaInfoDialog::update( input_thread_t *p_input )
 
 void MediaInfoDialog::updateOnTimeOut()
 {
-    /* Timer runs at 150 ms, dont' update more than 2 times per second */
+    /* Timer runs at 150 ms, dont' update more than 2 times per second
     i_runs++;
-    if( i_runs % 4 != 0 ) return;
+    if( i_runs % 4 != 0 ) return;*/
 
     /* Get Input and clear if non-existant */
     input_thread_t *p_input = THEMIM->getInput();
index a01ff210be86f29504c8e9854ae41416a0471c65..e30b9babbaeffcbe21d4d7c2642c9929829a6351 100644 (file)
@@ -42,6 +42,8 @@ static int PLItemChanged( vlc_object_t *, const char *,
                         vlc_value_t, vlc_value_t, void * );
 static int InterfaceChanged( vlc_object_t *, const char *,
                             vlc_value_t, vlc_value_t, void * );
+static int StatisticsUpdated( vlc_object_t *, const char *,
+                            vlc_value_t, vlc_value_t, void * );
 static int InterfaceVoutChanged( vlc_object_t *, const char *,
                                  vlc_value_t, vlc_value_t, void * );
 static int ItemStateChanged( vlc_object_t *, const char *,
@@ -158,6 +160,8 @@ void InputManager::addCallbacks()
     var_AddCallback( p_input, "title", ItemTitleChanged, this );
     /* src/input/input.c:734 for timers update*/
     var_AddCallback( p_input, "intf-change", InterfaceChanged, this );
+    /* src/input/input.c:710 for statistics update*/
+    var_AddCallback( p_input, "stats-change", StatisticsUpdated, this );
     /* src/input/input.c for vout creation/destruction */
     var_AddCallback( p_input, "intf-change-vout", InterfaceVoutChanged, this );
 }
@@ -172,6 +176,7 @@ void InputManager::delCallbacks()
     var_DelCallback( p_input, "rate-change", ItemRateChanged, this );
     var_DelCallback( p_input, "title", ItemTitleChanged, this );
     var_DelCallback( p_input, "intf-change", InterfaceChanged, this );
+    var_DelCallback( p_input, "stats-change", StatisticsUpdated, this );
     var_DelCallback( p_input, "intf-change-vout", InterfaceVoutChanged, this );
 }
 
@@ -188,6 +193,7 @@ void InputManager::customEvent( QEvent *event )
          type != ItemSpuChanged_Type &&
          type != ItemTeletextChanged_Type &&
          type != ItemStateChanged_Type &&
+         type != StatisticsUpdate_Type &&
          type != InterfaceVoutUpdate_Type )
         return;
 
@@ -204,12 +210,14 @@ void InputManager::customEvent( QEvent *event )
           type != ItemSpuChanged_Type &&
           type != ItemTeletextChanged_Type &&
           type != ItemStateChanged_Type &&
+          type != StatisticsUpdate_Type &&
           type != InterfaceVoutUpdate_Type
         )
         && ( i_input_id != ple->i_id ) )
         return;
 
-    if( type != PositionUpdate_Type )
+    if( type != PositionUpdate_Type &&
+        type != StatisticsUpdate_Type )
         msg_Dbg( p_intf, "New Event: type %i", type );
 
     /* Actions */
@@ -218,6 +226,9 @@ void InputManager::customEvent( QEvent *event )
     case PositionUpdate_Type:
         UpdatePosition();
         break;
+    case StatisticsUpdate_Type:
+        UpdateStats();
+        break;
     case ItemChanged_Type:
         UpdateMeta();
         UpdateStatus();
@@ -247,6 +258,11 @@ void InputManager::customEvent( QEvent *event )
     }
 }
 
+void InputManager::UpdateStats()
+{
+    emit statisticsUpdated( input_GetItem( p_input ) );
+}
+
 void InputManager::UpdatePosition()
 {
     /* Update position */
@@ -726,6 +742,16 @@ static int InterfaceChanged( vlc_object_t *p_this, const char *psz_var,
     return VLC_SUCCESS;
 }
 
+static int StatisticsUpdated( vlc_object_t *p_this, const char *psz_var,
+                           vlc_value_t oldval, vlc_value_t newval, void *param )
+{
+    InputManager *im = (InputManager*)param;
+
+    IMEvent *event = new IMEvent( StatisticsUpdate_Type, 0 );
+    QApplication::postEvent( im, static_cast<QEvent*>(event) );
+    return VLC_SUCCESS;
+}
+
 static int InterfaceVoutChanged( vlc_object_t *p_this, const char *psz_var,
                                  vlc_value_t oldval, vlc_value_t newval, void *param )
 {
index 0d0798d4c9075ba0e138278a20ade3e0942e8081..5656bde3c7ba0c10efece61624db455fb1021a7a 100644 (file)
@@ -45,11 +45,12 @@ static int const VolumeChanged_Type      = QEvent::User + IMEventType + 6;
 static int const ItemSpuChanged_Type     = QEvent::User + IMEventType + 7;
 static int const ItemTeletextChanged_Type= QEvent::User + IMEventType + 8;
 static int const InterfaceVoutUpdate_Type= QEvent::User + IMEventType + 9;
+static int const StatisticsUpdate_Type   = QEvent::User + IMEventType + 10;
 
-static int const FullscreenControlToggle_Type = QEvent::User + IMEventType + 10;
-static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 11;
-static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 12;
-static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 13;
+static int const FullscreenControlToggle_Type = QEvent::User + IMEventType + 11;
+static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 12;
+static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 13;
+static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 14;
 
 class IMEvent : public QEvent
 {
@@ -98,6 +99,7 @@ private:
     void UpdateTeletext();
     void UpdateArt();
     void UpdateVout();
+    void UpdateStats();
 
 public slots:
     void setInput( input_thread_t * ); ///< Our controlled input changed
@@ -122,6 +124,8 @@ signals:
     void nameChanged( QString );
     /// Used to signal whether we should show navigation buttons
     void navigationChanged( int );
+    /// Statistics are updated
+    void statisticsUpdated( input_item_t* );
     /// Play/pause status
     void statusChanged( int );
     void artChanged( input_item_t* );
index 28f2ddcad4dfbd34ab26a712d560e5f31670068e..162e00dedb8b79f2bff4c10a8d3b1b125fd750d3 100644 (file)
@@ -2261,6 +2261,7 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
         EnablePixelDoubling( p_vout );
 #endif
 
+#if 0
         /* Activate the window (give it the focus) */
         XClientMessageEvent event;
 
@@ -2282,6 +2283,7 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
                     DefaultRootWindow( p_vout->p_sys->p_display ),
                     False, SubstructureRedirectMask,
                     (XEvent*)&event );
+#endif
     }
     else
     {
@@ -2307,6 +2309,7 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
      * window has already been mapped because the XMapWindow() request
      * has not necessarily been sent directly to our window (remember,
      * the call is first redirected to the window manager) */
+#if 0
     do
     {
         XWindowEvent( p_vout->p_sys->p_display,
@@ -2320,6 +2323,9 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
                    p_vout->p_sys->p_win->base_window,
                    RevertToParent,
                    CurrentTime);
+#else
+    XSync( p_vout->p_sys->p_display, False );
+#endif
 
     /* signal that the size needs to be updated */
     p_vout->i_changes |= VOUT_SIZE_CHANGE;
index 0f75f62ca4e259fcaae8acfd393fd33b79b05f9c..694db6634b5d811703e8587e877166314dd01765 100644 (file)
@@ -123,6 +123,7 @@ static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_for
  *  - intf-change
  *  - intf-change-vout for when a vout is created or destroyed
  *  - rate-change for when playback rate changes
+ *  - stats-change for when statistics are updated
  * TODO explain when Callback is called
  * TODO complete this list (?)
  *****************************************************************************/
@@ -706,6 +707,7 @@ static void MainLoopStatistic( input_thread_t *p_input )
         stats_ComputeGlobalStats( p_input->p_libvlc,
                                   p_input->p_libvlc->p_stats );
     }
+    var_SetBool( p_input, "stats-change", true );
 }
 
 /**
index 9ed07e48abad94d0b09894cb003b18907adb873d..2714786dc6a7a856833d467b674ff26ee55c5984 100644 (file)
@@ -223,11 +223,15 @@ void input_ControlVarInit ( input_thread_t *p_input )
          *
          * Add rate-change to inform about rate changin
          *
+         * stats-change to inform when statistics are computed
+         *
          * TODO list all changes warn by this callbacks */
         var_Create( p_input, "intf-change", VLC_VAR_BOOL );
         var_SetBool( p_input, "intf-change", true );
         var_Create( p_input, "rate-change", VLC_VAR_BOOL );
         var_SetBool( p_input, "rate-change", true );
+        var_Create( p_input, "stats-change", VLC_VAR_BOOL );
+        var_SetBool( p_input, "stats-change", true );
 
         var_Create( p_input, "intf-change-vout", VLC_VAR_BOOL );
         var_SetBool( p_input, "intf-change-vout", true );