summaryrefslogtreecommitdiff
path: root/vdr.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-05-07 09:13:36 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2006-05-07 09:13:36 +0200
commit465ddf3ffcf55728608d0442f23516262a5e26f4 (patch)
tree1a6e17167ba9c067132f0b5e9a76690f75d7c77b /vdr.c
parent93d0120c3f2ae70c4d7c1887f5418e235455c857 (diff)
downloadvdr-465ddf3ffcf55728608d0442f23516262a5e26f4.tar.gz
vdr-465ddf3ffcf55728608d0442f23516262a5e26f4.tar.bz2
If VPS timers are active, their events are now being kept up to date
Diffstat (limited to 'vdr.c')
-rw-r--r--vdr.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/vdr.c b/vdr.c
index fc0e360c..ea762d38 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.cadsoft.de/vdr
*
- * $Id: vdr.c 1.268 2006/05/05 13:43:32 kls Exp $
+ * $Id: vdr.c 1.269 2006/05/07 09:13:36 kls Exp $
*/
#include <getopt.h>
@@ -74,6 +74,8 @@
#define SHUTDOWNRETRY 300 // seconds before trying again to shut down
#define VPSCHECKDELTA 10 // seconds between checks for timers that have entered the VPS margin
#define VPSDEVICETIMEOUT 8 // seconds before a device used for VPS may be reused
+#define VPSLOOKAHEADTIME 24 // hours within which VPS timers will make sure their events are up to date
+#define VPSUPTODATETIME 3600 // seconds before the event or schedule of a VPS timer needs to be refreshed
#define EXIT(v) { ExitCode = (v); goto Exit; }
@@ -762,8 +764,24 @@ int main(int argc, char *argv[])
TimerInVpsMargin = false;
static time_t DeviceUsed[MAXDEVICES] = { 0 };
for (cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer)) {
- if (Timer->HasFlags(tfActive | tfVps) && !Timer->Recording() && Timer->Matches(Now, true, Setup.VpsMargin)) {
- Timer->SetInVpsMargin(true);
+ bool InVpsMargin = false;
+ bool NeedsTransponder = false;
+ if (Timer->HasFlags(tfActive | tfVps) && !Timer->Recording()) {
+ if (Timer->Matches(Now, true, Setup.VpsMargin))
+ TimerInVpsMargin = InVpsMargin = true;
+ else if (Timer->Event())
+ NeedsTransponder = Timer->Event()->StartTime() - Now < VPSLOOKAHEADTIME * 3600 && !Timer->Event()->SeenWithin(VPSUPTODATETIME);
+ else {
+ cSchedulesLock SchedulesLock;
+ const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
+ if (Schedules) {
+ const cSchedule *Schedule = Schedules->GetSchedule(Timer->Channel());
+ NeedsTransponder = Schedule && !Schedule->PresentSeenWithin(VPSUPTODATETIME);
+ }
+ }
+ }
+ Timer->SetInVpsMargin(InVpsMargin);
+ if (NeedsTransponder || InVpsMargin) {
// Find a device that provides the required transponder:
cDevice *Device = NULL;
for (int i = 0; i < cDevice::NumDevices(); i++) {
@@ -785,7 +803,7 @@ int main(int argc, char *argv[])
}
}
}
- if (!Device) {
+ if (!Device && InVpsMargin) {
cDevice *d = cDevice::ActualDevice();
if (!d->Receiving() && d->ProvidesTransponder(Timer->Channel()) && Now - DeviceUsed[d->DeviceNumber()] > VPSDEVICETIMEOUT)
Device = d; // use the actual device as a last resort
@@ -805,10 +823,7 @@ int main(int argc, char *argv[])
Skins.Message(mtInfo, tr("Upcoming VPS recording!"));
}
}
- TimerInVpsMargin = true;
}
- else
- Timer->SetInVpsMargin(false);
}
LastVpsCheck = time(NULL);
}