[vdr] vdr shutdown handling / streamdev plugin

Klaus Schmidinger Klaus.Schmidinger at cadsoft.de
Fri Dec 1 16:47:01 CET 2006


Udo Richter wrote:
> 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 
> frequently.
> 
> Cheers,
> 
> Udo
> 
> 
> ------------------------------------------------------------------------
> 
> --- 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();
> 
> ------------------------------------------------------------------------

I don't really think this will improve things very much.

What about making cPluginManager::Active() remember the last state of
plugin activity, and, if Prompt is NULL, only call the individual plugins'
Active() functions if, say, one minute has passed since the last check?
If the timeout has not passed yet, and the remembered state is "true",
it can return that state right away.

This would reduce any possible overhead.

Klaus




More information about the vdr mailing list