mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Improved deleting plugins in case the plugin uses its own memory management
This commit is contained in:
parent
a526eee165
commit
5193fd9d99
@ -2761,6 +2761,7 @@ Winfried K
|
|||||||
for fixing some copy&paste errors in PLUGINS.html
|
for fixing some copy&paste errors in PLUGINS.html
|
||||||
for fixing the size of cChannel::dtypes[]
|
for fixing the size of cChannel::dtypes[]
|
||||||
for adding a device hook for detecting whether a device provides EIT data
|
for adding a device hook for detecting whether a device provides EIT data
|
||||||
|
for improving deleting plugins in case the plugin uses its own memory management
|
||||||
|
|
||||||
Hans-Werner Hilse <hilse@web.de>
|
Hans-Werner Hilse <hilse@web.de>
|
||||||
for adding the command line option --userdump to enable core dumps in case VDR
|
for adding the command line option --userdump to enable core dumps in case VDR
|
||||||
|
6
HISTORY
6
HISTORY
@ -9498,3 +9498,9 @@ Video Disk Recorder Revision History
|
|||||||
two bonded devices, which was "fixed" in version 1.7.29. Apparently this fix merely
|
two bonded devices, which was "fixed" in version 1.7.29. Apparently this fix merely
|
||||||
rendered the whole code branch inactive. Now this branch is only executed for devices
|
rendered the whole code branch inactive. Now this branch is only executed for devices
|
||||||
that are not bonded.
|
that are not bonded.
|
||||||
|
|
||||||
|
2020-06-29:
|
||||||
|
|
||||||
|
- Improved deleting plugins in case the plugin uses its own memory management (thanks
|
||||||
|
to Winfried Köhler). Plugins that have been compiled with previous versions of VDR
|
||||||
|
do not need to be recompiled, they will silently be handled as before.
|
||||||
|
15
plugin.c
15
plugin.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: plugin.c 4.1 2015/04/18 14:51:20 kls Exp $
|
* $Id: plugin.c 4.2 2020/06/29 09:29:06 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
@ -182,11 +182,15 @@ cDll::cDll(const char *FileName, const char *Args)
|
|||||||
args = Args ? strdup(Args) : NULL;
|
args = Args ? strdup(Args) : NULL;
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
plugin = NULL;
|
plugin = NULL;
|
||||||
|
destroy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cDll::~cDll()
|
cDll::~cDll()
|
||||||
{
|
{
|
||||||
delete plugin;
|
if (destroy)
|
||||||
|
destroy(plugin);
|
||||||
|
else
|
||||||
|
delete plugin; // silently fall back for plugins compiled with VDR version <= 2.4.3
|
||||||
if (handle)
|
if (handle)
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
free(args);
|
free(args);
|
||||||
@ -223,10 +227,11 @@ bool cDll::Load(bool Log)
|
|||||||
handle = dlopen(fileName, RTLD_NOW);
|
handle = dlopen(fileName, RTLD_NOW);
|
||||||
const char *error = dlerror();
|
const char *error = dlerror();
|
||||||
if (!error) {
|
if (!error) {
|
||||||
void *(*creator)(void);
|
typedef cPlugin *create_t(void);
|
||||||
creator = (void *(*)(void))dlsym(handle, "VDRPluginCreator");
|
create_t *create = (create_t *)dlsym(handle, "VDRPluginCreator");
|
||||||
if (!(error = dlerror()))
|
if (!(error = dlerror()))
|
||||||
plugin = (cPlugin *)creator();
|
plugin = create();
|
||||||
|
destroy = (destroy_t *)dlsym(handle, "VDRPluginDestroyer");
|
||||||
}
|
}
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (plugin && args) {
|
if (plugin && args) {
|
||||||
|
8
plugin.h
8
plugin.h
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: plugin.h 2.2 2012/09/01 13:08:54 kls Exp $
|
* $Id: plugin.h 4.1 2020/06/29 09:29:06 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __PLUGIN_H
|
#ifndef __PLUGIN_H
|
||||||
@ -15,7 +15,9 @@
|
|||||||
#include "osdbase.h"
|
#include "osdbase.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
#define VDRPLUGINCREATOR(PluginClass) extern "C" void *VDRPluginCreator(void) { return new PluginClass; }
|
#define VDRPLUGINCREATOR(PluginClass) \
|
||||||
|
extern "C" void *VDRPluginCreator(void) { return new PluginClass; } \
|
||||||
|
extern "C" void VDRPluginDestroyer(PluginClass *p) { delete p; }
|
||||||
|
|
||||||
class cPlugin {
|
class cPlugin {
|
||||||
friend class cDll;
|
friend class cDll;
|
||||||
@ -71,6 +73,8 @@ private:
|
|||||||
char *args;
|
char *args;
|
||||||
void *handle;
|
void *handle;
|
||||||
cPlugin *plugin;
|
cPlugin *plugin;
|
||||||
|
typedef void destroy_t(cPlugin *);
|
||||||
|
destroy_t *destroy;
|
||||||
public:
|
public:
|
||||||
cDll(const char *FileName, const char *Args);
|
cDll(const char *FileName, const char *Args);
|
||||||
virtual ~cDll();
|
virtual ~cDll();
|
||||||
|
Loading…
Reference in New Issue
Block a user