Skip to content

Commit

Permalink
[PVR] Fix timers thread start/stop, load/unload races.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksooo committed Dec 21, 2020
1 parent d02291e commit eb0d8fc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 2 additions & 0 deletions xbmc/pvr/PVRManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void CPVRManager::Stop()

m_addons->Stop();
m_pendingUpdates->Stop();
m_timers->Stop();
m_epgContainer.Stop();
m_guiInfo->Stop();

Expand Down Expand Up @@ -508,6 +509,7 @@ void CPVRManager::Process()

m_guiInfo->Start();
m_epgContainer.Start(true);
m_timers->Start();
m_pendingUpdates->Start();

SetState(ManagerStateStarted);
Expand Down
23 changes: 16 additions & 7 deletions xbmc/pvr/timers/PVRTimers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,33 @@ bool CPVRTimers::Load()
// load local timers from database
bool bReturn = LoadFromDatabase();

Update(); // update from clients

CServiceBroker::GetPVRManager().EpgContainer().Events().Subscribe(this, &CPVRTimers::Notify);
Create();
// update from clients
Update();

return bReturn;
}

void CPVRTimers::Unload()
{
StopThread();
CServiceBroker::GetPVRManager().EpgContainer().Events().Unsubscribe(this);

// remove all tags
CSingleLock lock(m_critSection);
m_tags.clear();
}

void CPVRTimers::Start()
{
Stop();

CServiceBroker::GetPVRManager().EpgContainer().Events().Subscribe(this, &CPVRTimers::Notify);
Create();
}

void CPVRTimers::Stop()
{
StopThread();
CServiceBroker::GetPVRManager().EpgContainer().Events().Unsubscribe(this);
}

bool CPVRTimers::Update()
{
{
Expand Down
10 changes: 10 additions & 0 deletions xbmc/pvr/timers/PVRTimers.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ namespace PVR
CPVRTimers();
~CPVRTimers() override = default;

/**
* @brief start the timer update thread.
*/
void Start();

/**
* @brief stop the timer update thread.
*/
void Stop();

/**
* @brief (re)load the timers from the clients.
* @return True if loaded successfully, false otherwise.
Expand Down

0 comments on commit eb0d8fc

Please sign in to comment.