From 8f1419fff59acea5c57e861819111cfc38dd193d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 4 Apr 2021 13:38:13 +0200 Subject: [PATCH] The margins for timer recordings are now always limited to the duration of the previous and next event --- HISTORY | 2 ++ MANUAL | 3 +++ timers.c | 34 +++++++++++++++++++++------------- timers.h | 3 ++- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/HISTORY b/HISTORY index db58eb7e..c9221d39 100644 --- a/HISTORY +++ b/HISTORY @@ -9631,3 +9631,5 @@ Video Disk Recorder Revision History causes a new event to be created, but rather modifies the existing one. This avoids possible interruptions in VPS recordings in case the event's start time is changed while the recording is already going on. +- The margins for timer recordings are now always limited to the duration of the + previous and next event. diff --git a/MANUAL b/MANUAL index 9377f93a..aee21821 100644 --- a/MANUAL +++ b/MANUAL @@ -1023,6 +1023,9 @@ timer, making "TITLE - EPISODE" and "TITLE: EPISODE" the same. after the official end time it shall stop recording. These margins are added automatically to timers that are created from the EPG data. + Note that the actual margins used may be smaller than the + given values, if the event before and/or after the event + to be recorded is shorter than the respective margin. Default priority = 50 The default Priority and Lifetime values used when Default lifetime = 99 creating a new timer event. A Lifetime value of 99 diff --git a/timers.c b/timers.c index 5c794309..6b881fd1 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.5 2021/01/19 13:21:51 kls Exp $ + * $Id: timers.c 5.6 2021/04/04 13:38:13 kls Exp $ */ #include "timers.h" @@ -58,8 +58,11 @@ cTimer::cTimer(bool Instant, bool Pause, const cChannel *Channel) tstart = Event->Vps(); } else { - tstop += Setup.MarginStop * 60; - tstart -= Setup.MarginStart * 60; + int MarginStart = 0; + int MarginStop = 0; + CalcMargins(MarginStart, MarginStop, Event); + tstart -= MarginStart; + tstop += MarginStop; } day = SetTime(tstart, 0); struct tm *time = localtime_r(&tstart, &tm_r); @@ -191,16 +194,9 @@ cTimer::cTimer(const cEvent *Event, const char *FileName, const cTimer *PatternT time_t tstart = (flags & tfVps) ? Event->Vps() : Event->StartTime(); time_t tstop = tstart + Event->Duration(); if (!(HasFlags(tfVps))) { - int MarginStart = Setup.MarginStart * 60; - int MarginStop = Setup.MarginStop * 60; - if (PatternTimer) { - // To make sure a spawned timer gets assigned to the correct event, we must - // make sure that this is the only event that overlaps 100%: - if (const cEvent *e = dynamic_cast(Event->Prev())) - MarginStart = max(0, min(MarginStart, e->Duration() - 60)); - if (const cEvent *e = dynamic_cast(Event->Next())) - MarginStop = max(0, min(MarginStop, e->Duration() - 60)); - } + int MarginStart = 0; + int MarginStop = 0; + CalcMargins(MarginStart, MarginStop, Event); tstart -= MarginStart; tstop += MarginStop; } @@ -273,6 +269,18 @@ cTimer& cTimer::operator= (const cTimer &Timer) return *this; } +void cTimer::CalcMargins(int &MarginStart, int &MarginStop, const cEvent *Event) +{ + MarginStart = Setup.MarginStart * 60; + MarginStop = Setup.MarginStop * 60; + // To make sure the timer gets assigned to the correct event, we must + // make sure that this is the only event that overlaps 100%: + if (const cEvent *e = dynamic_cast(Event->Prev())) + MarginStart = max(0, min(MarginStart, e->Duration() - 60)); + if (const cEvent *e = dynamic_cast(Event->Next())) + MarginStop = max(0, min(MarginStop, e->Duration() - 60)); +} + int cTimer::Compare(const cListObject &ListObject) const { const cTimer *ti = (const cTimer *)&ListObject; diff --git a/timers.h b/timers.h index 72e99531..ae3ab2f6 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.2 2021/01/14 10:29:05 kls Exp $ + * $Id: timers.h 5.3 2021/04/04 13:38:13 kls Exp $ */ #ifndef __TIMERS_H @@ -55,6 +55,7 @@ public: cTimer(const cTimer &Timer); virtual ~cTimer(); cTimer& operator= (const cTimer &Timer); + void CalcMargins(int &MarginStart, int &MarginStop, const cEvent *Event); virtual int Compare(const cListObject &ListObject) const; int Id(void) const { return id; } bool Recording(void) const { return HasFlags(tfRecording); }