diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2003-05-09 15:27:46 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2003-05-09 15:27:46 +0200 |
commit | dc8fd12f91713c2eec49ae38ab34f09fd7e73369 (patch) | |
tree | db9d260ccc995af10dbec6b7e1485679f600a341 | |
parent | aaeaf4582dd40677965f562283cf67cf0986eb65 (diff) | |
download | vdr-dc8fd12f91713c2eec49ae38ab34f09fd7e73369.tar.gz vdr-dc8fd12f91713c2eec49ae38ab34f09fd7e73369.tar.bz2 |
Introduced cPlugin::Initialize()
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | HISTORY | 7 | ||||
-rw-r--r-- | PLUGINS.html | 67 | ||||
-rw-r--r-- | PLUGINS/src/sky/HISTORY | 4 | ||||
-rw-r--r-- | PLUGINS/src/sky/sky.c | 10 | ||||
-rw-r--r-- | config.h | 4 | ||||
-rwxr-xr-x | newplugin | 9 | ||||
-rw-r--r-- | plugin.c | 25 | ||||
-rw-r--r-- | plugin.h | 4 | ||||
-rw-r--r-- | vdr.c | 23 |
10 files changed, 111 insertions, 43 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f96e444f..1f67aa48 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -200,6 +200,7 @@ Andreas Schultz <aschultz@warp10.net> for suggesting a Make.config file for making EIT filtering use masks to reduce the number of filters for suggesting to remove the Mute() call from cDvbDevice::StillPicture() + for suggesting to separate the startup of a plugin into an "early" and a "late" phase Aaron Holtzman for writing 'ac3dec' @@ -2108,3 +2108,10 @@ Video Disk Recorder Revision History (thanks to Carsten Siebholz). - The red ("Record") and yellow ("Pause") button in the "Main" menu are no longer available when replaying. + +2003-05-09: Version 1.1.31 + +- Introduced the new function cPlugin::Initialize(), in order to be able to separate + the startup of a plugin into an "early" (Initialize()) and "late" (Start()) phase + (suggested by Andreas Schultz). Plugin authors should please read the section + about "Getting started" in PLUGINS.html and adapt their code if applicable. diff --git a/PLUGINS.html b/PLUGINS.html index d6c37760..4a2571c6 100644 --- a/PLUGINS.html +++ b/PLUGINS.html @@ -21,18 +21,18 @@ VDR program and present itself to the user. The <i>internal</i> interface provides the plugin code access to VDR's internal data structures and allows it to hook itself into specific areas to perform special actions. <p> -<!--X1.1.14--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> -Important modifications introduced in version 1.1.14 are marked like this. -<!--X1.1.14--></td></tr></table> -<!--X1.1.15--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> +<!--X1.1.15--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> Important modifications introduced in version 1.1.15 are marked like this. <!--X1.1.15--></td></tr></table> -<!--X1.1.17--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> +<!--X1.1.17--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> Important modifications introduced in version 1.1.17 are marked like this. <!--X1.1.17--></td></tr></table> -<!--X1.1.27--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +<!--X1.1.27--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> Important modifications introduced in version 1.1.27 are marked like this. <!--X1.1.27--></td></tr></table> +<!--X1.1.31--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +Important modifications introduced in version 1.1.31 are marked like this. +<!--X1.1.31--></td></tr></table> <hr> <h1>Table Of Contents</h1> @@ -283,7 +283,12 @@ virtual ~cPlugin(); The <b>constructor</b> shall initialize any member variables the plugin defines, but <b>must not access any global structures of VDR</b>. It also must not create any threads or other large data structures. These things -are done in the <a href="#Getting started"><tt>Start()</tt></a> function later. +are done in the +<!--X1.1.31--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +<a href="#Getting started"><tt>Initialize()</tt></a> or +<a href="#Getting started"><tt>Start()</tt></a> +<!--X1.1.31--></td></tr></table> +function later. Constructing a plugin object shall not have any side effects or produce any output, since VDR, for instance, has to create the plugin objects in order to get their command line help - and after that immediately destroys them again. @@ -452,13 +457,28 @@ be shorter than 80 characters. If a plugin implements a function that runs in the background (presumably in a thread of its own), or wants to make use of <a href="#Internationalization">internationalization</a>, -it needs to implement the function +it needs to implement one of the functions <p><table><tr><td bgcolor=#F0F0F0><pre><br> +<!--X1.1.31--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%><pre> +virtual bool Initialize(void); +<!--X1.1.31--></pre></td></tr></table> virtual bool Start(void); </pre></td></tr></table><p> -which is called once for each plugin at program startup. +which are called once for each plugin at program startup. +<!--X1.1.31--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +The difference between these two functions is that <tt>Initialize()</tt> is +called early at program startup, while <tt>Start()</tt> is called after everything +else has been set up, right before the main program loop is entered. Inside the +<tt>Start()</tt> function of any plugin it is guaranteed that the <tt>Initialize()</tt> +functions of all plugins have already been called. For many plugins it probably +doesn't matter which of these functions they implement, but it may be of importance +for, e.g., plugins that implement devices. Such plugins should create their cDevice +derived objects in <tt>Initialize()</tt>, so that other plugins can use them in their +<tt>Start()</tt> functions. +<!--X1.1.31--></td></tr></table> +<p> Inside this function the plugin must set up everything necessary to perform its task. This may, for instance, be a thread that collects data from the DVB stream, which is later presented to the user via a function that is available @@ -467,10 +487,11 @@ from the main menu. A return value of <i>false</i> indicates that something has gone wrong and the plugin will not be able to perform its task. In that case, the plugin should write a proper error message to the log file. The first plugin that returns -<i>false</i> from its <tt>Start()</tt> function will cause VDR to exit. +<i>false</i> from its <tt>Initialize()</tt> or <tt>Start()</tt> function will cause +VDR to exit. <p> If the plugin doesn't implement any background functionality or internationalized -texts, it doesn't need to implement this function. +texts, it doesn't need to implement either of these functions. <a name="Main menu entry"><hr><h2>Main menu entry</h2> @@ -506,7 +527,7 @@ in the call to VDR. If the user selects the main menu entry of a plugin, VDR calls the function -<!--X1.1.17--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> +<!--X1.1.17--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> <p><table><tr><td bgcolor=#F0F0F0><pre><br> virtual cOsdObject *MainMenuAction(void); </pre></td></tr></table><p> @@ -759,7 +780,8 @@ void RegisterI18n(const tI18nPhrase * const Phrases); to register them with VDR's internationalization mechanism. <p> -The call to this function must be done in the <a href="#Getting started"><tt>Start()</tt></a> function of the plugin: +The call to this function must be done in the <a href="#Getting started"><tt>Initialize()</tt></a> +or <a href="#Getting started"><tt>Start()</tt></a> function of the plugin: <p><table><tr><td bgcolor=#F0F0F0><pre><br> const tI18nPhrase Phrases[] = { @@ -1022,7 +1044,7 @@ virtual void SetAudioTrack(int Index); </pre></td></tr></table><p> <p> -<!--X1.1.15--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> +<!--X1.1.15--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> If there is an additional audio track that has to be replayed with external hardware, the player shall call its member function @@ -1303,9 +1325,7 @@ The functions to implement replaying capabilites are <p><table><tr><td bgcolor=#F0F0F0><pre><br> virtual bool HasDecoder(void) const; -<!--X1.1.14--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> virtual bool CanReplay(void) const; -<!--X1.1.14--></td></tr></table> virtual bool SetPlayMode(ePlayMode PlayMode); virtual void TrickSpeed(int Speed); virtual void Clear(void); @@ -1345,20 +1365,19 @@ needed. <p> <b>Initializing new devices</b> <p> +<!--X1.1.31--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> A derived cDevice class shall implement a static function - -<p><table><tr><td bgcolor=#F0F0F0><pre><br> -static bool Initialize(void); -</pre></td></tr></table><p> - in which it determines whether the necessary hardware to run this sort of device is actually present in this machine (or whatever other prerequisites might be important), and then creates as many device objects as necessary. See <tt>VDR/dvbdevice.c</tt> for the implementation of the <tt>cDvbDevice</tt> initialize function. <p> -A plugin that adds devices to a VDR instance shall call this initializing -function from its <a href="#Getting started"><tt>Start()</tt></a> function. +A plugin that adds devices to a VDR instance shall call this +function from its <a href="#Getting started"><tt>Initialize()</tt></a> function +to make sure other plugins that may need to have access to all available devices +will see them in their <a href="#Getting started"><tt>Start()</tt></a> function. +<!--X1.1.31--></td></tr></table> <p> Nothing needs to be done to shut down the devices. VDR will automatically shut down (delete) all devices when the program terminates. It is therefore @@ -1476,7 +1495,7 @@ the incoming data (by calling your <tt>Action()</tt> function). In case you need to do any other setup steps, like opening a file or initializing member variables, you should do so before calling <tt>Start()</tt>. <p> -<!--X1.1.27--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +<!--X1.1.27--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> If your remote control for some reason can't work (maybe because it was unable to open some file handle it requires) it can implement the virtual function diff --git a/PLUGINS/src/sky/HISTORY b/PLUGINS/src/sky/HISTORY index bdb440b1..d41904e6 100644 --- a/PLUGINS/src/sky/HISTORY +++ b/PLUGINS/src/sky/HISTORY @@ -8,3 +8,7 @@ VDR Plugin 'sky' Revision History 2002-12-13: Version 0.1.0 - Changed setting of CXX and CXXFLAGS variables in Makefile. + +2003-05-09: Version 0.1.1 + +- Changed Start() to Initialize(). diff --git a/PLUGINS/src/sky/sky.c b/PLUGINS/src/sky/sky.c index d6e10c92..ae591378 100644 --- a/PLUGINS/src/sky/sky.c +++ b/PLUGINS/src/sky/sky.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: sky.c 1.2 2002/12/13 15:01:57 kls Exp $ + * $Id: sky.c 1.3 2003/05/09 15:27:16 kls Exp $ */ #include <sys/socket.h> @@ -14,7 +14,7 @@ #include <vdr/plugin.h> #include <vdr/sources.h> -static const char *VERSION = "0.1.0"; +static const char *VERSION = "0.1.1"; static const char *DESCRIPTION = "Sky Digibox interface"; // --- cDigiboxDevice -------------------------------------------------------- @@ -186,7 +186,7 @@ public: virtual const char *Description(void) { return DESCRIPTION; } virtual const char *CommandLineHelp(void); virtual bool ProcessArgs(int argc, char *argv[]); - virtual bool Start(void); + virtual bool Initialize(void); virtual void Housekeeping(void); virtual cMenuSetupPage *SetupMenu(void); virtual bool SetupParse(const char *Name, const char *Value); @@ -216,9 +216,9 @@ bool cPluginSky::ProcessArgs(int argc, char *argv[]) return true; } -bool cPluginSky::Start(void) +bool cPluginSky::Initialize(void) { - // Start any background activities the plugin shall perform. + // Initialize any background activities the plugin shall perform. new cDigiboxDevice; return true; } @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 1.155 2003/04/27 15:56:04 kls Exp $ + * $Id: config.h 1.156 2003/05/09 15:20:22 kls Exp $ */ #ifndef __CONFIG_H @@ -19,7 +19,7 @@ #include "device.h" #include "tools.h" -#define VDRVERSION "1.1.30" +#define VDRVERSION "1.1.31" #define MAXPRIORITY 99 #define MAXLIFETIME 99 @@ -12,7 +12,7 @@ # See the main source file 'vdr.c' for copyright information and # how to reach the author. # -# $Id: newplugin 1.14 2002/12/13 14:51:46 kls Exp $ +# $Id: newplugin 1.15 2003/05/09 14:59:28 kls Exp $ $PLUGIN_NAME = $ARGV[0] || die "Usage: newplugin <name>\n"; @@ -162,6 +162,7 @@ public: virtual const char *Description(void) { return DESCRIPTION; } virtual const char *CommandLineHelp(void); virtual bool ProcessArgs(int argc, char *argv[]); + virtual bool Initialize(void); virtual bool Start(void); virtual void Housekeeping(void); virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; } @@ -194,6 +195,12 @@ bool cPlugin${PLUGIN_CLASS}::ProcessArgs(int argc, char *argv[]) return true; } +bool cPlugin${PLUGIN_CLASS}::Initialize(void) +{ + // Initialize any background activities the plugin shall perform. + return true; +} + bool cPlugin${PLUGIN_CLASS}::Start(void) { // Start any background activities the plugin shall perform. @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: plugin.c 1.8 2002/11/16 14:22:37 kls Exp $ + * $Id: plugin.c 1.9 2003/05/09 15:01:26 kls Exp $ */ #include "plugin.h" @@ -50,6 +50,11 @@ bool cPlugin::ProcessArgs(int argc, char *argv[]) return true; } +bool cPlugin::Initialize(void) +{ + return true; +} + bool cPlugin::Start(void) { return true; @@ -293,6 +298,22 @@ bool cPluginManager::LoadPlugins(bool Log) return true; } +bool cPluginManager::InitializePlugins(void) +{ + for (cDll *dll = dlls.First(); dll; dll = dlls.Next(dll)) { + cPlugin *p = dll->Plugin(); + if (p) { + int Language = Setup.OSDLanguage; + Setup.OSDLanguage = 0; // the i18n texts are only available _after_ Start() + isyslog("initializing plugin: %s (%s): %s", p->Name(), p->Version(), p->Description()); + Setup.OSDLanguage = Language; + if (!p->Initialize()) + return false; + } + } + return true; +} + bool cPluginManager::StartPlugins(void) { for (cDll *dll = dlls.First(); dll; dll = dlls.Next(dll)) { @@ -300,7 +321,7 @@ bool cPluginManager::StartPlugins(void) if (p) { int Language = Setup.OSDLanguage; Setup.OSDLanguage = 0; // the i18n texts are only available _after_ Start() - isyslog("starting plugin: %s (%s): %s", p->Name(), p->Version(), p->Description()); + isyslog("starting plugin: %s", p->Name()); Setup.OSDLanguage = Language; if (!p->Start()) return false; @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: plugin.h 1.5 2002/11/16 14:22:24 kls Exp $ + * $Id: plugin.h 1.6 2003/05/09 14:57:55 kls Exp $ */ #ifndef __PLUGIN_H @@ -33,6 +33,7 @@ public: virtual const char *CommandLineHelp(void); virtual bool ProcessArgs(int argc, char *argv[]); + virtual bool Initialize(void); virtual bool Start(void); virtual void Housekeeping(void); @@ -78,6 +79,7 @@ public: void SetDirectory(const char *Directory); void AddPlugin(const char *Args); bool LoadPlugins(bool Log = false); + bool InitializePlugins(void); bool StartPlugins(void); void Housekeeping(void); static bool HasPlugins(void); @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.152 2003/05/03 13:39:57 kls Exp $ + * $Id: vdr.c 1.153 2003/05/09 14:14:13 kls Exp $ */ #include <getopt.h> @@ -355,9 +355,9 @@ int main(int argc, char *argv[]) cDvbDevice::Initialize(); - // Start plugins: + // Initialize plugins: - if (!PluginManager.StartPlugins()) + if (!PluginManager.InitializePlugins()) return 2; // Primary device: @@ -437,6 +437,18 @@ int main(int argc, char *argv[]) if (WatchdogTimeout > 0) if (signal(SIGALRM, Watchdog) == SIG_IGN) signal(SIGALRM, SIG_IGN); + // Watchdog: + + if (WatchdogTimeout > 0) { + dsyslog("setting watchdog timer to %d seconds", WatchdogTimeout); + alarm(WatchdogTimeout); // Initial watchdog timer start + } + + // Start plugins: + + if (!PluginManager.StartPlugins()) + return 2; + // Main program loop: cOsdObject *Menu = NULL; @@ -448,11 +460,6 @@ int main(int argc, char *argv[]) bool ForceShutdown = false; bool UserShutdown = false; - if (WatchdogTimeout > 0) { - dsyslog("setting watchdog timer to %d seconds", WatchdogTimeout); - alarm(WatchdogTimeout); // Initial watchdog timer start - } - while (!Interrupted) { // Handle emergency exits: if (cThread::EmergencyExit()) { |