[vlc-devel] commit: stats-change variable for statistics/ removing stats timer from qt4 interface (Ilkka Ollakka )

git version control git at videolan.org
Sun Oct 12 14:08:41 CEST 2008


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sun Oct 12 14:48:26 2008 +0300| [8689e8be211fe01376316a99fefb8c908263f97e] | committer: Ilkka Ollakka 

stats-change variable for statistics/removing stats timer from qt4 interface

- 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)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8689e8be211fe01376316a99fefb8c908263f97e
---

 modules/gui/qt4/components/info_panels.cpp |    2 ++
 modules/gui/qt4/dialogs/mediainfo.cpp      |    4 ++--
 modules/gui/qt4/input_manager.cpp          |   28 +++++++++++++++++++++++++++-
 modules/gui/qt4/input_manager.hpp          |   12 ++++++++----
 modules/video_output/x11/xcommon.c         |    6 ++++++
 src/input/input.c                          |    2 ++
 src/input/var.c                            |    4 ++++
 7 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp
index 1d4164a..35e784c 100644
--- a/modules/gui/qt4/components/info_panels.cpp
+++ b/modules/gui/qt4/components/info_panels.cpp
@@ -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()
diff --git a/modules/gui/qt4/dialogs/mediainfo.cpp b/modules/gui/qt4/dialogs/mediainfo.cpp
index 844c923..ccebec7 100644
--- a/modules/gui/qt4/dialogs/mediainfo.cpp
+++ b/modules/gui/qt4/dialogs/mediainfo.cpp
@@ -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();
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index a01ff21..e30b9ba 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -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 )
 {
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index 0d0798d..5656bde 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -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* );
diff --git a/modules/video_output/x11/xcommon.c b/modules/video_output/x11/xcommon.c
index 28f2ddc..162e00d 100644
--- a/modules/video_output/x11/xcommon.c
+++ b/modules/video_output/x11/xcommon.c
@@ -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;
diff --git a/src/input/input.c b/src/input/input.c
index 0f75f62..694db66 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -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 );
 }
 
 /**
diff --git a/src/input/var.c b/src/input/var.c
index 9ed07e4..2714786 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -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 );




More information about the vlc-devel mailing list