Now making sure VPS timers don't get stuck with outdated events, and that the actual device isn't used for updating a VPS timer's event as long as other free devices are available

This commit is contained in:
Klaus Schmidinger 2006-06-16 09:22:20 +02:00
parent 3ed538f496
commit 1d4512cbea
2 changed files with 21 additions and 14 deletions

View File

@ -4783,7 +4783,7 @@ Video Disk Recorder Revision History
so that they can be suppressed in normal operation mode to avoid clogging the so that they can be suppressed in normal operation mode to avoid clogging the
log file in case this function is used frequently (suggested by Helmut Auer). log file in case this function is used frequently (suggested by Helmut Auer).
2006-06-15: Version 1.4.1-1 2006-06-16: Version 1.4.1-1
- Added "-fPIC" to the compiler options in Make.config.template when compiling - Added "-fPIC" to the compiler options in Make.config.template when compiling
plugins (thanks to Udo Richter). If you use your own Make.config file, you may plugins (thanks to Udo Richter). If you use your own Make.config file, you may
@ -4791,3 +4791,6 @@ Video Disk Recorder Revision History
- Added some comment to cDevice::GetDevice() to explain how the individual - Added some comment to cDevice::GetDevice() to explain how the individual
conditions are put together to make a decision on which device to use. conditions are put together to make a decision on which device to use.
- Updated 'S13E' in 'sources.conf' (thanks to Antti Hartikainen). - Updated 'S13E' in 'sources.conf' (thanks to Antti Hartikainen).
- Now making sure VPS timers don't get stuck with outdated events, and that the
actual device isn't used for updating a VPS timer's event as long as other
free devices are available.

30
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/vdr * The project's page is at http://www.cadsoft.de/vdr
* *
* $Id: vdr.c 1.274 2006/06/04 09:04:47 kls Exp $ * $Id: vdr.c 1.275 2006/06/16 09:17:24 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -47,6 +47,7 @@
#include "i18n.h" #include "i18n.h"
#include "interface.h" #include "interface.h"
#include "keys.h" #include "keys.h"
#include "libsi/si.h"
#include "lirc.h" #include "lirc.h"
#include "menu.h" #include "menu.h"
#include "osdbase.h" #include "osdbase.h"
@ -773,10 +774,14 @@ int main(int argc, char *argv[])
bool NeedsTransponder = false; bool NeedsTransponder = false;
if (Timer->HasFlags(tfActive) && !Timer->Recording()) { if (Timer->HasFlags(tfActive) && !Timer->Recording()) {
if (Timer->HasFlags(tfVps)) { if (Timer->HasFlags(tfVps)) {
if (Timer->Matches(Now, true, Setup.VpsMargin)) if (Timer->Matches(Now, true, Setup.VpsMargin)) {
InVpsMargin = true; InVpsMargin = true;
else if (Timer->Event()) Timer->SetInVpsMargin(InVpsMargin);
}
else if (Timer->Event()) {
InVpsMargin = Timer->Event()->StartTime() <= Now && Timer->Event()->RunningStatus() == SI::RunningStatusUndefined;
NeedsTransponder = Timer->Event()->StartTime() - Now < VPSLOOKAHEADTIME * 3600 && !Timer->Event()->SeenWithin(VPSUPTODATETIME); NeedsTransponder = Timer->Event()->StartTime() - Now < VPSLOOKAHEADTIME * 3600 && !Timer->Event()->SeenWithin(VPSUPTODATETIME);
}
else { else {
cSchedulesLock SchedulesLock; cSchedulesLock SchedulesLock;
const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock); const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
@ -790,10 +795,10 @@ int main(int argc, char *argv[])
else else
NeedsTransponder = Timer->Matches(Now, true, TIMERLOOKAHEADTIME); NeedsTransponder = Timer->Matches(Now, true, TIMERLOOKAHEADTIME);
} }
Timer->SetInVpsMargin(InVpsMargin);
if (NeedsTransponder || InVpsMargin) { if (NeedsTransponder || InVpsMargin) {
// Find a device that provides the required transponder: // Find a device that provides the required transponder:
cDevice *Device = NULL; cDevice *Device = NULL;
bool DeviceAvailable = false;
for (int i = 0; i < cDevice::NumDevices(); i++) { for (int i = 0; i < cDevice::NumDevices(); i++) {
cDevice *d = cDevice::GetDevice(i); cDevice *d = cDevice::GetDevice(i);
if (d && d->ProvidesTransponder(Timer->Channel())) { if (d && d->ProvidesTransponder(Timer->Channel())) {
@ -802,18 +807,17 @@ int main(int argc, char *argv[])
Device = d; Device = d;
break; break;
} }
else if (Now - DeviceUsed[d->DeviceNumber()] > TIMERDEVICETIMEOUT) { bool timeout = Now - DeviceUsed[d->DeviceNumber()] > TIMERDEVICETIMEOUT; // only check other devices if they have been left alone for a while
// only check other devices if they have been left alone for a while if (d->MaySwitchTransponder()) {
if (d->MaySwitchTransponder()) DeviceAvailable = true; // avoids using the actual device below
// this one can be switched without disturbing anything else if (timeout)
Device = d; Device = d; // only check other devices if they have been left alone for a while
else if (!Device && InVpsMargin && !d->Receiving() && d->ProvidesTransponderExclusively(Timer->Channel()))
// use this one only if no other with less impact can be found
Device = d;
} }
else if (timeout && !Device && InVpsMargin && !d->Receiving() && d->ProvidesTransponderExclusively(Timer->Channel()))
Device = d; // use this one only if no other with less impact can be found
} }
} }
if (!Device && InVpsMargin) { if (!Device && InVpsMargin && !DeviceAvailable) {
cDevice *d = cDevice::ActualDevice(); cDevice *d = cDevice::ActualDevice();
if (!d->Receiving() && d->ProvidesTransponder(Timer->Channel()) && Now - DeviceUsed[d->DeviceNumber()] > TIMERDEVICETIMEOUT) if (!d->Receiving() && d->ProvidesTransponder(Timer->Channel()) && Now - DeviceUsed[d->DeviceNumber()] > TIMERDEVICETIMEOUT)
Device = d; // use the actual device as a last resort Device = d; // use the actual device as a last resort