[vlc-commits] Qt: rate limit EPG updates

Francois Cartegnie git at videolan.org
Thu Dec 15 17:15:09 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Dec 15 17:08:52 2016 +0100| [ba78a1fe00edbbb34502704347788f3455faccf4] | committer: Francois Cartegnie

Qt: rate limit EPG updates

As we don't have discrete updates due to use of input variable
for events, we're updating far too many times on EPG tables updates,
reprocessing the whole EPG set. This is mainly the performance
issue with large EPG updates.

Also no longer updates internal event storage when hidden.

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

 modules/gui/qt/dialogs/epg.cpp | 27 ++++++++++++++++++++++-----
 modules/gui/qt/dialogs/epg.hpp |  7 ++++++-
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/modules/gui/qt/dialogs/epg.cpp b/modules/gui/qt/dialogs/epg.cpp
index d0aa301..d73b214 100644
--- a/modules/gui/qt/dialogs/epg.cpp
+++ b/modules/gui/qt/dialogs/epg.cpp
@@ -76,7 +76,7 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
     layout->addWidget( descBox );
 
     CONNECT( epg, itemSelectionChanged( EPGItem *), this, displayEvent( EPGItem *) );
-    CONNECT( THEMIM->getIM(), epgChanged(), this, updateInfos() );
+    CONNECT( THEMIM->getIM(), epgChanged(), this, scheduleUpdate() );
     CONNECT( THEMIM, inputChanged( bool ), this, updateInfos() );
 
     QDialogButtonBox *buttonsBox = new QDialogButtonBox( this );
@@ -94,8 +94,8 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
 
     timer = new QTimer( this );
     timer->setSingleShot( true );
-    timer->setInterval( 1000 * 60 );
-    CONNECT( timer, timeout(), this, updateInfos() );
+    timer->setInterval( 5000 );
+    CONNECT( timer, timeout(), this, timeout() );
 
     updateInfos();
     restoreWidgetPosition( "EPGDialog", QSize( 650, 450 ) );
@@ -106,6 +106,25 @@ EpgDialog::~EpgDialog()
     saveWidgetPosition( "EPGDialog" );
 }
 
+void EpgDialog::showEvent(QShowEvent *)
+{
+    scheduleUpdate();
+}
+
+void EpgDialog::timeout()
+{
+    if( !isVisible() )
+        scheduleUpdate();
+    else
+        updateInfos();
+}
+
+void EpgDialog::scheduleUpdate()
+{
+    if( !timer->isActive() )
+        timer->start( 5000 );
+}
+
 void EpgDialog::displayEvent( EPGItem *epgItem )
 {
     if( !epgItem ) return;
@@ -124,7 +143,6 @@ void EpgDialog::displayEvent( EPGItem *epgItem )
 
 void EpgDialog::updateInfos()
 {
-    timer->stop();
     input_item_t *p_input_item = NULL;
     playlist_t *p_playlist = THEPL;
     input_thread_t *p_input_thread = playlist_CurrentInput( p_playlist ); /* w/hold */
@@ -139,7 +157,6 @@ void EpgDialog::updateInfos()
         {
             epg->updateEPG( p_input_item );
             vlc_gc_decref( p_input_item );
-            if ( isVisible() ) timer->start();
         }
     }
 }
diff --git a/modules/gui/qt/dialogs/epg.hpp b/modules/gui/qt/dialogs/epg.hpp
index 88bbd26..10c3ff1 100644
--- a/modules/gui/qt/dialogs/epg.hpp
+++ b/modules/gui/qt/dialogs/epg.hpp
@@ -36,6 +36,9 @@ class EPGWidget;
 class EpgDialog : public QVLCFrame, public Singleton<EpgDialog>
 {
     Q_OBJECT
+protected:
+    virtual void showEvent(QShowEvent * event) Q_DECL_OVERRIDE;
+
 private:
     EpgDialog( intf_thread_t * );
     virtual ~EpgDialog();
@@ -48,8 +51,10 @@ private:
     friend class    Singleton<EpgDialog>;
 
 private slots:
-    void displayEvent( EPGItem * );
+    void scheduleUpdate();
     void updateInfos();
+    void timeout();
+    void displayEvent( EPGItem * );
 };
 
 #endif



More information about the vlc-commits mailing list