On Sat, Jan 13, 2007 at 09:48:47PM +0100, Udo Richter wrote:
> >A more important suggestion: Could you please add a notification method
> >to status.h for notifying plugins whether VDR is currently in
> >interactive mode?  
> You can poll this state on your own by calling 
> Shutdown.IsUserInactive().

Thanks, this seems to work: the display is powered off after the
"press any button to cancel shutdown" timeout.  However, after a
failed shutdown attempt (renaming the shutdown script so that
it won't be found), vdr does something to the file descriptor that
my plugin opens, and the relay control will fail.

This might have something to do with the fact that it is file descriptor 0.
There is no stdin, because my runvdr script closes it:

exec <&- >> /tmp/vdr.log 2>&1

The problem seems to lie in shutdown.c, in SystemExecSession().
It won't close file descriptor 0, but it will close anything above
STDERR_FILENO (which is normally 2).  This function appears to show
up in strace output as "clone()".  Adding close(0) to the function
fixes the problem.  Do you see any reason why the shutdown script
would need to access stdin?  (I can see reasons why it would want to
access stdout or stderr.)

I made a simple patch to softdevice (attached) that seems to work.
A similar patch would be needed for the subtitles plugin, to prevent
subtitles from appearing on the suspended video screen.

Index: softdevice.c
RCS file: /cvsroot/softdevice/softdevice/softdevice.c,v
retrieving revision 1.76
diff -p -u -r1.76 softdevice.c
--- softdevice.c	3 Dec 2006 20:38:18 -0000	1.76
+++ softdevice.c	22 Jan 2007 21:06:00 -0000
@@ -15,6 +15,7 @@
 #include <vdr/osd.h>
 #include <vdr/dvbspu.h>
+#include <vdr/shutdown.h>
 #include <sys/mman.h>
 #include <sys/ioctl.h>
@@ -1084,6 +1085,11 @@ bool cPluginSoftDevice::SetupParse(const
   // Parse your own setup parameters and store their values.
   return setupStore.SetupParse(Name, Value);
+void cPluginSoftDevice::MainThreadHook(void)
+  setupStore.shouldSuspend = Shutdown.IsUserInactive();
 VDRPLUGINCREATOR(cPluginSoftDevice); // Don't touch this!
Index: softdevice.h
RCS file: /cvsroot/softdevice/softdevice/softdevice.h,v
retrieving revision 1.13
diff -p -u -r1.13 softdevice.h
--- softdevice.h	11 Nov 2006 08:45:17 -0000	1.13
+++ softdevice.h	22 Jan 2007 21:06:00 -0000
@@ -58,6 +58,7 @@ public:
   virtual cOsdObject *MainMenuAction(void);
   virtual cMenuSetupPage *SetupMenu(void);
   virtual bool SetupParse(const char *Name, const char *Value);
+  virtual void MainThreadHook(void);
 #if VDRVERSNUM >= 10330
   virtual bool Service(const char *Id, void *Data = NULL);
vdr mailing list

Reply via email to