From 98de50e14c3c9f3189f9603dceea13050f5560ba Mon Sep 17 00:00:00 2001 From: Jasmin Jessich Date: Sun, 14 May 2017 00:49:10 +0200 Subject: Added RecordingsManager::StateChanged --- recman.cpp | 19 +++++++++++++++++-- recman.h | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/recman.cpp b/recman.cpp index b303076..47ea378 100644 --- a/recman.cpp +++ b/recman.cpp @@ -26,7 +26,8 @@ namespace vdrlive { shared_ptr< RecordingsTree > RecordingsManager::m_recTree; shared_ptr< RecordingsList > RecordingsManager::m_recList; shared_ptr< DirectoryList > RecordingsManager::m_recDirs; - int RecordingsManager::m_recordingsState = 0; + time_t RecordingsManager::m_recordingsState = 0; + string RecordingsManager::m_UpdateFileName; // The RecordingsManager holds a VDR lock on the // Recordings. Additionally the singleton instance of @@ -256,6 +257,20 @@ namespace vdrlive { return archived; } +#if VDRVERSNUM >= 20301 + bool RecordingsManager::StateChanged (time_t& tm) + { + if (m_UpdateFileName.empty()) { + m_UpdateFileName = AddDirectory (cVideoDirectory::Name(), ".update"); + } + LOCK_RECORDINGS_READ; + time_t lastmod = LastModifiedTime (m_UpdateFileName.c_str()); + bool result = tm != lastmod; + tm = lastmod; + return result; + } +#endif + RecordingsManagerPtr RecordingsManager::EnsureValidData() { // Get singleton instance of RecordingsManager. 'this' is not @@ -272,7 +287,7 @@ namespace vdrlive { // StateChanged must be executed every time, so not part of // the short cut evaluation in the if statement below. #if VDRVERSNUM >= 20301 - bool stateChanged = true; + bool stateChanged = StateChanged (m_recordingsState); #else bool stateChanged = Recordings.StateChanged(m_recordingsState); #endif diff --git a/recman.h b/recman.h index abc5359..0ff60f7 100644 --- a/recman.h +++ b/recman.h @@ -119,13 +119,15 @@ namespace vdrlive { private: RecordingsManager(); + static bool StateChanged (time_t& tm); static RecordingsManagerPtr EnsureValidData(); static std::tr1::weak_ptr< RecordingsManager > m_recMan; static std::tr1::shared_ptr< RecordingsTree > m_recTree; static std::tr1::shared_ptr< RecordingsList > m_recList; static std::tr1::shared_ptr< DirectoryList > m_recDirs; - static int m_recordingsState; + static time_t m_recordingsState; + static std::string m_UpdateFileName; cThreadLock m_recordingsLock; }; -- cgit v1.2.3