From patchwork Fri Dec 8 19:15:50 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: 12419 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 1GslCW-0003KB-27 for vdr@linuxtv.org; Fri, 08 Dec 2006 20:16:04 +0100 Received: from RollerCoaster (dslb-088-064-009-109.pools.arcor-ip.net [88.64.9.109]) by reelbox.de (Postfix) with ESMTP id A8C3F804021 for ; Fri, 8 Dec 2006 20:15:50 +0100 (CET) From: Thiemo Organization: Reel Multimedia AG To: VDR Mailing List Subject: Re: [vdr] [vdr bug]Shutdown during an active timer is broken Date: Fri, 8 Dec 2006 20:15:50 +0100 User-Agent: KMail/1.7.1 References: <20060725082546.DF6A0115951@dd3532.kasserver.com> <44C631EF.4010204@gmx.de> <44CB7D95.4080205@cadsoft.de> In-Reply-To: <44CB7D95.4080205@cadsoft.de> MIME-Version: 1.0 Message-Id: <200612082015.50181.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:16:04 -0000 Status: O X-Status: X-Keywords: X-UID: 11380 I am sorry I have to bring this up after a few months, i came over it and had to realize that the new behavior is not what the user expects. Now i am a little bit afraid that you are going to change this again. (see vdr shutdown handling / streamdev plugin) > How about this: if the user presses the "Power" key to turn off VDR, > and VDR tells him/her that there is a recording going on, or a timer > will hit in a few minutes, and the user still insists in shutting > down VDR *now*, what could be the reason for this? IMHO the only real > reason is that the user wants to do some maintenance, for which the > device must be turned off (like, for instance, install some hardware > or relocate it to a different place). This assumption is not correct. Not anyone ist going to do some maintenance if he shuts down his box. They are not all freaks like us ;) In fact i found out that there are two main reasons: 1. Saving power. Well, *we* know that shutting down for some minutes isn't really saving anything, but a user thinks "ok, its still 15 minutes to the next recording so its save to shut it down. And the vdr isn't telling him a warning that wakeuptime is shifted if he does so. So it's not intuitive. A timer is a "holy kow" - it should not be modified automatically. 2. Users always think "my box will (has to) return to the same state as it was before the recording". So they shut it down. They do not know that there is this (hidden) feature in the vdr that lets it shut down if he ignores the message and then keeps away his fingers from the remote (as it is no informational message but a question). On the other hand, the user expects that a running recording is disabled and he says "yes" to the question to shut down anyway. So here is my solution: - if a recording is running and User presses "Power" tell him the box will shutdown after the current recording - If he presses "Power" a second time, ask if he realy wants to do this (like before) *and* stop any running recordings (i reused the code from Udo which work very well, thanks) - if a timer is pending within MinEventTimeout ask if he really wants to do so but do *not* modify any timers or wakeup times. I think it's the task of whoever adopts vdr to a mainboard or box to program a valid wakeup time, not the vdr itself. Cheers, Tim patch: diff -u vdr-1.4.4-vanilla/vdr.c vdr-1.4.4-new/vdr.c --- vdr-1.4.4-vanilla/vdr.c 2006-10-14 12:01:32.000000000 +0200 +++ vdr-1.4.4-new/vdr.c 2006-12-08 19:51:36.000000000 +0100 @@ -1012,18 +1012,46 @@ break; } LastActivity = 1; // not 0, see below! - UserShutdown = true; if (cRecordControls::Active()) { + if (!UserShutdown) { + Skins.Message(mtInfo, tr("Activated standby after current recording")); + UserShutdown = true; + break; + } else if (!Interface->Confirm(tr("Recording - shut down anyway?"))) break; - } + } + UserShutdown = true; if (cPluginManager::Active(tr("shut down anyway?"))) break; - if (!cRecordControls::Active()) { + if (cRecordControls::Active()) { + // Stop all running timers + time_t Now = time(NULL); + cTimer *timer = Timers.GetNextActiveTimer(); + time_t Next = timer ? timer->StartTime() : 0; + while (timer && Next - Now < 0) { + if (timer->IsSingleEvent()) + timer->ClrFlags(tfActive); + else + timer->Skip(); + timer->Matches(); + + cTimer *nextTimer = Timers.GetNextActiveTimer(); + time_t nextNext = nextTimer ? nextTimer->StartTime() : 0; + if (nextNext < Next || (nextNext == Next && nextTimer == timer)) { + esyslog("Loop detected while disabling running timers"); + break; + } + Next=nextNext; + timer=nextTimer; + } + Timers.SetModified(); + } + else { 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); @@ -1172,19 +1200,21 @@ else LastActivity = 1; } + /* This one manipulates starttime, we don't want that if (timer && Delta < Setup.MinEventTimeout * 60 && ForceShutdown) { Delta = Setup.MinEventTimeout * 60; Next = Now + Delta; timer = NULL; dsyslog("reboot at %s", *TimeToString(Next)); } + */ if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) { ForceShutdown = 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("Activating standby"), UserShutdown ? 2 : SHUTDOWNWAIT, true)) { cControl::Shutdown(); int Channel = timer ? timer->Channel()->Number() : 0; const char *File = timer ? timer->File() : ""; @@ -1195,6 +1225,7 @@ isyslog("executing '%s'", cmd); SystemExec(cmd); free(cmd); + Interrupted=1; // use this to make vdr shut down without "kill -1" LastActivity = time(NULL) - Setup.MinUserInactivity * 60 + SHUTDOWNRETRY; // try again later } else { Nur in vdr-1.4.4-new: vdr.c.orig.