From 527f11d4de80498724cf60c25a3ff1698892a2ea Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sun, 28 Feb 2016 23:08:52 +0100 Subject: [PATCH] - adzap: move code to determinate monitorLifeTime to own function --- src/gui/adzap.cpp | 33 ++++++++++++++++++++------------- src/gui/adzap.h | 2 ++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/gui/adzap.cpp b/src/gui/adzap.cpp index 2fde271b1..845bb1f36 100644 --- a/src/gui/adzap.cpp +++ b/src/gui/adzap.cpp @@ -84,25 +84,32 @@ void CAdZapMenu::Init() CChannelList *channelList = CNeutrinoApp::getInstance()->channelList; channelId = channelList ? channelList->getActiveChannel_ChannelID() : -1; channelName = channelList->getActiveChannelName(); - CChannelEventList evtlist; + evtlist.clear(); CEitManager::getInstance()->getEventsServiceKey(channelId & 0xFFFFFFFFFFFFULL, evtlist); monitorLifeTime.tv_sec = 0; if (!evtlist.empty()) { sort(evtlist.begin(), evtlist.end(), sortByDateTime); - CChannelEventList::iterator eli; - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - for (eli = evtlist.begin(); eli != evtlist.end(); ++eli) - { - if ((u_int) eli->startTime + (u_int) eli->duration > (u_int) ts.tv_sec) - { - monitorLifeTime.tv_sec = (uint) eli->startTime + eli->duration; - Update(); - break; - } - } + monitorLifeTime.tv_sec = getMonitorLifeTime(); + Update(); } + printf("CAdZapMenu::%s: monitorLifeTime.tv_sec: %d\n", __func__, (uint) monitorLifeTime.tv_sec); +} + +time_t CAdZapMenu::getMonitorLifeTime() +{ + if (evtlist.empty()) + return 0; + + CChannelEventList::iterator eli; + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + for (eli = evtlist.begin(); eli != evtlist.end(); ++eli) + { + if ((u_int) eli->startTime + (u_int) eli->duration > (u_int) ts.tv_sec) + return (uint) eli->startTime + eli->duration; + } + return 0; } void CAdZapMenu::Update() diff --git a/src/gui/adzap.h b/src/gui/adzap.h index ccf6ad7a3..af0ed495e 100644 --- a/src/gui/adzap.h +++ b/src/gui/adzap.h @@ -43,11 +43,13 @@ class CAdZapMenu: public CMenuTarget struct timespec zapBackTime; std::string channelName; CMenuForwarder *forwarders[9]; + CChannelEventList evtlist; struct timespec monitorLifeTime; t_channel_id channelId; sem_t sem; CAdZapMenu(); void Init(); + time_t getMonitorLifeTime(); void Settings(); void Update(); void Run(void);