From dc8fd12f91713c2eec49ae38ab34f09fd7e73369 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 9 May 2003 15:27:46 +0200 Subject: Introduced cPlugin::Initialize() --- PLUGINS.html | 67 ++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 24 deletions(-) (limited to 'PLUGINS.html') 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 -- cgit v1.2.3