From 30dfd2e7019b9727ca761440b1ec4fe511a1143a Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 17 Oct 2004 11:50:21 +0200 Subject: Now only saving channels.conf after a modification made by the user --- vdr.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'vdr.c') diff --git a/vdr.c b/vdr.c index bb4276a6..6d76f178 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.186 2004/10/10 12:47:56 kls Exp $ + * $Id: vdr.c 1.187 2004/10/17 11:50:21 kls Exp $ */ #include @@ -58,10 +58,11 @@ #include "transfer.h" #include "videodir.h" -#define MINCHANNELWAIT 10 // seconds to wait between failed channel switchings -#define ACTIVITYTIMEOUT 60 // seconds before starting housekeeping -#define SHUTDOWNWAIT 300 // seconds to wait in user prompt before automatic shutdown -#define MANUALSTART 600 // seconds the next timer must be in the future to assume manual start +#define MINCHANNELWAIT 10 // seconds to wait between failed channel switchings +#define ACTIVITYTIMEOUT 60 // seconds before starting housekeeping +#define SHUTDOWNWAIT 300 // seconds to wait in user prompt before automatic shutdown +#define MANUALSTART 600 // seconds the next timer must be in the future to assume manual start +#define CHANNELSAVEDELTA 600 // seconds before saving channels.conf after automatic modifications static int Interrupted = 0; @@ -546,10 +547,20 @@ int main(int argc, char *argv[]) } } // Handle channel modifications: - if (!Channels.BeingEdited() && Channels.Modified()) { - if (Channels.Lock(false, 100)) { - Channels.Save(); //XXX only after user changes??? - Timers.Save(); + if (!Channels.BeingEdited()) { + int modified = Channels.Modified(); + static time_t ChannelSaveTimeout = 0; + if (modified == CHANNELSMOD_USER) + ChannelSaveTimeout = 1; // triggers an immediate save + else if (modified && !ChannelSaveTimeout) + ChannelSaveTimeout = time(NULL) + CHANNELSAVEDELTA; + bool timeout = ChannelSaveTimeout == 1 || ChannelSaveTimeout && time(NULL) > ChannelSaveTimeout && !cRecordControls::Active(); + if ((modified || timeout) && Channels.Lock(false, 100)) { + if (timeout) { + Channels.Save(); + Timers.Save(); + ChannelSaveTimeout = 0; + } for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) { if (Channel->Modification(CHANNELMOD_RETUNE)) { cRecordControls::ChannelDataModified(Channel); -- cgit v1.2.3