From patchwork Sun Dec 31 14:52:52 2006 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schwarzott X-Patchwork-Id: 12424 Received: from mail-out.m-online.net ([212.18.0.9]) by www.linuxtv.org with esmtp (Exim 4.50) id 1H123S-0003DM-0F for vdr@linuxtv.org; Sun, 31 Dec 2006 15:52:54 +0100 Received: from mail01.m-online.net (svr21.m-online.net [192.168.3.149]) by mail-out.m-online.net (Postfix) with ESMTP id 8DD4A98085 for ; Sun, 31 Dec 2006 15:52:53 +0100 (CET) Received: from gauss.x.fun (DSL01.83.171.189.164.ip-pool.NEFkom.net [83.171.189.164]) by mail.nefkom.net (Postfix) with ESMTP id 4F9AC92A38 for ; Sun, 31 Dec 2006 15:52:53 +0100 (CET) Received: from gateway (gateway [192.168.42.1]) by gauss.x.fun (Postfix) with ESMTP id C6B0F7C2A for ; Sun, 31 Dec 2006 15:52:52 +0100 (CET) From: Matthias Schwarzott To: VDR Mailing List Subject: Re: [vdr] [RFC] Shutdown rewrite for 1.5.x Date: Sun, 31 Dec 2006 15:52:52 +0100 User-Agent: KMail/1.9.5 References: <45947EFD.6000206@gmx.de> <200612311409.20202.zzam@gentoo.org> <4597C2E5.8030006@helmutauer.de> In-Reply-To: <4597C2E5.8030006@helmutauer.de> MIME-Version: 1.0 Message-Id: <200612311552.52130.zzam@gentoo.org> 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: Sun, 31 Dec 2006 14:52:54 -0000 Status: O X-Status: X-Keywords: X-UID: 11507 On Sunday 31 December 2006 15:02, Helmut Auer wrote: > Matthias Schwarzott schrieb: > > On Sunday 31 December 2006 13:36, Joachim Wilke wrote: > >> 2006/12/30, Udo Richter : > >>> However, it might be worth thinking about giving plugins the ability to > >>> set a different wakeup time, so that a scheduled EPG scan plugin can be > >>> written. > >> > >> I also think that this would be very helpful for some plugins. Manual > >> start detection could also include a call to the plugins. A plugin > >> that did "schedule" an EPG-scan or similar could tell VDR during start > >> up, that VDR woke up because of this scheduled event set by this > >> plugin. > >> At the moment I use a relatively complex patch that does some > >> "maintainance" task during the night. If it would be possible to > >> modify the wakeup-time in a plugin I could re-implement the complete > >> patch as a plugin. > > > > I think a much easier solution (implementable in runvdr/vdr-initscript) > > is: Write down wakeup-time when shutting down and comparing that to time > > when system/vdr starts (with some margin). > > That's exactly what my Gen2VDR distribution is doing, and it works fine. > It's not the job of vdr to guess why it was started, but it would be nice > if vdr offers an option to shutdown after next recording ( maybe via svdrp > call ). In gentoo vdr package we added a small hack (attached), which implements a svdrp call "down" to tell vdr it is inactive and will shutdown in X minutes. We call this from shutdown-scripts to let vdr retry shutdown in 5 min (or other value if needed). Matthias Written by Matthias Schwarzott GENTOO_NO_PREPARE diff -ru --exclude='*.o' vdr-1.3.36-orig/svdrp.c vdr-1.3.36/svdrp.c --- vdr-1.3.36-orig/svdrp.c 2005-12-29 00:02:26.000000000 +0100 +++ vdr-1.3.36/svdrp.c 2005-12-29 00:18:45.000000000 +0100 @@ -293,6 +293,9 @@ " Updates a timer. Settings must be in the same format as returned\n" " by the LSTT command. If a timer with the same channel, day, start\n" " and stop time does not yet exists, it will be created.", + "DOWN [ ]\n" + " Starts an automatic shutdown (with 5 minutes waiting time) in given\n" + " minutes or now if no number was given.", "VOLU [ | + | - | mute ]\n" " Set the audio volume to the given number (which is limited to the range\n" " 0...255). If the special options '+' or '-' are given, the volume will\n" @@ -1342,6 +1345,16 @@ Reply(501, "Missing timer settings"); } +extern time_t LastActivity; +void cSVDRP::CmdDOWN(const char *Option) +{ + if (isnumber(Option)) + LastActivity = time(NULL) - Setup.MinUserInactivity*60 + strtol(Option, NULL, 10)*60; + else + LastActivity = time(NULL) - Setup.MinUserInactivity*60; + Reply(250, "Automatic shutdown triggered"); +} + void cSVDRP::CmdVOLU(const char *Option) { if (*Option) { @@ -1413,6 +1426,7 @@ else if (CMD("STAT")) CmdSTAT(s); else if (CMD("UPDT")) CmdUPDT(s); else if (CMD("VOLU")) CmdVOLU(s); + else if (CMD("DOWN")) CmdDOWN(s); else if (CMD("QUIT")) Close(true); else Reply(500, "Command unrecognized: \"%s\"", Cmd); } diff -ru --exclude='*.o' vdr-1.3.36-orig/svdrp.h vdr-1.3.36/svdrp.h --- vdr-1.3.36-orig/svdrp.h 2005-12-29 00:02:26.000000000 +0100 +++ vdr-1.3.36/svdrp.h 2005-12-30 02:28:08.000000000 +0100 @@ -59,6 +59,7 @@ void CmdDELC(const char *Option); void CmdDELR(const char *Option); void CmdDELT(const char *Option); + void CmdDOWN(const char *Option); void CmdEDIT(const char *Option); void CmdGRAB(const char *Option); void CmdHELP(const char *Option); diff -ru --exclude='*.o' vdr-1.3.36-orig/vdr.c vdr-1.3.36/vdr.c --- vdr-1.3.36-orig/vdr.c 2005-12-29 00:02:26.000000000 +0100 +++ vdr-1.3.36/vdr.c 2005-12-29 00:09:49.000000000 +0100 @@ -89,6 +89,8 @@ exit(1); } +time_t LastActivity; + int main(int argc, char *argv[]) { // Save terminal settings: @@ -395,7 +397,7 @@ int PreviousChannel[2] = { 1, 1 }; int PreviousChannelIndex = 0; time_t LastChannelChanged = time(NULL); - time_t LastActivity = 0; + LastActivity = 0; // now being a global variable time_t LastCamMenu = 0; int MaxLatencyTime = 0; bool ForceShutdown = false;