[vdr] vdr shutdown handling / streamdev plugin

Udo Richter udo_richter at gmx.de
Tue Nov 14 19:26:57 CET 2006

Jörg Wendel wrote:
> a question about the 'new' vdr shutdown handling implemented a few versions ago.
> [..]
> But why vdr call this so often, isn't it only required if the vdr is going to shutdown?
> Even without the log message, at first view it looks like unnecessary load?

VDR calls this function together with several other activity checks in 
its main loop, and not just when no user activity was detected for the 
configured time.
This call is done on each cycle of the main loop (typically once a 
second, sometimes more often) unless there's an open OSD, a recording, 
or a cutting in progress.

If this call is used as a simple boolean check, the load is very small. 
Translating a string on each call is more serious. And dumping to syslog 
should definitely be avoided.

For plugin developers, I suggest to keep it simple in there. Its 
probably a good idea to tr() the string just once and cache it afterwards.

For VDR, the two if's in the inactivity shutdown should be swappable 
with no serious side effects, see attached diff. All the calls do noting 
important, except the cCutter::Active() call, and this one is called 
often enough in other situations. But even with this patch, an 
non-interactive idle VDR waiting for shutdown will call this very 


-------------- next part --------------
--- vdr.c.bak	2006-11-14 19:17:37.342544928 +0100
+++ vdr.c	2006-11-14 19:16:50.045735136 +0100
@@ -1149,9 +1149,9 @@
                  Skins.Message(mtInfo, tr("Editing process finished"));
-        if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && !cPluginManager::Active() && (!Interface->HasSVDRPConnection() || UserShutdown)) || ForceShutdown)) {
-           time_t Now = time(NULL);
-           if (Now - LastActivity > ACTIVITYTIMEOUT) {
+        time_t Now = time(NULL);
+        if (Now - LastActivity > ACTIVITYTIMEOUT) {
+            if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && !cPluginManager::Active() && (!Interface->HasSVDRPConnection() || UserShutdown)) || ForceShutdown)) {
               // Shutdown:
               if (Shutdown && (Setup.MinUserInactivity || LastActivity == 1) && Now - LastActivity > Setup.MinUserInactivity * 60) {
                  cTimer *timer = Timers.GetNextActiveTimer();

More information about the vdr mailing list