diff options
Diffstat (limited to 'update.c')
-rw-r--r-- | update.c | 55 |
1 files changed, 54 insertions, 1 deletions
@@ -93,6 +93,7 @@ cUpdate::cUpdate(cPluginEPG2VDR* aPlugin) manualTrigger = no; videoBasePath = 0; dbReconnectTriggered = no; + switchTimerTrigger = no; fullreload = no; epgdBusy = yes; @@ -830,6 +831,20 @@ int cUpdate::exitDb() } //*************************************************************************** +// Send Event +//*************************************************************************** + +void cUpdate::sendEvent(int event, void* userData) +{ + cUpdate* update = (cUpdate*)userData; + cMutexLock lock(&update->eventHookMutex); + + update->eventHook.push(event); + tell(3, "sendEvent(%d)", event); + update->waitCondition.Broadcast(); +} + +//*************************************************************************** // Check Connection //*************************************************************************** @@ -1239,6 +1254,39 @@ void cUpdate::Stop() Cancel(10); // wait up to 10 seconds for thread was stopping } +void cUpdate::processEvents() +{ + cMutexLock lock(&eventHookMutex); + + while (!eventHook.empty()) + { + int event = eventHook.front(); + eventHook.pop(); + + switch (event) + { + case evtSwitchTimer: + { + switchTimerTrigger = yes; + break; + } + } + } + + for (auto it = timerThreads.begin(); it != timerThreads.end(); ) + { + if (!(*it)->isActive()) + { + delete *it; + it = timerThreads.erase(it); + } + else + { + it++; + } + } +} + //*************************************************************************** // Action //*************************************************************************** @@ -1265,6 +1313,10 @@ void cUpdate::Action() waitCondition.TimedWait(mutex, 60*1000); + // first process events + + processEvents(); + // we pass here at least once per minute ... if (checkConnection(reconnectTimeout) != success) @@ -1272,7 +1324,8 @@ void cUpdate::Action() // switch timer - checkSwitchTimer(); + if (switchTimerTrigger) + checkSwitchTimer(); // recording stuff |