Permalink
Browse files

epg: removed unneeded local time conversions when getting epg data an…

…d cache the fileitemlist with epg entries in the window. speeds up timeline (a lot)
  • Loading branch information...
1 parent f3f2f22 commit f05a59b62a0e1f4a6f446d08a7118d6545acc5b6 @opdenkamp committed Jul 8, 2012
View
18 xbmc/epg/Epg.cpp
@@ -540,14 +540,7 @@ int CEpg::Get(CFileItemList &results) const
CSingleLock lock(m_critSection);
for (map<CDateTime, CEpgInfoTag *>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++)
- {
- CDateTime localStartTime;
- localStartTime.SetFromUTCDateTime(it->first);
-
- CFileItemPtr entry(new CFileItem(*it->second));
- entry->SetLabel2(localStartTime.GetAsLocalizedDateTime(false, false));
- results.Add(entry);
- }
+ results.Add(CFileItemPtr(new CFileItem(*it->second)));
return results.Size() - iInitialSize;
}
@@ -564,14 +557,7 @@ int CEpg::Get(CFileItemList &results, const EpgSearchFilter &filter) const
for (map<CDateTime, CEpgInfoTag *>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++)
{
if (filter.FilterEntry(*it->second))
- {
- CDateTime localStartTime;
- localStartTime.SetFromUTCDateTime(it->first);
-
- CFileItemPtr entry(new CFileItem(*it->second));
- entry->SetLabel2(localStartTime.GetAsLocalizedDateTime(false, false));
- results.Add(entry);
- }
+ results.Add(CFileItemPtr(new CFileItem(*it->second)));
}
return results.Size() - iInitialSize;
View
12 xbmc/epg/GUIEPGGridContainer.cpp
@@ -725,7 +725,7 @@ bool CGUIEPGGridContainer::OnMessage(CGUIMessage& message)
UpdateLayout(true); // true to refresh all items
/* Create Ruler items */
- CDateTime ruler = m_gridStart;
+ CDateTime ruler; ruler.SetFromUTCDateTime(m_gridStart);
CDateTimeSpan unit(0, 0, m_rulerUnit * MINSPERBLOCK, 0);
CGUIListItemPtr rulerItem(new CFileItem(ruler.GetAsLocalizedDate(true, true)));
rulerItem->SetProperty("DateLabel", true);
@@ -793,7 +793,7 @@ void CGUIEPGGridContainer::UpdateItems()
CDateTime gridCursor = m_gridStart; //reset cursor for new channel
unsigned long progIdx = m_epgItemsPtr[row].start;
unsigned long lastIdx = m_epgItemsPtr[row].stop;
- int channelnum = ((CFileItem *)m_programmeItems[progIdx].get())->GetEPGInfoTag()->PVRChannelNumber();
+ int iEpgId = ((CFileItem *)m_programmeItems[progIdx].get())->GetEPGInfoTag()->EpgID();
/** FOR EACH BLOCK **********************************************************************/
@@ -806,18 +806,18 @@ void CGUIEPGGridContainer::UpdateItems()
if (tag == NULL)
progIdx++;
- if (tag->PVRChannelNumber() != channelnum)
+ if (tag->EpgID() != iEpgId)
break;
- if (m_gridEnd <= tag->StartAsLocalTime())
+ if (m_gridEnd <= tag->StartAsUTC())
{
break;
}
- else if (gridCursor >= tag->EndAsLocalTime())
+ else if (gridCursor >= tag->EndAsUTC())
{
progIdx++;
}
- else if (gridCursor < tag->EndAsLocalTime())
+ else if (gridCursor < tag->EndAsUTC())
{
m_gridIndex[row][block].item = item;
break;
View
39 xbmc/pvr/windows/GUIWindowPVRGuide.cpp
@@ -44,6 +44,12 @@ CGUIWindowPVRGuide::CGUIWindowPVRGuide(CGUIWindowPVR *parent) :
Observer(),
m_iGuideView(g_guiSettings.GetInt("epg.defaultguideview"))
{
+ m_cachedTimeline = new CFileItemList;
+}
+
+CGUIWindowPVRGuide::~CGUIWindowPVRGuide(void)
+{
+ delete m_cachedTimeline;
}
void CGUIWindowPVRGuide::UnregisterObservers(void)
@@ -62,11 +68,11 @@ void CGUIWindowPVRGuide::Notify(const Observable &obs, const CStdString& msg)
{
if (msg.Equals("epg"))
{
+ m_bUpdateRequired = true;
+
/* update the current window if the EPG timeline view is visible */
if (IsVisible() && m_iGuideView == GUIDE_VIEW_TIMELINE)
UpdateData();
- else
- m_bUpdateRequired = true;
}
else if (msg.Equals("epg-now"))
{
@@ -202,24 +208,33 @@ void CGUIWindowPVRGuide::UpdateViewNext(void)
void CGUIWindowPVRGuide::UpdateViewTimeline(void)
{
- CPVRChannel CurrentChannel;
- bool bGotCurrentChannel = g_PVRManager.GetCurrentChannel(CurrentChannel);
- bool bRadio = bGotCurrentChannel ? CurrentChannel.IsRadio() : false;
- CDateTime gridStart = CDateTime::GetCurrentDateTime();
- CDateTime firstDate; firstDate.SetFromUTCDateTime(g_EpgContainer.GetFirstEPGDate());
- CDateTime lastDate; lastDate.SetFromUTCDateTime(g_EpgContainer.GetLastEPGDate());
m_parent->m_guideGrid = (CGUIEPGGridContainer*) m_parent->GetControl(CONTROL_LIST_TIMELINE);
if (!m_parent->m_guideGrid)
return;
- m_parent->SetLabel(m_iControlButton, g_localizeStrings.Get(19222) + ": " + g_localizeStrings.Get(19032));
- m_parent->SetLabel(CONTROL_LABELGROUP, g_localizeStrings.Get(19032));
+ if (m_bUpdateRequired || m_cachedTimeline->IsEmpty())
+ {
+ CPVRChannel CurrentChannel;
+ bool bGotCurrentChannel = g_PVRManager.GetCurrentChannel(CurrentChannel);
+ bool bRadio = bGotCurrentChannel ? CurrentChannel.IsRadio() : false;
+
+ m_cachedTimeline->Clear();
+ g_PVRManager.GetPlayingGroup(bRadio)->GetEPGAll(*m_cachedTimeline);
+ }
- g_PVRManager.GetPlayingGroup(bRadio)->GetEPGAll(*m_parent->m_vecItems);
m_parent->m_vecItems->RemoveDiscCache(m_parent->GetID());
+ m_parent->m_vecItems->Clear();
+ m_parent->m_vecItems->Copy(*m_cachedTimeline);
+ CDateTime gridStart = CDateTime::GetCurrentDateTime().GetAsUTCDateTime();
+ CDateTime firstDate(g_EpgContainer.GetFirstEPGDate());
+ CDateTime lastDate(g_EpgContainer.GetLastEPGDate());
m_parent->m_guideGrid->SetStartEnd(firstDate > gridStart ? firstDate : gridStart, lastDate);
+
+ m_parent->SetLabel(m_iControlButton, g_localizeStrings.Get(19222) + ": " + g_localizeStrings.Get(19032));
+ m_parent->SetLabel(CONTROL_LABELGROUP, g_localizeStrings.Get(19032));
m_parent->m_viewControl.SetCurrentView(CONTROL_LIST_TIMELINE);
+
SelectPlayingFile();
}
@@ -240,7 +255,6 @@ void CGUIWindowPVRGuide::UpdateData(void)
CLog::Log(LOGDEBUG, "CGUIWindowPVRGuide - %s - update window '%s'. set view to %d", __FUNCTION__, GetName(), m_iControlList);
g_EpgContainer.RegisterObserver(this);
- m_bUpdateRequired = false;
/* lock the graphics context while updating */
CSingleLock graphicsLock(g_graphicsContext);
@@ -256,6 +270,7 @@ void CGUIWindowPVRGuide::UpdateData(void)
else if (m_iGuideView == GUIDE_VIEW_TIMELINE)
UpdateViewTimeline();
+ m_bUpdateRequired = false;
m_parent->SetLabel(CONTROL_LABELHEADER, g_localizeStrings.Get(19222));
UpdateButtons();
}
View
5 xbmc/pvr/windows/GUIWindowPVRGuide.h
@@ -36,7 +36,7 @@ namespace PVR
public:
CGUIWindowPVRGuide(CGUIWindowPVR *parent);
- virtual ~CGUIWindowPVRGuide(void) {};
+ virtual ~CGUIWindowPVRGuide(void);
virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const;
virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button);
@@ -67,6 +67,7 @@ namespace PVR
virtual void UpdateViewNext(void);
virtual void UpdateViewTimeline(void);
- int m_iGuideView;
+ int m_iGuideView;
+ CFileItemList *m_cachedTimeline;
};
}

0 comments on commit f05a59b

Please sign in to comment.