From 07dc53331e62b29cc7659a23de4d7348f4788bd7 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 14 Mar 2004 13:27:57 +0100 Subject: [PATCH] Removed cSchedule::GetEventNumber() and cSchedule::NumEvents() --- HISTORY | 2 ++ epg.h | 5 ++--- menu.c | 6 ++---- timers.c | 26 ++++++++++++-------------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/HISTORY b/HISTORY index d140769f..5baa14c2 100644 --- a/HISTORY +++ b/HISTORY @@ -2739,3 +2739,5 @@ Video Disk Recorder Revision History - Fixed detecting the running status in case an empty EPG event is broadcast (thanks to Michael Pennewiß for pointing this out). - Improved performance when paging through very long menu lists. +- Removed cSchedule::GetEventNumber() and cSchedule::NumEvents(). There is now + cSchedule::Events() that returns the list of events directly. diff --git a/epg.h b/epg.h index 74e5c0bd..9a6547ef 100644 --- a/epg.h +++ b/epg.h @@ -7,7 +7,7 @@ * Original version (as used in VDR before 1.3.0) written by * Robert Schneider and Rolf Hakenes . * - * $Id: epg.h 1.14 2004/03/13 13:39:13 kls Exp $ + * $Id: epg.h 1.15 2004/03/14 13:25:39 kls Exp $ */ #ifndef __EPG_H @@ -90,12 +90,11 @@ public: void Cleanup(time_t Time); void Cleanup(void); cEvent *AddEvent(cEvent *Event); + const cList *Events(void) const { return &events; } const cEvent *GetPresentEvent(bool CheckRunningStatus = false) const; const cEvent *GetFollowingEvent(bool CheckRunningStatus = false) const; const cEvent *GetEvent(u_int16_t EventID, time_t StartTime = 0) const; const cEvent *GetEventAround(time_t Time) const; - const cEvent *GetEventNumber(int n) const { return events.Get(n); } - int NumEvents(void) const { return events.Count(); } void Dump(FILE *f, const char *Prefix = "", eDumpMode DumpMode = dmAll, time_t AtTime = 0) const; static bool Read(FILE *f, cSchedules *Schedules); }; diff --git a/menu.c b/menu.c index 72030664..4fdb994b 100644 --- a/menu.c +++ b/menu.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.296 2004/03/14 10:31:13 kls Exp $ + * $Id: menu.c 1.297 2004/03/14 13:24:02 kls Exp $ */ #include "menu.h" @@ -1380,10 +1380,8 @@ void cMenuSchedule::PrepareSchedule(cChannel *Channel) const cSchedule *Schedule = schedules->GetSchedule(Channel->GetChannelID()); if (Schedule) { const cEvent *PresentEvent = Schedule->GetPresentEvent(Channel->Number() == cDevice::CurrentChannel()); - int num = Schedule->NumEvents(); time_t now = time(NULL) - Setup.EPGLinger * 60; - for (int a = 0; a < num; a++) { - const cEvent *Event = Schedule->GetEventNumber(a); + for (const cEvent *Event = Schedule->Events()->First(); Event; Event = Schedule->Events()->Next(Event)) { if (Event->EndTime() > now || Event == PresentEvent) Add(new cMenuScheduleItem(Event), Event == PresentEvent); } diff --git a/timers.c b/timers.c index 02765800..69693650 100644 --- a/timers.c +++ b/timers.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.c 1.11 2004/03/06 11:22:57 kls Exp $ + * $Id: timers.c 1.12 2004/03/14 13:27:57 kls Exp $ */ #include "timers.h" @@ -506,7 +506,7 @@ cTimer *cTimers::GetNextActiveTimer(void) void cTimers::SetEvents(void) { - cSchedulesLock SchedulesLock; + cSchedulesLock SchedulesLock(false, 100); const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock); if (Schedules) { for (cTimer *ti = First(); ti; ti = Next(ti)) { @@ -514,19 +514,17 @@ void cTimers::SetEvents(void) const cEvent *Event = NULL; if (Schedule) { //XXX what if the Schedule doesn't have any VPS??? - const cEvent *e; int Match = tmNone; - int i = 0; - while ((e = Schedule->GetEventNumber(i++)) != NULL) { - int m = ti->Matches(e); - if (m > Match) { - Match = m; - Event = e; - if (Match == tmFull) - break; - //XXX what if there's another event with the same VPS time??? - } - } + for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e)) { + int m = ti->Matches(e); + if (m > Match) { + Match = m; + Event = e; + if (Match == tmFull) + break; + //XXX what if there's another event with the same VPS time??? + } + } } ti->SetEvent(Event); }