From 0f8495f1d8deff9560676cd46a8284007d291c44 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 6 Aug 2011 13:20:07 +0200 Subject: [PATCH] Added a mechanism to defer timer handling in case of problems --- CONTRIBUTORS | 4 ++++ HISTORY | 2 ++ menu.c | 5 ++++- timers.c | 15 ++++++++++++++- timers.h | 5 ++++- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 8978e676..a39d71b5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2744,3 +2744,7 @@ Jerome Lacarriere Mark Hawes for reporting a bug in handling DiSEqC codes + +Frank Niederwipper + for reporting a problem in timer handling in case a recording directory can't + be created diff --git a/HISTORY b/HISTORY index ceea8a53..1f91ad09 100644 --- a/HISTORY +++ b/HISTORY @@ -6664,3 +6664,5 @@ Video Disk Recorder Revision History - Increased MAXCAIDS to 12 (thanks to Jerome Lacarriere). - Fixed handling DiSEqC codes (thanks to Mark Hawes for reporting the bug, and Udo Richter for suggesting the fix). +- Added a mechanism to defer timer handling in case of problems (reported by + Frank Niederwipper). diff --git a/menu.c b/menu.c index 2ba1de8e..39785146 100644 --- a/menu.c +++ b/menu.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 2.28 2011/02/27 12:37:48 kls Exp $ + * $Id: menu.c 2.29 2011/08/06 13:13:34 kls Exp $ */ #include "menu.h" @@ -38,6 +38,7 @@ #define NEWTIMERLIMIT 120 // seconds until the start time of a new timer created from the Schedule menu, // within which it will go directly into the "Edit timer" menu to allow // further parameter settings +#define DEFERTIMER 60 // seconds by which a timer is deferred in case of problems #define MAXRECORDCONTROLS (MAXDEVICES * MAXRECEIVERS) #define MAXINSTANTRECTIME (24 * 60 - 1) // 23:59 hours @@ -4134,6 +4135,8 @@ cRecordControl::cRecordControl(cDevice *Device, cTimer *Timer, bool Pause) else DELETENULL(recorder); } + else + timer->SetDeferred(DEFERTIMER); if (!Timer) { Timers.Del(timer); Timers.SetModified(); diff --git a/timers.c b/timers.c index 246fd868..54ed1ba8 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 2.4 2010/01/16 11:18:53 kls Exp $ + * $Id: timers.c 2.5 2011/08/06 13:13:54 kls Exp $ */ #include "timers.h" @@ -29,6 +29,7 @@ cTimer::cTimer(bool Instant, bool Pause, cChannel *Channel) { startTime = stopTime = 0; lastSetEvent = 0; + deferred = 0; recording = pending = inVpsMargin = false; flags = tfNone; if (Instant) @@ -62,6 +63,7 @@ cTimer::cTimer(const cEvent *Event) { startTime = stopTime = 0; lastSetEvent = 0; + deferred = 0; recording = pending = inVpsMargin = false; flags = tfActive; if (Event->Vps() && Setup.UseVps) @@ -118,6 +120,7 @@ cTimer& cTimer::operator= (const cTimer &Timer) startTime = Timer.startTime; stopTime = Timer.stopTime; lastSetEvent = 0; + deferred = 0; recording = Timer.recording; pending = Timer.pending; inVpsMargin = Timer.inVpsMargin; @@ -422,6 +425,10 @@ bool cTimer::Matches(time_t t, bool Directly, int Margin) const day = 0; } + if (t < deferred) + return false; + deferred = 0; + if (HasFlags(tfActive)) { if (HasFlags(tfVps) && event && event->Vps()) { if (Margin || !Directly) { @@ -589,6 +596,12 @@ void cTimer::SetPriority(int Priority) priority = Priority; } +void cTimer::SetDeferred(int Seconds) +{ + deferred = time(NULL) + Seconds; + isyslog("timer %s deferred for %d seconds", *ToDescr(), Seconds); +} + void cTimer::SetFlags(uint Flags) { flags |= Flags; diff --git a/timers.h b/timers.h index a18f9f87..1d733ee0 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 1.31 2008/02/16 14:33:23 kls Exp $ + * $Id: timers.h 2.1 2011/08/06 12:59:32 kls Exp $ */ #ifndef __TIMERS_H @@ -29,6 +29,7 @@ class cTimer : public cListObject { private: mutable time_t startTime, stopTime; time_t lastSetEvent; + mutable time_t deferred; ///< Matches(time_t, ...) will return false if the current time is before this value bool recording, pending, inVpsMargin; uint flags; cChannel *channel; @@ -62,6 +63,7 @@ public: const char *File(void) const { return file; } time_t FirstDay(void) const { return weekdays ? day : 0; } const char *Aux(void) const { return aux; } + time_t Deferred(void) const { return deferred; } cString ToText(bool UseChannelID = false) const; cString ToDescr(void) const; const cEvent *Event(void) const { return event; } @@ -85,6 +87,7 @@ public: void SetPending(bool Pending); void SetInVpsMargin(bool InVpsMargin); void SetPriority(int Priority); + void SetDeferred(int Seconds); void SetFlags(uint Flags); void ClrFlags(uint Flags); void InvFlags(uint Flags);