From 0c654ed2a790bef5a7529b06a6b3ce7a84e5c099 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Thu, 10 Jul 2025 19:12:24 +0200 Subject: [PATCH] Added cTimer::VpsTime() --- CONTRIBUTORS | 1 + HISTORY | 3 ++- timers.c | 14 +++++++++++--- timers.h | 5 ++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index dd75e024..b6c5c414 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2604,6 +2604,7 @@ Markus Ehrnsperger for reporting that cTimer::StartTime() may return different values, depending on the parameters of a previous call to cTimer::Matches() for fixing the stop time of repeating timers in case of DST change + for suggesting to add cTimer::VpsTime() Werner Färber for reporting a bug in handling the cPluginManager::Active() result when pressing diff --git a/HISTORY b/HISTORY index 9b90b0e9..ed29299c 100644 --- a/HISTORY +++ b/HISTORY @@ -10138,7 +10138,7 @@ Video Disk Recorder Revision History - Fixed an invalid lock sequence when pressing the Channel+/Channel- keys while in the "What's on..." menu in live view. -2025-07-09: +2025-07-10: - Fixed cPoller::Poll() to allow negative timeout values again. - When regenerating the index of a recording, PID changes are now taken into account @@ -10168,3 +10168,4 @@ Video Disk Recorder Revision History - Fixed expiring VPS timers in case the event has not yet startet after its announced end time. - Reverted the change in cCondWait::SleepMs() because of a possible lockup (reported by Johann Friedrichs). +- Added cTimer::VpsTime() (suggested by Markus Ehrnsperger). diff --git a/timers.c b/timers.c index b9eb3e86..f04d57de 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.28 2025/07/09 14:49:59 kls Exp $ + * $Id: timers.c 5.29 2025/07/10 19:12:24 kls Exp $ */ #include "timers.h" @@ -608,6 +608,13 @@ void cTimer::CalcStartStopTime(time_t &startTime, time_t &stopTime, time_t t) co } } +time_t cTimer::VpsTime(time_t t) const +{ + time_t startTime, stopTime; + CalcStartStopTime(startTime, stopTime, t); + return startTime; +} + #if DEPRECATED_TIMER_MATCHES bool cTimer::Matches(time_t t, bool Directly) const { @@ -797,8 +804,9 @@ bool cTimer::Expired(void) const } if (FirstEvent) { if (Schedule) { + time_t Vps = VpsTime(); for (const cEvent *e = FirstEvent; e; e = Schedule->Events()->Next(e)) { - if (e->Vps() == StartTime()) { + if (e->Vps() == Vps) { 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 @@ -1132,7 +1140,7 @@ bool cTimer::HasFlags(uint Flags) const void cTimer::Skip(void) { cMutexLock MutexLock(&mutex); - day = IncDay(SetTime(StartTime(), 0), 1); + day = IncDay(SetTime(VpsTime(), 0), 1); startTime = 0; SetEvent(NULL); } diff --git a/timers.h b/timers.h index ced66fcb..9b52869c 100644 --- a/timers.h +++ b/timers.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.h 5.13 2025/07/06 15:06:55 kls Exp $ + * $Id: timers.h 5.14 2025/07/10 19:12:24 kls Exp $ */ #ifndef __TIMERS_H @@ -100,6 +100,9 @@ public: ///< Calculates the raw start and stop time of this timer, as given by the user in the timer definition. ///< If t is given, and this is a repeating timer, the start and stop times on that day are returned ///< (default is "today"). t can be any time_t value on the given day. + time_t VpsTime(time_t t = 0) const; + ///< Returns the VPS time of this timer. This is a shortcut for calling CalcStartStopTime() and using the + ///< result given in the startTime parameter. The parameter t is handed to CalcStartStopTime(). #define DEPRECATED_TIMER_MATCHES 1 #if DEPRECATED_TIMER_MATCHES // for backwards compatibility, remove these functions once Matches(time_t ...) has default parameters: