Skip to content

Commit

Permalink
Merge pull request #6937 from xhaggi/pvr-async-epg-container-start
Browse files Browse the repository at this point in the history
[epg] start epg container asynchronously
  • Loading branch information
xhaggi committed Aug 3, 2015
2 parents 9da5b7c + 24e7387 commit 856414b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
27 changes: 25 additions & 2 deletions xbmc/epg/EpgContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,31 @@ void CEpgContainer::Clear(bool bClearDb /* = false */)
NotifyObservers(ObservableMessageEpgContainer);

if (bThreadRunning)
Start();
Start(true);
}

void CEpgContainer::Start(void)
class CEPGContainerStartJob : public CJob
{
public:
CEPGContainerStartJob() {}
~CEPGContainerStartJob(void) {}

bool DoWork(void)
{
g_EpgContainer.Start(false);
return true;
}
};

void CEpgContainer::Start(bool bAsync)
{
if (bAsync)
{
CEPGContainerStartJob *job = new CEPGContainerStartJob();
CJobManager::GetInstance().AddJob(job, NULL);
return;
}

Stop();

{
Expand All @@ -150,7 +170,10 @@ void CEpgContainer::Start(void)

LoadFromDB();
if (g_PVRManager.IsStarted())
{
g_PVRManager.TriggerEpgsCreate();
g_PVRManager.Recordings()->UpdateEpgTags();
}

CSingleLock lock(m_critSection);
if (!m_bStop)
Expand Down
3 changes: 2 additions & 1 deletion xbmc/epg/EpgContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ namespace EPG

/*!
* @brief Start the EPG update thread.
* @param bAsync Should the EPG container starts asynchronously
*/
virtual void Start(void);
virtual void Start(bool bAsync);

/*!
* @brief Stop the EPG update thread.
Expand Down
6 changes: 4 additions & 2 deletions xbmc/pvr/PVRManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ bool CPVRManager::UpgradeOutdatedAddons(void)
if (IsInitialising())
{
SetState(ManagerStateStarted);
g_EpgContainer.Start();
g_EpgContainer.Start(true);

CLog::Log(LOGDEBUG, "PVRManager - %s - restarted", __FUNCTION__);
return true;
Expand Down Expand Up @@ -504,9 +504,11 @@ void CPVRManager::Process(void)

SetState(ManagerStateStarted);

/* start epg container */
g_EpgContainer.Start(true);

/* main loop */
CLog::Log(LOGDEBUG, "PVRManager - %s - entering main loop", __FUNCTION__);
g_EpgContainer.Start();

bool bRestart(false);
while (IsStarted() && m_addons && m_addons->HasConnectedClients() && !bRestart)
Expand Down

0 comments on commit 856414b

Please sign in to comment.