Skip to content

Commit

Permalink
[epg] start epg container asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaggi committed Jul 31, 2015
1 parent 4081de3 commit 7b29f5a
Show file tree
Hide file tree
Showing 3 changed files with 29 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
4 changes: 2 additions & 2 deletions xbmc/pvr/PVRManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,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 @@ -510,7 +510,7 @@ void CPVRManager::Process(void)

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

/* activate startup window */
if (m_openWindowId > 0)
Expand Down

0 comments on commit 7b29f5a

Please sign in to comment.