From 3d13eb002fbfe7b303f0f873e59623cb448dff5f Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 16 Apr 2021 16:26:47 +0200 Subject: [PATCH] Now making sure that spawned timers with reduced start/stop margins actually record with the full margins --- HISTORY | 4 +++- MANUAL | 3 +++ timers.c | 31 ++++++++++++++++++++++--------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/HISTORY b/HISTORY index 78b081a8..9ce48e20 100644 --- a/HISTORY +++ b/HISTORY @@ -9641,7 +9641,7 @@ Video Disk Recorder Revision History - No longer switching devices for pattern timers (thanks to Helmut Binder). - cTimer::TriggerRespawn() now only acts on local timers. -2021-04-13: +2021-04-16: - When spawning pattern timers, the new function cTimers::GetTimerForEvent() is now used to check whether a matching event already has a local spawned timer. Reason: creating a timer @@ -9654,3 +9654,5 @@ Video Disk Recorder Revision History - Fixed dropping outdated events. - To avoid problems with very short events, non-VPS pattern timers now spawn timers for all matching events that would start while the first one is still recording. +- Now making sure that spawned timers with reduced start/stop margins actually record with + the full margins. diff --git a/MANUAL b/MANUAL index 4553b78b..d916bc23 100644 --- a/MANUAL +++ b/MANUAL @@ -556,6 +556,9 @@ The following rules apply to pattern timers: - Recording is done according to the event's begin/end times, either by adding the start/stop margins (for non-VPS timers) or by using the event's running status (for VPS timers). +- If the start/stop margins of a spawned timer are reduced because the event + before and/or after that timer's event is shorter than the respective margin, + the actual recording still uses the full margins. - If the times of the event change, a non-VPS pattern timer automatically adjusts itself to the new times. This also happens if the start/stop margins are changed in the setup. diff --git a/timers.c b/timers.c index c1e5bf99..a3931d3a 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.12 2021/04/13 13:54:00 kls Exp $ + * $Id: timers.c 5.13 2021/04/16 16:26:47 kls Exp $ */ #include "timers.h" @@ -604,14 +604,27 @@ bool cTimer::Matches(time_t t, bool Directly, int Margin) const deferred = 0; if (HasFlags(tfActive)) { - if (HasFlags(tfVps) && event && event->Vps()) { - if (Margin || !Directly) { - startTime = event->StartTime(); - stopTime = event->EndTime(); - if (!Margin) { // this is an actual check - if (event->Schedule()->PresentSeenWithin(EITPRESENTFOLLOWINGRATE)) // VPS control can only work with up-to-date events... - return event->IsRunning(true); - return startTime <= t && t < stopTime; // ...otherwise we fall back to normal timer handling + if (event) { + if (HasFlags(tfVps)) { + if (event->Vps()) { + if (Margin || !Directly) { + startTime = event->StartTime(); + stopTime = event->EndTime(); + if (!Margin) { // this is an actual check + if (event->Schedule()->PresentSeenWithin(EITPRESENTFOLLOWINGRATE)) // VPS control can only work with up-to-date events... + return event->IsRunning(true); + // ...otherwise we fall back to normal timer handling below (note: Margin == 0!) + } + } + } + } + else if (HasFlags(tfSpawned)) { + if (!Margin && !Directly) { // this is an actual check + // The spawned timer's start-/stopTimes are adjusted to the event's times in AdjustSpawnedTimer(). + // However, in order to make sure the timer is set to the correct event, the margins at begin + // end end are limited by the durations of the events before and after this timer's event. + // The recording, though, shall always use the full start/stop margins, hence this calculation: + return event->StartTime() - Setup.MarginStart * 60 <= t && t < event->EndTime() + Setup.MarginStop * 60; } } }