[vlc-commits] epg: narrow input lock

Francois Cartegnie git at videolan.org
Thu Mar 31 00:09:39 CEST 2011


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Mar 30 23:45:46 2011 +0200| [2e3ce1ccaab119d84ff531041e684fba4c31cea1] | committer: Francois Cartegnie

epg: narrow input lock

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

 modules/gui/qt4/components/epg/EPGWidget.cpp |   21 +++++++++++++++------
 modules/gui/qt4/components/epg/EPGWidget.hpp |    2 +-
 modules/gui/qt4/dialogs/epg.cpp              |   11 ++---------
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/modules/gui/qt4/components/epg/EPGWidget.cpp b/modules/gui/qt4/components/epg/EPGWidget.cpp
index cc1391c..d059de2 100644
--- a/modules/gui/qt4/components/epg/EPGWidget.cpp
+++ b/modules/gui/qt4/components/epg/EPGWidget.cpp
@@ -33,6 +33,9 @@
 #include <QLabel>
 #include <QStringList>
 #include "qt4.hpp"
+#include "input_manager.hpp"
+#include <vlc_common.h>
+#include <vlc_epg.h>
 
 EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
 {
@@ -94,18 +97,22 @@ void EPGWidget::setZoom( int level )
     m_rulerWidget->setScale( scale );
 }
 
-void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
+void EPGWidget::updateEPG( input_item_t *p_input_item )
 {
+    if( !p_input_item ) return;
+
     /* flush our EPG data if input type has changed */
-    if ( b_input_type_known && i_input_type != i_event_source_type ) m_epgView->reset();
-    i_event_source_type = i_input_type;
+    if ( b_input_type_known && p_input_item->i_type != i_event_source_type ) m_epgView->reset();
+    i_event_source_type = p_input_item->i_type;
     b_input_type_known = true;
 
     m_epgView->cleanup(); /* expire items and flags */
-
-    for ( int i = 0; i < i_epg; ++i )
+    /* Fixme: input could have dissapeared */
+    vlc_mutex_lock(  & p_input_item->lock );
+    int i_nbitems = p_input_item->i_epg;
+    for ( int i = 0; i < p_input_item->i_epg; ++i )
     {
-        vlc_epg_t *p_epg = pp_epg[i];
+        vlc_epg_t *p_epg = p_input_item->pp_epg[i];
 
         /* Read current epg events from libvlc and try to insert them */
         for ( int j = 0; j < p_epg->i_event; ++j )
@@ -115,6 +122,7 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
                                     ( p_epg->p_current == p_event ) );
         }
     }
+    vlc_mutex_unlock( & p_input_item->lock );
 
     /* toggle our widget view */
     rootWidget->setCurrentIndex( m_epgView->hasValidData() ? 0 : 1 );
@@ -123,3 +131,4 @@ void EPGWidget::updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type )
     m_epgView->updateDuration();
     m_epgView->updateStartTime();
 }
+
diff --git a/modules/gui/qt4/components/epg/EPGWidget.hpp b/modules/gui/qt4/components/epg/EPGWidget.hpp
index 73ae32f..f9b0596 100644
--- a/modules/gui/qt4/components/epg/EPGWidget.hpp
+++ b/modules/gui/qt4/components/epg/EPGWidget.hpp
@@ -46,7 +46,7 @@ public:
 
 public slots:
     void setZoom( int level );
-    void updateEPG( vlc_epg_t **pp_epg, int i_epg, uint8_t i_input_type );
+    void updateEPG( input_item_t * );
 
 private:
     EPGRuler* m_rulerWidget;
diff --git a/modules/gui/qt4/dialogs/epg.cpp b/modules/gui/qt4/dialogs/epg.cpp
index 2fb3e9e..0a036ad 100644
--- a/modules/gui/qt4/dialogs/epg.cpp
+++ b/modules/gui/qt4/dialogs/epg.cpp
@@ -118,15 +118,8 @@ void EpgDialog::showEvent( EPGItem *epgItem )
 
 void EpgDialog::updateInfos()
 {
-    if( !THEMIM->getInput() ) return;
     timer->stop();
-    input_item_t *p_input_item = input_GetItem( THEMIM->getInput() );
-    vlc_mutex_lock(  & p_input_item->lock );
-    int i_nbitems = p_input_item->i_epg;
-    if ( i_nbitems > 0 ) msg_Dbg( p_intf, "Found %i EPG items", i_nbitems );
-    epg->updateEPG( p_input_item->pp_epg,
-                    p_input_item->i_epg,
-                    p_input_item->i_type);
-    vlc_mutex_unlock( & p_input_item->lock );
+    if( !THEMIM->getInput() ) return;
+    epg->updateEPG( input_GetItem( THEMIM->getInput() ) );
     if ( isVisible() ) timer->start();
 }



More information about the vlc-commits mailing list