summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasmin Jessich <jasmin@anw.at>2017-06-17 23:38:14 +0200
committerJasmin Jessich <jasmin@anw.at>2017-06-17 23:38:14 +0200
commit00e2a4d8f46a67f2eb5549fc9be6631c1e142490 (patch)
tree80430c7cfceaec2b2da85713ea42f6f10cbd9eb7
parent9bebbad537dfedc7d143b35d1d01dc9cc7b68b5f (diff)
downloadvdr-plugin-live-00e2a4d8f46a67f2eb5549fc9be6631c1e142490.tar.gz
vdr-plugin-live-00e2a4d8f46a67f2eb5549fc9be6631c1e142490.tar.bz2
Use a cStateKey for SortedTimers::Modified changed detection
- Added SortedTimers::m_TimersStateKey to store the last timers list state. - SortedTimers::Modified uses now the new m_TimersStateKey to check, if the list has been modified.
-rw-r--r--timers.cpp43
-rw-r--r--timers.h8
2 files changed, 21 insertions, 30 deletions
diff --git a/timers.cpp b/timers.cpp
index 7f46cab..bb31ac8 100644
--- a/timers.cpp
+++ b/timers.cpp
@@ -23,10 +23,12 @@ namespace vdrlive {
static char const* const TIMER_DELETE = "DELETE";
static char const* const TIMER_TOGGLE = "TOGGLE";
- SortedTimers::SortedTimers():
- m_state( 0 )
+ SortedTimers::SortedTimers()
+#if VDRVERSNUM < 20301
+ : m_state( 0 )
+#endif
{
- ReloadTimers( true );
+ ReloadTimers();
}
string SortedTimers::GetTimerId( cTimer const& timer )
@@ -62,6 +64,8 @@ namespace vdrlive {
int start = lexical_cast< int >( parts[3] );
int stop = lexical_cast< int >( parts[4] );
+ cMutexLock MutexLock(&m_mutex);
+
for ( SortedTimers::iterator timer = begin(); timer != end(); ++timer ) {
if ( timer->Channel() == channel &&
( ( weekdays != 0 && timer->WeekDays() == weekdays ) || ( weekdays == 0 && timer->Day() == day ) ) &&
@@ -92,10 +96,12 @@ namespace vdrlive {
}
- void SortedTimers::ReloadTimers( bool initial )
+ void SortedTimers::ReloadTimers()
{
// dsyslog("live reloading timers");
+ cMutexLock MutexLock(&m_mutex);
+
clear();
#if VDRVERSNUM >= 20301
{
@@ -159,33 +165,12 @@ namespace vdrlive {
#if VDRVERSNUM >= 20301
bool SortedTimers::Modified()
{
- // the global(!) list of known timers
- static vector<cTimer> knownTimers;
-
bool modified = false;
- LOCK_TIMERS_READ;
- for ( const cTimer* timer = Timers->First(); timer; timer = Timers->Next( timer ) ) {
- bool known_id = false;
- for (vector<cTimer>::iterator it = knownTimers.begin(); it != knownTimers.end(); ++it) {
- if (timer->Id() == it->Id()) {
- known_id = true;
- string timer_txt = *timer->ToText (true);
- string known_txt = *it->ToText (true);
- modified = timer_txt != known_txt;
- break;
- }
- }
- if (!known_id) {
- modified = true;
- break;
- }
- }
- if (modified) {
- knownTimers.clear();
- for (const cTimer* Timer = Timers->First(); Timer; Timer = Timers->Next (Timer)) {
- knownTimers.push_back (*Timer);
- }
+ // will return != 0 only, if the Timers List has been changed since last read
+ if (cTimers::GetTimersRead(m_TimersStateKey)) {
+ modified = true;
+ m_TimersStateKey.Remove();
}
return modified;
diff --git a/timers.h b/timers.h
index 5f62f76..1fc86ff 100644
--- a/timers.h
+++ b/timers.h
@@ -35,9 +35,15 @@ namespace vdrlive {
SortedTimers();
SortedTimers( SortedTimers const& );
+ cMutex m_mutex;
+
+#if VDRVERSNUM >= 20301
+ cStateKey m_TimersStateKey;
+#else
int m_state;
+#endif
- void ReloadTimers( bool initial = false );
+ void ReloadTimers();
};
class TimerManager: public cMutex