From 5e9bd5cf83b8a7312e3c6543f757bf723e342e8e Mon Sep 17 00:00:00 2001 From: Jasmin Jessich Date: Fri, 9 Jun 2017 23:36:48 +0200 Subject: Update internal timer list if VDR timers have been changed - New function StatusMonitor::TimerChange. - New function TimerManager::SetReloadTimers. - VDR will execute TimerChange which will use SetReloadTimers to store a timer update needs to be done. Later TimerManager::DoPendingWork will reload the actual timers from VDR. - Added missing locking to StatusMonitor functions. --- status.cpp | 9 ++++++++- status.h | 3 ++- timers.cpp | 2 +- timers.h | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/status.cpp b/status.cpp index 47b451e..a39782c 100644 --- a/status.cpp +++ b/status.cpp @@ -8,9 +8,16 @@ namespace vdrlive { StatusMonitor::StatusMonitor() { } - + +void StatusMonitor::TimerChange(const cTimer *Timer, eTimerChange Change) +{ + cMutexLock timersLock( &LiveTimerManager() ); + LiveTimerManager().SetReloadTimers(); +} + void StatusMonitor::Recording( cDevice const*, char const*, char const*, bool ) { + cMutexLock timersLock( &LiveTimerManager() ); LiveTimerManager().DoReloadTimers(); } diff --git a/status.h b/status.h index 6f1b3ce..7379b75 100644 --- a/status.h +++ b/status.h @@ -12,7 +12,8 @@ class StatusMonitor: public cStatus private: StatusMonitor(); StatusMonitor( StatusMonitor const& ); - + + virtual void TimerChange(const cTimer *Timer, eTimerChange Change); virtual void Recording( cDevice const* Device, char const* Name, char const* FileName, bool On ); }; diff --git a/timers.cpp b/timers.cpp index 8f3eea8..5335381 100644 --- a/timers.cpp +++ b/timers.cpp @@ -249,7 +249,7 @@ namespace vdrlive { void TimerManager::DoPendingWork() { - if ( m_updateTimers.size() == 0 && !m_timers.Modified() ) + if ( m_updateTimers.size() == 0 && !m_timers.Modified() && !m_reloadTimers ) return; cMutexLock lock( this ); diff --git a/timers.h b/timers.h index 1952524..968cd8a 100644 --- a/timers.h +++ b/timers.h @@ -53,8 +53,9 @@ namespace vdrlive { void ToggleTimerActive( cTimer* timer); // may only be called from Plugin::MainThreadHook void DoPendingWork(); - void DoReloadTimers() { m_timers.ReloadTimers(); } + void DoReloadTimers() { m_timers.ReloadTimers(); m_reloadTimers = false; } const cTimer* GetTimer(tEventID eventid, tChannelID channelid); + void SetReloadTimers() { m_reloadTimers = true; } private: typedef std::pair< cTimer*, std::string > TimerPair; @@ -69,6 +70,7 @@ namespace vdrlive { TimerList m_updateTimers; ErrorList m_failedUpdates; cCondVar m_updateWait; + bool m_reloadTimers; void DoUpdateTimers(); void DoInsertTimer( TimerPair& timerData ); -- cgit v1.2.3