Commit 2e3ce1cc authored by Francois Cartegnie's avatar Francois Cartegnie

epg: narrow input lock

parent 41e32860
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
#include <QLabel> #include <QLabel>
#include <QStringList> #include <QStringList>
#include "qt4.hpp" #include "qt4.hpp"
#include "input_manager.hpp"
#include <vlc_common.h>
#include <vlc_epg.h>
EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent ) EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
{ {
...@@ -94,18 +97,22 @@ void EPGWidget::setZoom( int level ) ...@@ -94,18 +97,22 @@ void EPGWidget::setZoom( int level )
m_rulerWidget->setScale( scale ); 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 */ /* flush our EPG data if input type has changed */
if ( b_input_type_known && i_input_type != i_event_source_type ) m_epgView->reset(); if ( b_input_type_known && p_input_item->i_type != i_event_source_type ) m_epgView->reset();
i_event_source_type = i_input_type; i_event_source_type = p_input_item->i_type;
b_input_type_known = true; b_input_type_known = true;
m_epgView->cleanup(); /* expire items and flags */ m_epgView->cleanup(); /* expire items and flags */
/* Fixme: input could have dissapeared */
for ( int i = 0; i < i_epg; ++i ) 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 */ /* Read current epg events from libvlc and try to insert them */
for ( int j = 0; j < p_epg->i_event; ++j ) 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 ) ...@@ -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 ) ); ( p_epg->p_current == p_event ) );
} }
} }
vlc_mutex_unlock( & p_input_item->lock );
/* toggle our widget view */ /* toggle our widget view */
rootWidget->setCurrentIndex( m_epgView->hasValidData() ? 0 : 1 ); 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 ) ...@@ -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->updateDuration();
m_epgView->updateStartTime(); m_epgView->updateStartTime();
} }
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
public slots: public slots:
void setZoom( int level ); 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: private:
EPGRuler* m_rulerWidget; EPGRuler* m_rulerWidget;
......
...@@ -118,15 +118,8 @@ void EpgDialog::showEvent( EPGItem *epgItem ) ...@@ -118,15 +118,8 @@ void EpgDialog::showEvent( EPGItem *epgItem )
void EpgDialog::updateInfos() void EpgDialog::updateInfos()
{ {
if( !THEMIM->getInput() ) return;
timer->stop(); timer->stop();
input_item_t *p_input_item = input_GetItem( THEMIM->getInput() ); if( !THEMIM->getInput() ) return;
vlc_mutex_lock( & p_input_item->lock ); epg->updateEPG( input_GetItem( THEMIM->getInput() ) );
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 ( isVisible() ) timer->start(); if ( isVisible() ) timer->start();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment