Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PVR] Guide window: Fix responsiveness on first open. #10814

Merged
merged 2 commits into from Oct 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 28 additions & 1 deletion xbmc/pvr/windows/GUIWindowPVRGuide.cpp
Expand Up @@ -515,6 +515,9 @@ bool CGUIWindowPVRGuide::RefreshTimelineItems()
if (epgGridContainer)
{
const CPVRChannelGroupPtr group(GetChannelGroup());
if (!group)
return false;

std::unique_ptr<CFileItemList> timeline(new CFileItemList);

// can be very expensive. never call with lock acquired.
Expand Down Expand Up @@ -695,13 +698,37 @@ CPVRRefreshTimelineItemsThread::CPVRRefreshTimelineItemsThread(CGUIWindowPVRGuid

void CPVRRefreshTimelineItemsThread::Process()
{
static const int BOOSTED_SLEEPS_THRESHOLD = 4;

int iLastEpgItemsCount = 0;
int iUpdatesWithoutChange = 0;

while (!m_bStop)
{
if (m_pGuideWindow->RefreshTimelineItems() && !m_bStop)
{
CGUIMessage m(GUI_MSG_REFRESH_LIST, m_pGuideWindow->GetID(), 0, ObservableMessageEpg);
KODI::MESSAGING::CApplicationMessenger::GetInstance().SendGUIMessage(m);
}
Sleep(5000);

// in order to fill the guide window asap, use a short update interval until we the
// same amount of epg events for BOOSTED_SLEEPS_THRESHOLD + 1 times in a row .
if (iUpdatesWithoutChange < BOOSTED_SLEEPS_THRESHOLD)
{
int iCurrentEpgItemsCount = m_pGuideWindow->CurrentDirectory().Size();

if (iCurrentEpgItemsCount == iLastEpgItemsCount)
iUpdatesWithoutChange++;
else
iUpdatesWithoutChange = 0; // reset

iLastEpgItemsCount = iCurrentEpgItemsCount;

Sleep(1000); // boosted update cycle
}
else
{
Sleep(5000); // normal update cycle
}
}
}