summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-03-20 11:19:36 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2005-03-20 11:19:36 +0100
commitce0e97eb6501ecea1c6be45bcc99ce51d34262c9 (patch)
tree1fc0271f185b2b7961463aff2f2eb95c37121936
parente760b14f646004a7fe99e4561156a132a0572cdb (diff)
downloadvdr-ce0e97eb6501ecea1c6be45bcc99ce51d34262c9.tar.gz
vdr-ce0e97eb6501ecea1c6be45bcc99ce51d34262c9.tar.bz2
Single shot timers are now reliably deleted when they have expired
-rw-r--r--HISTORY3
-rw-r--r--menu.c25
-rw-r--r--menu.h5
-rw-r--r--timers.c23
-rw-r--r--timers.h4
-rw-r--r--vdr.c4
6 files changed, 46 insertions, 18 deletions
diff --git a/HISTORY b/HISTORY
index ec504642..4619590b 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3444,7 +3444,7 @@ Video Disk Recorder Revision History
- Fixed handling repeated kAudio keys.
- Improved displaying the the current audio track in the ST:TNG channel display.
-2005-03-19: Version 1.3.23
+2005-03-20: Version 1.3.23
- The setup option "DVB/Video display format" is now only available if "Video format"
is set to "4:3" (suggested by Mikko Salo).
@@ -3466,3 +3466,4 @@ Video Disk Recorder Revision History
patch by Roman Krenický).
- Some fixes to avoid compiler warnings in gcc 4.0 (thanks to Ville Skyttä for reporting
these).
+- Single shot timers are now reliably deleted when they have expired.
diff --git a/menu.c b/menu.c
index e30be39e..6e2ba778 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 1.345 2005/03/19 15:45:19 kls Exp $
+ * $Id: menu.c 1.346 2005/03/20 11:06:56 kls Exp $
*/
#include "menu.h"
@@ -3067,7 +3067,7 @@ cRecordControl::cRecordControl(cDevice *Device, cTimer *Timer, bool Pause)
cRecordControl::~cRecordControl()
{
- Stop(true);
+ Stop();
free(instantId);
free(fileName);
}
@@ -3102,16 +3102,11 @@ bool cRecordControl::GetEvent(void)
return false;
}
-void cRecordControl::Stop(bool KeepInstant)
+void cRecordControl::Stop(void)
{
if (timer) {
DELETENULL(recorder);
timer->SetRecording(false);
- if ((IsInstant() && !KeepInstant) || (timer->IsSingleEvent() && timer->StopTime() <= time(NULL))) {
- isyslog("deleting timer %d", timer->Index() + 1);
- Timers.Del(timer);
- Timers.SetModified();
- }
timer = NULL;
cStatus::MsgRecording(device, NULL);
cRecordingUserCommand::InvokeCommand(RUC_AFTERRECORDING, fileName);
@@ -3172,8 +3167,16 @@ void cRecordControls::Stop(const char *InstantId)
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
if (RecordControls[i]) {
const char *id = RecordControls[i]->InstantId();
- if (id && strcmp(id, InstantId) == 0)
+ if (id && strcmp(id, InstantId) == 0) {
+ cTimer *timer = RecordControls[i]->Timer();
RecordControls[i]->Stop();
+ if (timer) {
+ isyslog("deleting timer %d", timer->Index() + 1);
+ Timers.Del(timer);
+ Timers.SetModified();
+ }
+ break;
+ }
}
}
}
@@ -3184,7 +3187,7 @@ void cRecordControls::Stop(cDevice *Device)
if (RecordControls[i]) {
if (RecordControls[i]->Device() == Device) {
isyslog("stopping recording on DVB device %d due to higher priority", Device->CardIndex() + 1);
- RecordControls[i]->Stop(true);
+ RecordControls[i]->Stop();
}
}
}
@@ -3261,7 +3264,7 @@ void cRecordControls::ChannelDataModified(cChannel *Channel)
if (RecordControls[i]->Timer() && RecordControls[i]->Timer()->Channel() == Channel) {
if (RecordControls[i]->Device()->ProvidesTransponder(Channel)) { // avoids retune on devices that don't really access the transponder
isyslog("stopping recording due to modification of channel %d", Channel->Number());
- RecordControls[i]->Stop(true);
+ RecordControls[i]->Stop();
// This will restart the recording, maybe even from a different
// device in case conditional access has changed.
}
diff --git a/menu.h b/menu.h
index d63fdafa..d142bbc4 100644
--- a/menu.h
+++ b/menu.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.h 1.68 2005/01/08 15:48:57 kls Exp $
+ * $Id: menu.h 1.69 2005/03/20 10:57:29 kls Exp $
*/
#ifndef __MENU_H
@@ -155,8 +155,7 @@ public:
virtual ~cRecordControl();
bool Process(time_t t);
cDevice *Device(void) { return device; }
- void Stop(bool KeepInstant = false);
- bool IsInstant(void) { return instantId; }
+ void Stop(void);
const char *InstantId(void) { return instantId; }
const char *FileName(void) { return fileName; }
cTimer *Timer(void) { return timer; }
diff --git a/timers.c b/timers.c
index e24fb207..b8e67468 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.25 2005/03/19 15:20:58 kls Exp $
+ * $Id: timers.c 1.26 2005/03/20 11:19:36 kls Exp $
*/
#include "timers.h"
@@ -389,6 +389,13 @@ int cTimer::Matches(const cEvent *Event, int *Overlap)
return tmNone;
}
+#define EXPIRELATENCY 60 // seconds (just in case there's a short glitch in the VPS signal)
+
+bool cTimer::Expired(void)
+{
+ return IsSingleEvent() && !Recording() && StopTime() + EXPIRELATENCY <= time(NULL);
+}
+
time_t cTimer::StartTime(void) const
{
if (!startTime)
@@ -604,3 +611,17 @@ void cTimers::SetEvents(void)
}
lastSetEvents = time(NULL);
}
+
+void cTimers::DeleteExpired(void)
+{
+ cTimer *ti = First();
+ while (ti) {
+ cTimer *next = Next(ti);
+ if (ti->Expired()) {
+ isyslog("deleting timer %d", ti->Index() + 1);
+ Del(ti);
+ SetModified();
+ }
+ ti = next;
+ }
+}
diff --git a/timers.h b/timers.h
index 9c611b88..6e9c4ee4 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.15 2005/03/19 14:22:11 kls Exp $
+ * $Id: timers.h 1.16 2005/03/20 10:55:49 kls Exp $
*/
#ifndef __TIMERS_H
@@ -72,6 +72,7 @@ public:
char *SetFile(const char *File);
bool Matches(time_t t = 0, bool Directly = false) const;
int Matches(const cEvent *Event, int *Overlap = NULL);
+ bool Expired(void);
time_t StartTime(void) const;
time_t StopTime(void) const;
void SetEvent(const cEvent *Event);
@@ -109,6 +110,7 @@ public:
///< Returns true if any of the timers have been modified.
///< Calling this function resets the 'modified' flag to false.
void SetEvents(void);
+ void DeleteExpired(void);
};
extern cTimers Timers;
diff --git a/vdr.c b/vdr.c
index 15aff949..72975e3b 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.202 2005/02/12 15:06:16 kls Exp $
+ * $Id: vdr.c 1.203 2005/03/20 10:58:59 kls Exp $
*/
#include <getopt.h>
@@ -606,6 +606,8 @@ int main(int argc, char *argv[])
PreviousChannel[PreviousChannelIndex ^= 1] = LastChannel;
// Timers and Recordings:
if (!Timers.BeingEdited()) {
+ // Delete expired timers:
+ Timers.DeleteExpired();
// Assign events to timers:
Timers.SetEvents();
// Must do all following calls with the exact same time!