From patchwork Fri Dec 8 19:21:07 2006 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rollercoaster@reel-multimedia.com X-Patchwork-Id: 12420 Received: from 213-239-210-49.clients.your-server.de ([213.239.210.49] helo=reelbox.de ident=postfix) by www.linuxtv.org with esmtp (Exim 4.50) id 1GslHa-0003o5-2h for vdr@linuxtv.org; Fri, 08 Dec 2006 20:21:18 +0100 Received: from RollerCoaster (dslb-088-064-009-109.pools.arcor-ip.net [88.64.9.109]) by reelbox.de (Postfix) with ESMTP id 263B9804021 for ; Fri, 8 Dec 2006 20:21:08 +0100 (CET) From: Thiemo Gehrke Organization: Reel Multimedia AG To: VDR Mailing List Subject: Re: [vdr] Parameter --manual-start/--timer-start (was: vdr shutdown handling / streamdev plugin) Date: Fri, 8 Dec 2006 20:21:07 +0100 User-Agent: KMail/1.7.1 References: <200611141003.07963.vdr-ml@jwendel.de> <45719733.3070601@gmx.de> <200612021624.18181.zzam@gentoo.org> In-Reply-To: <200612021624.18181.zzam@gentoo.org> MIME-Version: 1.0 Message-Id: <200612082021.07708.rollercoaster@reel-multimedia.com> X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Dec 2006 19:21:18 -0000 Status: O X-Status: X-Keywords: X-UID: 11381 Am Samstag, 2. Dezember 2006 16:24 schrieb Matthias Schwarzott: > To manual start check I have another idea. Perhaps vdr can get a parameter > for setting explicitly manual-start or start based on timer. Then the > startskript could check the time that was written into nvram/acpi/wherever > and tell vdr if start was manual or not. > > Matthias The attached patch does what you suggest, but I don't see any correlation to the shutdown behaviour of plugins... Tim diff -Nur vdr-1.4.0-pl8/vdr.c vdr-1.4.0/vdr.c --- vdr-1.4.0-pl8/vdr.c 2006-06-07 15:04:35.000000000 +0200 +++ vdr-1.4.0/vdr.c 2006-06-07 16:43:31.000000000 +0200 @@ -188,6 +188,8 @@ int WatchdogTimeout = DEFAULTWATCHDOG; const char *Terminal = NULL; const char *Shutdown = NULL; + bool TimerWakeup = false; + bool AutoShutdown = false; bool UseKbd = true; const char *LircDevice = NULL; @@ -230,6 +232,7 @@ { "record", required_argument, NULL, 'r' }, { "shutdown", required_argument, NULL, 's' }, { "terminal", required_argument, NULL, 't' }, + { "timerwakeup", no_argument, NULL, 'T' }, { "user", required_argument, NULL, 'u' }, { "version", no_argument, NULL, 'V' }, { "vfat", no_argument, NULL, 'v' | 0x100 }, @@ -239,7 +242,7 @@ }; int c; - while ((c = getopt_long(argc, argv, "a:c:dD:E:g:hk:l:L:mp:P:r:s:t:u:v:Vw:", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "a:c:dD:E:g:hk:l:L:mp:P:r:s:t:Tu:v:Vw:", long_options, NULL)) != -1) { switch (c) { case 'a': AudioCommand = optarg; break; @@ -330,6 +333,8 @@ case 'u': if (*optarg) VdrUser = optarg; break; + case 'T': TimerWakeup = true; + break; case 'V': DisplayVersion = true; break; case 'v' | 0x100: @@ -521,6 +526,7 @@ int LastTimerChannel = -1; int PreviousChannel[2] = { 1, 1 }; int PreviousChannelIndex = 0; + time_t vdrStartTime = time(NULL); time_t LastChannelChanged = time(NULL); time_t LastActivity = 0; time_t LastCamMenu = 0; @@ -772,6 +778,14 @@ if (time(NULL) - LastChannelChanged >= Setup.ZapTimeout && LastChannel != PreviousChannel[PreviousChannelIndex]) PreviousChannel[PreviousChannelIndex ^= 1] = LastChannel; // Timers and Recordings: + if (TimerWakeup && Shutdown && time(NULL) - vdrStartTime > SHUTDOWNWAIT) { + if (LastActivity == 0) { + LastActivity = 1; + AutoShutdown = true; + } + else if (LastActivity != 1) + AutoShutdown = false; + } if (!Timers.BeingEdited()) { // Assign events to timers: Timers.SetEvents(); @@ -1037,7 +1051,7 @@ cTimer *timer = Timers.GetNextActiveTimer(); time_t Next = timer ? timer->StartTime() : 0; time_t Delta = timer ? Next - time(NULL) : 0; - if (Next && Delta <= Setup.MinEventTimeout * 60) { + if (Next && Delta <= Setup.MinEventTimeout * 60 && !AutoShutdown) { char *buf; asprintf(&buf, tr("Recording in %ld minutes, shut down anyway?"), Delta / 60); bool confirm = Interface->Confirm(buf); @@ -1167,7 +1181,7 @@ Skins.Message(mtInfo, tr("Editing process finished")); } } - if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && !cPluginManager::Active() && (!Interface->HasSVDRPConnection() || UserShutdown)) || ForceShutdown)) { + if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && !cPluginManager::Active() && (!Interface->HasSVDRPConnection() || UserShutdown || AutoShutdown)) || ForceShutdown)) { time_t Now = time(NULL); if (Now - LastActivity > ACTIVITYTIMEOUT) { // Shutdown: @@ -1185,13 +1199,14 @@ else LastActivity = 1; } - if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) { + if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown || (AutoShutdown && Delta > Setup.MinEventTimeout * 60)) { ForceShutdown = false; + AutoShutdown = false; if (timer) dsyslog("next timer event at %s", *TimeToString(Next)); if (WatchdogTimeout > 0) signal(SIGALRM, SIG_IGN); - if (Interface->Confirm(tr("Press any key to cancel shutdown"), UserShutdown ? 5 : SHUTDOWNWAIT, true)) { + if (Interface->Confirm(tr("Press any key to cancel shutdown"), UserShutdown ? 1 : SHUTDOWNWAIT, true)) { cControl::Shutdown(); int Channel = timer ? timer->Channel()->Number() : 0; const char *File = timer ? timer->File() : ""; @@ -1202,6 +1217,8 @@ isyslog("executing '%s'", cmd); SystemExec(cmd); free(cmd); + //UserShutdownActive = true; //by kh + Interrupted=1; // GA LastActivity = time(NULL) - Setup.MinUserInactivity * 60 + SHUTDOWNRETRY; // try again later } else {