[vdr] [RFC] Shutdown rewrite for 1.5.x

Udo Richter udo_richter at gmx.de
Fri Dec 29 03:35:41 CET 2006


Hi list,

The program code for automatic and manual shut down and for automatic 
restarts for timer recordings is in VDR 1.4.x very complex and 
error-prone, and behaves strange in some situations. With Klaus' 
permission I am working on a re-implementation for the upcoming 1.5.x 
developer builds of VDR.

I now want to publish a first draft version for testing and further 
comments. Not all issues are fixed yet, but it already gives an 
impression of the new code.

http://www.udo-richter.de/vdr/patches.html#shutdown
http://www.udo-richter.de/vdr/patches.en.html#shutdown


New:
- Shutdown related code is now in shutdown.[ch]. vdr.c mainly delegates
   the work to the cShutdown class, that does all necessary steps for
   manual or automatic shutdown.
- cShutdown tracks whether there is an interactive user or not. (eg.
   Min User Inactivity run out)
- cRemote tracks time of last key press separately and autonomously.
- The old 5-minute "Press any key to cancel..." message got replaced by
   a 5 minute countdown message that counts in 10-second steps
- Since the new code is modularized, plugins will have access to
   activity tracking, can mess with inactivity state, and can initiate
   shutdown behavior similar to the kPower button.
   (But, please, only if you have to. ;) )

Fixed:
- Pressing power button while recording playback works again, instead of
   doing nothing visible. (and not shutting down within 5 seconds at
   playback end.)
- Show 5-minute shutdown message after background activity ends, if
   power button was pressed but not confirmed
- Not freezing the VDR main loop while 5-minute shutdown message
- Background activity now cancels the 5-minute shutdown message
- Not messing with watchdog (and forgetting to re-enable) while 5-minute
   shutdown message
- Timers set via SVDRP while in 5-minute shutdown message did not start
   and were not considered for reboot time.
- Calling the main menu action of a plugin and closing a menu doesn't
   count as user activity any more

Todo:
- Start the 5-minute countdown 5 minutes _before_ min user inactivity
   runs out. (also does not add 5min to SHUTDOWNRETRY any more)
- Fix negative time in shutdown confirm if VPS timer is in run-out phase

Possible changes:
- Make the 'inactive' mode (waiting for background activity to end, then
   shut down) more visible to the user:
   - Suggestion was to put up a message 'VDR will shut down when idle.
     Press power button again to force shutdown' before starting the
     confirms.
   - Alternative may be a message 'VDR will shut down later when idle' if
     shutdown was not confirmed
   - Alternative may be to permanently put up a message 'VDR is waiting
     for background tasks to complete'.

- What should happen if a user confirms to shut down while a running /
   pending timer is scheduled. Currently, VDR will reboot after
   MinEventTimeout, but VDR could also reboot at the next timer that
   starts after MinEventTimeout - or never.

- There is a feature request that the caller should be able to notify
   VDR whether VDR was started manually or automatically. (VDR currently
   guesses by searching for nearby timers)

- There is a feature request to start the external shutdown script
   asynchronously, so the shutdown script does not block VDR any more.

- A 'bug' in the old code allows to automatically shut down VDR at the
   end of a playback, though this was probably never intended. It could
   however be re-added as 'feature'.


There's some debug output code to monitor the various timers on console. 
If you don't want that, you can disable it in vdr.c, search for #define 
DebugTimeouts and comment it out.


Cheers,

Udo



More information about the vdr mailing list