Re: [vdr] Parameter --manual-start/--timer-start (was: vdr shutdown handling / streamdev plugin)

2006-12-08 Thread Thiemo Gehrke
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.0 +0200
+++ vdr-1.4.0/vdr.c	2006-06-07 16:43:31.0 +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 ? 

Re: [vdr] Parameter --manual-start/--timer-start (was: vdr shutdown handling / streamdev plugin)

2006-12-08 Thread Marko Mäkelä
On Fri, Dec 08, 2006 at 08:21:07PM +0100, Thiemo Gehrke wrote:
 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...

What about a third possibility: the computer is started by Wake-on-LAN
or Wake-on-Ring?  It is kind of manual startup, but there should not be
any output in that case.

I have written a patch for making the Power key suspend the output.
Some softdevice users have found it useful, but I've been told that
the patch does not stop playback on full-featured cards.  You can
access the patch here: http://www.iki.fi/~msmakela/software/vdr/#suspend

Quoting from there:

The patch introduces three 'Setup/Miscellanous' menu items. The Booleans
'Power button suspends playback' and 'Playback suspended' should be
self-explanatory. The integer, 'Suspend to shutdown timeout (s)', is 0 by
default, meaning that no shutdown will be initiated when playback is
suspended by pressing the Power button. If you would like to use the
Power button as a smart power-off button that works in any context, set
this timeout to a suitable value, e.g., five seconds. Should you only
want to suspend playback and not power the system off, you can press
Power followed by OK. The latter button-press will confirm the 'Press any
key to cancel shutdown prompt' if one is presented. (If any timed
recordings are in progress, the prompt will be presented after they have
finished, unless the shutdown was cancelled by pressing any button.)

I originally made the patch for vdr 1.3.32, and back then it was too late
to change the shutdown behaviour of 1.4.  I hope that the feature will make
it to 1.5 in some form.

Marko

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] Parameter --manual-start/--timer-start (was: vdr shutdown handling / streamdev plugin)

2006-12-02 Thread Matthias Schwarzott
On Saturday 02 December 2006 16:09, Udo Richter wrote:
 Klaus Schmidinger wrote:
  The attached patch makes it call cPluginManager::Active() only
  if it really wants to shut down, and if there is actually an option
  for plugins to delay the shutdown (i.e. this is not a forced shutdown).
 
  If cPluginManager::Active() returns 'true' once, it waits for
  SHUTDOWNRETRY minutes before trying again.

 I'd suggest moving the if block a bit down in the code, at least behind
 the manual start check, so plugins cannot interfere with this. I think

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

-- 
Matthias Schwarzott
Gentoo Developer
http://www.gentoo.org

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr