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 Apr 12, 2015
1 parent 1549e4e commit d668a8c
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 @@ -131,11 +131,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 @@ -154,7 +174,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 @@ -75,8 +75,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 @@ -334,7 +334,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 @@ -512,7 +512,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 d668a8c

Please sign in to comment.