diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f96e444f..1f67aa48 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -200,6 +200,7 @@ Andreas Schultz 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' diff --git a/HISTORY b/HISTORY index c436fdbe..99b6a4b9 100644 --- a/HISTORY +++ b/HISTORY @@ -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 internal 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.

-
  -Important modifications introduced in version 1.1.14 are marked like this. -
-
  +
  Important modifications introduced in version 1.1.15 are marked like this.
-
  +
  Important modifications introduced in version 1.1.17 are marked like this.
-
  +
  Important modifications introduced in version 1.1.27 are marked like this.
+
  +Important modifications introduced in version 1.1.31 are marked like this. +

Table Of Contents

@@ -283,7 +283,12 @@ virtual ~cPlugin(); The constructor shall initialize any member variables the plugin defines, but must not access any global structures of VDR. It also must not create any threads or other large data structures. These things -are done in the Start() function later. +are done in the +
  +Initialize() or +Start() +
+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 internationalization, -it needs to implement the function +it needs to implement one of the functions


+
 
+virtual bool Initialize(void);
+
virtual bool Start(void);

-which is called once for each plugin at program startup. +which are called once for each plugin at program startup. +
  +The difference between these two functions is that Initialize() is +called early at program startup, while Start() is called after everything +else has been set up, right before the main program loop is entered. Inside the +Start() function of any plugin it is guaranteed that the Initialize() +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 Initialize(), so that other plugins can use them in their +Start() functions. +
+

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 false 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 -false from its Start() function will cause VDR to exit. +false from its Initialize() or Start() function will cause +VDR to exit.

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.


Main menu entry

@@ -506,7 +527,7 @@ in the call to VDR. If the user selects the main menu entry of a plugin, VDR calls the function -
  +
 


virtual cOsdObject *MainMenuAction(void);

@@ -759,7 +780,8 @@ void RegisterI18n(const tI18nPhrase * const Phrases); to register them with VDR's internationalization mechanism.

-The call to this function must be done in the Start() function of the plugin: +The call to this function must be done in the Initialize() +or Start() function of the plugin:


const tI18nPhrase Phrases[] = { @@ -1022,7 +1044,7 @@ virtual void SetAudioTrack(int Index);

-
  +
  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


virtual bool HasDecoder(void) const; -
  virtual bool CanReplay(void) const; -
virtual bool SetPlayMode(ePlayMode PlayMode); virtual void TrickSpeed(int Speed); virtual void Clear(void); @@ -1345,20 +1365,19 @@ needed.

Initializing new devices

+
  A derived cDevice class shall implement a static function - -


-static bool Initialize(void); -

- 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 VDR/dvbdevice.c for the implementation of the cDvbDevice initialize function.

-A plugin that adds devices to a VDR instance shall call this initializing -function from its Start() function. +A plugin that adds devices to a VDR instance shall call this +function from its Initialize() function +to make sure other plugins that may need to have access to all available devices +will see them in their Start() function. +

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 Action() 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 Start().

-
  +
  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 @@ -14,7 +14,7 @@ #include #include -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; } diff --git a/config.h b/config.h index 343ed15f..0b414f9e 100644 --- a/config.h +++ b/config.h @@ -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 diff --git a/newplugin b/newplugin index 1f4d5da1..e4742663 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.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 \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. diff --git a/plugin.c b/plugin.c index 5b8bc5ff..74395348 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.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; diff --git a/plugin.h b/plugin.h index d3e26d62..0a753faa 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.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); diff --git a/vdr.c b/vdr.c index ae4edd56..0b1e8e3c 100644 --- a/vdr.c +++ b/vdr.c @@ -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 @@ -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()) {