diff options
-rw-r--r-- | baserender.c | 38 | ||||
-rw-r--r-- | displaymenu.c | 23 |
2 files changed, 41 insertions, 20 deletions
diff --git a/baserender.c b/baserender.c index 17e2acec..785202eb 100644 --- a/baserender.c +++ b/baserender.c @@ -9,6 +9,34 @@ #include <ft2build.h> #include FT_FREETYPE_H +#if VDRVERSNUM >= 20301 +#include <vdr/thread.h> + +class cRecCounter : public cThread +{ + private: + int numRec; + cCondWait condWait; + cRecCounter() { numRec = 0; } + protected: + void Action(void) { + LOCK_TIMERS_READ; + for(const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti)) { + if( ti->HasFlags(tfRecording) ) numRec++; + } + condWait.Signal(); + } + public: + static int Count(void) { + cRecCounter rc; + rc.Start(); + if(rc.condWait.Wait(500)) + return rc.numRec; + return 0; + } +}; +#endif + cFlatBaseRender::cFlatBaseRender(void) { font = cFont::CreateFont(Setup.FontOsd, Setup.FontOsdSize ); fontSml = cFont::CreateFont(Setup.FontSml, Setup.FontSmlSize); @@ -424,15 +452,11 @@ void cFlatBaseRender::TopBarUpdate(void) { if( Config.TopBarRecordingShow ) { // look for timers #if VDRVERSNUM >= 20301 - LOCK_TIMERS_READ; - for(const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti)) { + numRec = cRecCounter::Count(); #else - for(cTimer *ti = Timers.First(); ti; ti = Timers.Next(ti)) { + for(cTimer *ti = Timers.First(); ti; ti = Timers.Next(ti)) + if( ti->HasFlags(tfRecording) ) numRec++; #endif - if( ti->HasFlags(tfRecording) ) { - numRec++; - } - } if( numRec ) { imgRec = imgLoader.LoadIcon("topbar_timer", topBarFontHeight - marginItem*2, topBarFontHeight - marginItem*2); if( imgRec ) { diff --git a/displaymenu.c b/displaymenu.c index cb873115..15b34571 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -748,12 +748,6 @@ bool cFlatDisplayMenu::SetItemChannel(const cChannel *Channel, int Index, bool C if( Config.MenuChannelView == 0 || !Channel ) return false; -#if VDRVERSNUM >= 20301 - LOCK_SCHEDULES_READ; -#else - cSchedulesLock schedulesLock; - const cSchedules *schedules = cSchedules::Schedules(schedulesLock); -#endif const cEvent *Event = NULL; bool DrawProgress = true; @@ -884,8 +878,11 @@ bool cFlatDisplayMenu::SetItemChannel(const cChannel *Channel, int Index, bool C // event from channel #if VDRVERSNUM >= 20301 + LOCK_SCHEDULES_READ; const cSchedule *Schedule = Schedules->GetSchedule( Channel ); #else + cSchedulesLock schedulesLock; + const cSchedules *schedules = cSchedules::Schedules(schedulesLock); const cSchedule *Schedule = schedules->GetSchedule( Channel->GetChannelID() ); #endif if( Schedule ) { @@ -4424,13 +4421,6 @@ int cFlatDisplayMenu::DrawMainMenuWidgetActiveTimers(int wLeft, int wWidth, int //check if remotetimers plugin is available static cPlugin* pRemoteTimers = cPluginManager::GetPlugin("remotetimers"); -#if VDRVERSNUM >= 20301 - LOCK_SCHEDULES_READ; -#else - cSchedulesLock SchedulesLock; - const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock); -#endif - time_t now; time(&now); if( (Config.MainMenuWidgetActiveTimerShowRemoteActive || Config.MainMenuWidgetActiveTimerShowRemoteRecording) && pRemoteTimers && (now - remoteTimersLastRefresh) > Config.MainMenuWidgetActiveTimerShowRemoteRefreshTime ) { @@ -4459,6 +4449,13 @@ int cFlatDisplayMenu::DrawMainMenuWidgetActiveTimers(int wLeft, int wWidth, int if( timerRec.Size() + timerActive.Size() >= Config.MainMenuWidgetActiveTimerMaxCount ) break; } + +#if VDRVERSNUM >= 20301 + LOCK_SCHEDULES_READ; +#else + cSchedulesLock SchedulesLock; + const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock); +#endif if( (Config.MainMenuWidgetActiveTimerShowRemoteActive || Config.MainMenuWidgetActiveTimerShowRemoteRecording) && pRemoteTimers && timerRec.Size() + timerActive.Size() < Config.MainMenuWidgetActiveTimerMaxCount ) { cTimer* remoteTimer = NULL; |