1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Now switching to non-VPS timers' channels 60 seconds before the timer starts

This commit is contained in:
Klaus Schmidinger 2006-06-04 09:10:59 +02:00
parent 0d4cf40b79
commit 50c0b03f0c
2 changed files with 33 additions and 25 deletions

View File

@ -4746,7 +4746,7 @@ Video Disk Recorder Revision History
- Fixed deleting channels in case the current channel's number changes (reported - Fixed deleting channels in case the current channel's number changes (reported
by Mirko Dölle). by Mirko Dölle).
2006-06-03: Version 1.4.0-3 2006-06-04: Version 1.4.0-3
- Fixed the PremiereContentTransmissionDescriptor in 'libsi' (thanks to Stefan - Fixed the PremiereContentTransmissionDescriptor in 'libsi' (thanks to Stefan
Huelswitt). Huelswitt).
@ -4773,3 +4773,6 @@ Video Disk Recorder Revision History
- Added some log messages when setting the current skin. - Added some log messages when setting the current skin.
- Only making a second attempt to set the current skin at startup if the first - Only making a second attempt to set the current skin at startup if the first
attempt has failed. attempt has failed.
- Now switching to non-VPS timers' channels 60 seconds before the timer starts
(if a free device is available), to allow for the updating of EPG data and CA
descriptors before the actual recording starts.

53
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.273 2006/06/03 14:46:36 kls Exp $ * $Id: vdr.c 1.274 2006/06/04 09:04:47 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -72,8 +72,9 @@
#define DEVICEREADYTIMEOUT 30 // seconds to wait until all devices are ready #define DEVICEREADYTIMEOUT 30 // seconds to wait until all devices are ready
#define MENUTIMEOUT 120 // seconds of user inactivity after which an OSD display is closed #define MENUTIMEOUT 120 // seconds of user inactivity after which an OSD display is closed
#define SHUTDOWNRETRY 300 // seconds before trying again to shut down #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 TIMERCHECKDELTA 10 // seconds between checks for timers that need to see their channel
#define VPSDEVICETIMEOUT 8 // seconds before a device used for VPS may be reused #define TIMERDEVICETIMEOUT 8 // seconds before a device used for timer check may be reused
#define TIMERLOOKAHEADTIME 60 // seconds before a non-VPS timer starts and the channel is switched if possible
#define VPSLOOKAHEADTIME 24 // hours within which VPS timers will make sure their events are up to date #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 VPSUPTODATETIME 3600 // seconds before the event or schedule of a VPS timer needs to be refreshed
@ -502,7 +503,7 @@ int main(int argc, char *argv[])
int MaxLatencyTime = 0; int MaxLatencyTime = 0;
bool ForceShutdown = false; bool ForceShutdown = false;
bool UserShutdown = false; bool UserShutdown = false;
bool TimerInVpsMargin = false; bool InhibitEpgScan = false;
bool IsInfoMenu = false; bool IsInfoMenu = false;
cSkin *CurrentSkin = NULL; cSkin *CurrentSkin = NULL;
@ -762,28 +763,32 @@ int main(int argc, char *argv[])
else else
LastTimerChannel = Timer->Channel()->Number(); LastTimerChannel = Timer->Channel()->Number();
} }
// Make sure VPS timers "see" their channel early enough: // Make sure timers "see" their channel early enough:
static time_t LastVpsCheck = 0; static time_t LastTimerCheck = 0;
if (Now - LastVpsCheck > VPSCHECKDELTA) { // don't do this too often if (Now - LastTimerCheck > TIMERCHECKDELTA) { // don't do this too often
TimerInVpsMargin = false; InhibitEpgScan = false;
static time_t DeviceUsed[MAXDEVICES] = { 0 }; static time_t DeviceUsed[MAXDEVICES] = { 0 };
for (cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer)) { for (cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer)) {
bool InVpsMargin = false; bool InVpsMargin = false;
bool NeedsTransponder = false; bool NeedsTransponder = false;
if (Timer->HasFlags(tfActive | tfVps) && !Timer->Recording()) { if (Timer->HasFlags(tfActive) && !Timer->Recording()) {
if (Timer->Matches(Now, true, Setup.VpsMargin)) if (Timer->HasFlags(tfVps)) {
InVpsMargin = true; if (Timer->Matches(Now, true, Setup.VpsMargin))
else if (Timer->Event()) InVpsMargin = true;
NeedsTransponder = Timer->Event()->StartTime() - Now < VPSLOOKAHEADTIME * 3600 && !Timer->Event()->SeenWithin(VPSUPTODATETIME); else if (Timer->Event())
else { NeedsTransponder = Timer->Event()->StartTime() - Now < VPSLOOKAHEADTIME * 3600 && !Timer->Event()->SeenWithin(VPSUPTODATETIME);
cSchedulesLock SchedulesLock; else {
const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock); cSchedulesLock SchedulesLock;
if (Schedules) { const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
const cSchedule *Schedule = Schedules->GetSchedule(Timer->Channel()); if (Schedules) {
NeedsTransponder = Schedule && !Schedule->PresentSeenWithin(VPSUPTODATETIME); const cSchedule *Schedule = Schedules->GetSchedule(Timer->Channel());
NeedsTransponder = Schedule && !Schedule->PresentSeenWithin(VPSUPTODATETIME);
}
} }
InhibitEpgScan |= InVpsMargin | NeedsTransponder;
} }
TimerInVpsMargin |= InVpsMargin | NeedsTransponder; else
NeedsTransponder = Timer->Matches(Now, true, TIMERLOOKAHEADTIME);
} }
Timer->SetInVpsMargin(InVpsMargin); Timer->SetInVpsMargin(InVpsMargin);
if (NeedsTransponder || InVpsMargin) { if (NeedsTransponder || InVpsMargin) {
@ -797,7 +802,7 @@ int main(int argc, char *argv[])
Device = d; Device = d;
break; break;
} }
else if (Now - DeviceUsed[d->DeviceNumber()] > VPSDEVICETIMEOUT) { else if (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())
// this one can be switched without disturbing anything else // this one can be switched without disturbing anything else
@ -810,7 +815,7 @@ int main(int argc, char *argv[])
} }
if (!Device && InVpsMargin) { if (!Device && InVpsMargin) {
cDevice *d = cDevice::ActualDevice(); cDevice *d = cDevice::ActualDevice();
if (!d->Receiving() && d->ProvidesTransponder(Timer->Channel()) && Now - DeviceUsed[d->DeviceNumber()] > VPSDEVICETIMEOUT) 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
} }
// Switch the device to the transponder: // Switch the device to the transponder:
@ -830,7 +835,7 @@ int main(int argc, char *argv[])
} }
} }
} }
LastVpsCheck = time(NULL); LastTimerCheck = time(NULL);
} }
// Delete expired timers: // Delete expired timers:
Timers.DeleteExpired(); Timers.DeleteExpired();
@ -1129,7 +1134,7 @@ int main(int argc, char *argv[])
} }
} }
if (!Menu) { if (!Menu) {
if (!TimerInVpsMargin) if (!InhibitEpgScan)
EITScanner.Process(); EITScanner.Process();
if (!cCutter::Active() && cCutter::Ended()) { if (!cCutter::Active() && cCutter::Ended()) {
if (cCutter::Error()) if (cCutter::Error())