From 5a626fef9fe43ecdde2fb2febb66b78e8eb12185 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 11 Oct 2024 13:58:11 +0200 Subject: [PATCH] Fixed expiring of one-time VPS timers in case there is more than one event with the same VPS time --- CONTRIBUTORS | 2 ++ HISTORY | 4 +++- timers.c | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7119b906..2b214094 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2587,6 +2587,8 @@ Markus Ehrnsperger at the same time get a new event ID for reporting a bug in handling negative values in cSource::Position() on systems where 'int' is 64 bit + for suggesting a fix for expiring of one-time VPS timers in case there is more than + one event with the same VPS time Werner Färber for reporting a bug in handling the cPluginManager::Active() result when pressing diff --git a/HISTORY b/HISTORY index 244eae42..4e91ee50 100644 --- a/HISTORY +++ b/HISTORY @@ -10021,10 +10021,12 @@ Video Disk Recorder Revision History - Fixed a problem with duplicate events if they are moved to a lower table ID and at the same time get a new event ID (reported by Markus Ehrnsperger). -2024-10-09: +2024-10-11: - Removed defining DEPRECATED_* macros with value 0, because this is the preprocessor's default (suggested by Winfried Köhler). - Fixed error checking in case of large PTS discontinuities (reported by Matthias Senzel). - Fixed handling negative values in cSource::Position() on systems where 'int' is 64 bit (reported by Markus Ehrnsperger, fix suggested by Winfried Köhler). +- Fixed expiring of one-time VPS timers in case there is more than one event with the + same VPS time (suggested by Markus Ehrnsperger). diff --git a/timers.c b/timers.c index 696724a5..eb094b69 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 5.20 2024/03/06 14:37:15 kls Exp $ + * $Id: timers.c 5.21 2024/10/11 13:58:11 kls Exp $ */ #include "timers.h" @@ -726,10 +726,39 @@ eTimerMatch cTimer::Matches(const cEvent *Event, int *Overlap) const bool cTimer::Expired(void) const { if (IsSingleEvent() && !Recording()) { + time_t Now = time(NULL); time_t ExpireTime = StopTimeEvent(); - if (HasFlags(tfVps)) + if (HasFlags(tfVps)) { ExpireTime += EXPIRELATENCY; - return ExpireTime <= time(NULL); + if (ExpireTime <= Now) { + LOCK_SCHEDULES_READ; + const cSchedule *Schedule = event ? event->Schedule() : NULL; + const cEvent *FirstEvent = event; + if (Schedule) + FirstEvent = Schedule->Events()->Next(FirstEvent); + else if ((Schedule = Schedules->GetSchedule(Channel())) != NULL) { + FirstEvent = Schedule->Events()->First(); + if (FirstEvent) + dsyslog("timer %s had no event, got %s from channel/schedule", *ToDescr(), *FirstEvent->ToDescr()); + } + if (FirstEvent) { + if (Schedule) { + for (const cEvent *e = FirstEvent; e; e = Schedule->Events()->Next(e)) { + if (e->Vps() == startTime) { + ExpireTime = e->EndTime() + EXPIRELATENCY; + dsyslog("timer %s is waiting for next VPS event %s", *ToDescr(), *e->ToDescr()); + // no break here - let's play it safe and look at *all* events + } + } + } + } + else { + dsyslog("timer %s has no event, setting expiration to +24h", *ToDescr()); + ExpireTime += 3600 * 24; + } + } + } + return ExpireTime <= Now; } return false; }