summaryrefslogtreecommitdiff
path: root/timers.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-04-09 09:12:47 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2006-04-09 09:12:47 +0200
commitbfce2b3dba4f4f7f4e6b009b34b2467d3eef6542 (patch)
treef525c931f3f71ff5c4755785ffc94115bb06e9f5 /timers.c
parent24b3579d149a45fa3b09cc22aa09a6ac053bd392 (diff)
downloadvdr-bfce2b3dba4f4f7f4e6b009b34b2467d3eef6542.tar.gz
vdr-bfce2b3dba4f4f7f4e6b009b34b2467d3eef6542.tar.bz2
Fixed VPS recording in case there is more than one timer in the VPS margin
Diffstat (limited to 'timers.c')
-rw-r--r--timers.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/timers.c b/timers.c
index 6439c0ea..f620735f 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.56 2006/04/01 13:27:14 kls Exp $
+ * $Id: timers.c 1.57 2006/04/09 09:10:08 kls Exp $
*/
#include "timers.h"
@@ -330,7 +330,7 @@ char *cTimer::SetFile(const char *File)
return file;
}
-bool cTimer::Matches(time_t t, bool Directly) const
+bool cTimer::Matches(time_t t, bool Directly, int Margin) const
{
startTime = stopTime = 0;
if (t == 0)
@@ -370,7 +370,7 @@ bool cTimer::Matches(time_t t, bool Directly) const
stopTime = event->EndTime();
return event->IsRunning(true);
}
- return startTime <= t && t < stopTime; // must stop *before* stopTime to allow adjacent timers
+ return startTime <= t + Margin && t < stopTime; // must stop *before* stopTime to allow adjacent timers
}
return false;
}
@@ -450,19 +450,24 @@ void cTimer::SetEventFromSchedule(const cSchedules *Schedules)
if (Schedule && Schedule->Events()->First()) {
time_t now = time(NULL);
if (!lastSetEvent || Schedule->Modified() >= lastSetEvent) {
+ lastSetEvent = now;
const cEvent *Event = NULL;
if (HasFlags(tfVps) && Schedule->Events()->First()->Vps()) {
+ if (event && Recording())
+ return; // let the recording end first
// VPS timers only match if their start time exactly matches the event's VPS time:
for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e)) {
- if (e->RunningStatus() == SI::RunningStatusNotRunning)
- continue; // skip events that have already stopped
- int overlap = 0;
- Matches(e, &overlap);
- if (overlap > FULLMATCH) {
- Event = e;
- break; // take the first matching event
+ if (e->StartTime() && e->RunningStatus() != SI::RunningStatusNotRunning) { // skip outdated events
+ int overlap = 0;
+ Matches(e, &overlap);
+ if (overlap > FULLMATCH) {
+ Event = e;
+ break; // take the first matching event
+ }
}
}
+ if (!Event && event && (now <= event->EndTime() || Matches(0, true)))
+ return; // stay with the old event until the timer has completely expired
}
else {
// Normal timers match the event they have the most overlap with:
@@ -487,7 +492,6 @@ void cTimer::SetEventFromSchedule(const cSchedules *Schedules)
}
}
SetEvent(Event);
- lastSetEvent = now;
}
}
}