summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY3
-rw-r--r--PLUGINS.html22
-rwxr-xr-xnewplugin9
-rw-r--r--plugin.c15
-rw-r--r--plugin.h4
-rw-r--r--vdr.c4
6 files changed, 53 insertions, 4 deletions
diff --git a/HISTORY b/HISTORY
index 4efe9ab9..61bfea72 100644
--- a/HISTORY
+++ b/HISTORY
@@ -4616,3 +4616,6 @@ Video Disk Recorder Revision History
Reinhard Nissl). If it returns false, another plugin call is currently pending
and the caller should try again later. This also means that the SVDRP command
PLUG can now return an error code is the call fails.
+- The new function cPlugin::MainThreadHook() can be used by plugins to perform
+ actions in the context of the main program thread. Use this function with great
+ care and only of you absolutely have to! See also PLUGINS.html.
diff --git a/PLUGINS.html b/PLUGINS.html
index b1c4877e..bd18a866 100644
--- a/PLUGINS.html
+++ b/PLUGINS.html
@@ -63,6 +63,7 @@ structures and allows it to hook itself into specific areas to perform special a
<li><a href="#User interaction">User interaction</a>
<li><a href="#Housekeeping">Housekeeping</a>
<!--X1.3.47--><table width=100%><tr><td bgcolor=#FF0000>&nbsp;</td><td width=100%>
+<li><a href="#Main thread hook">Main thread hook</a>
<li><a href="#Activity">Activity</a>
<!--X1.3.47--></td></tr></table>
<li><a href="#Setup parameters">Setup parameters</a>
@@ -620,6 +621,27 @@ the plugin should launch a separate thread to do this.
</b>
<!--X1.3.47--><table width=100%><tr><td bgcolor=#FF0000>&nbsp;</td><td width=100%>
+<a name="Main thread hook"><hr><h2>Main thread hook</h2>
+
+<center><i><b>Pushing in...</b></i></center><p>
+
+Normally a plugin only reacts on user input if directly called through its
+<a href="#Main menu entry">main menu entry</a>, or performs some background
+activity in a separate thread. However, sometimes a plugin may need to do
+something in the context of the main program thread, without being explicitly
+called up by the user. In such a case it can implement the function
+
+<p><table><tr><td bgcolor=#F0F0F0><pre>
+virtual void MainThreadHook(void);
+</pre></td></tr></table><p>
+
+in which it can do this. This function is called for every plugin once during
+every cycle of VDR's main program loop, which typically happens once every
+second.
+<b>Be very careful when using this function, and make sure you return from it
+as soon as possible! If you spend too much time in this function, the user
+interface performance will become sluggish!</b>
+
<a name="Activity"><hr><h2>Activity</h2>
<center><i><b>Now is not a good time!</b></i></center><p>
diff --git a/newplugin b/newplugin
index 9ac83c85..2a7cac2a 100755
--- a/newplugin
+++ b/newplugin
@@ -12,7 +12,7 @@
# See the main source file 'vdr.c' for copyright information and
# how to reach the author.
#
-# $Id: newplugin 1.25 2006/04/16 09:04:21 kls Exp $
+# $Id: newplugin 1.26 2006/04/17 09:49:13 kls Exp $
$PLUGIN_NAME = $ARGV[0] || die "Usage: newplugin <name>\n";
@@ -165,6 +165,7 @@ public:
virtual bool Start(void);
virtual void Stop(void);
virtual void Housekeeping(void);
+ virtual void MainThreadHook(void);
virtual cString Active(void);
virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; }
virtual cOsdObject *MainMenuAction(void);
@@ -221,6 +222,12 @@ void cPlugin${PLUGIN_CLASS}::Housekeeping(void)
// Perform any cleanup or other regular tasks.
}
+void cPlugin${PLUGIN_CLASS}::MainThreadHook(void)
+{
+ // Perform actions in the context of the main program thread.
+ // WARNING: Use with great care - see PLUGINS.html!
+}
+
cString cPlugin${PLUGIN_CLASS}::Active(void)
{
// Return a message string if shutdown should be postponed
diff --git a/plugin.c b/plugin.c
index 88841899..82cbd692 100644
--- a/plugin.c
+++ b/plugin.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: plugin.c 1.21 2006/04/16 09:23:30 kls Exp $
+ * $Id: plugin.c 1.22 2006/04/17 09:20:05 kls Exp $
*/
#include "plugin.h"
@@ -70,6 +70,10 @@ void cPlugin::Housekeeping(void)
{
}
+void cPlugin::MainThreadHook(void)
+{
+}
+
cString cPlugin::Active(void)
{
return NULL;
@@ -370,6 +374,15 @@ void cPluginManager::Housekeeping(void)
}
}
+void cPluginManager::MainThreadHook(void)
+{
+ for (cDll *dll = pluginManager->dlls.First(); dll; dll = pluginManager->dlls.Next(dll)) {
+ cPlugin *p = dll->Plugin();
+ if (p)
+ p->MainThreadHook();
+ }
+}
+
bool cPluginManager::Active(const char *Prompt)
{
if (pluginManager) {
diff --git a/plugin.h b/plugin.h
index d113c8eb..19db6134 100644
--- a/plugin.h
+++ b/plugin.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: plugin.h 1.12 2006/04/15 10:30:33 kls Exp $
+ * $Id: plugin.h 1.13 2006/04/17 09:18:16 kls Exp $
*/
#ifndef __PLUGIN_H
@@ -39,6 +39,7 @@ public:
virtual bool Start(void);
virtual void Stop(void);
virtual void Housekeeping(void);
+ virtual void MainThreadHook(void);
virtual cString Active(void);
virtual const char *MainMenuEntry(void);
@@ -90,6 +91,7 @@ public:
bool InitializePlugins(void);
bool StartPlugins(void);
void Housekeeping(void);
+ void MainThreadHook(void);
static bool Active(const char *Prompt = NULL);
static bool HasPlugins(void);
static cPlugin *GetPlugin(int Index);
diff --git a/vdr.c b/vdr.c
index ea1d0580..2b8b484d 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.cadsoft.de/vdr
*
- * $Id: vdr.c 1.260 2006/04/15 13:51:52 kls Exp $
+ * $Id: vdr.c 1.261 2006/04/17 09:23:23 kls Exp $
*/
#include <getopt.h>
@@ -830,6 +830,8 @@ int main(int argc, char *argv[])
// Queued messages:
if (!Skins.IsOpen())
Skins.ProcessQueuedMessages();
+ // Main thread hooks of plugins:
+ PluginManager.MainThreadHook();
// User Input:
cOsdObject *Interact = Menu ? Menu : cControl::Control();
eKeys key = Interface->GetKey((!Interact || !Interact->NeedsFastResponse()) && time(NULL) - LastCamMenu > LASTCAMMENUTIMEOUT);