summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/engine/Makefile.am1
-rw-r--r--src/libs/engine/NodeFactory.cpp50
-rw-r--r--src/libs/engine/NodeFactory.h8
-rw-r--r--src/libs/engine/Plugin.h41
-rw-r--r--src/libs/engine/PluginLibrary.h98
-rw-r--r--src/libs/module/Module.h4
6 files changed, 43 insertions, 159 deletions
diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am
index 32fa531b..89dd0735 100644
--- a/src/libs/engine/Makefile.am
+++ b/src/libs/engine/Makefile.am
@@ -72,7 +72,6 @@ libingen_engine_la_SOURCES = \
GraphObject.cpp \
Tree.h \
TreeImplementation.h \
- PluginLibrary.h \
Plugin.h \
Plugin.cpp \
PostProcessor.h \
diff --git a/src/libs/engine/NodeFactory.cpp b/src/libs/engine/NodeFactory.cpp
index 151e3c6c..04d349e3 100644
--- a/src/libs/engine/NodeFactory.cpp
+++ b/src/libs/engine/NodeFactory.cpp
@@ -22,13 +22,11 @@
#include <dirent.h>
#include <float.h>
#include <cmath>
-#include <dlfcn.h>
#include "ThreadManager.h"
#include "MidiNoteNode.h"
#include "MidiTriggerNode.h"
#include "MidiControlNode.h"
#include "TransportNode.h"
-#include "PluginLibrary.h"
#include "Plugin.h"
#include "Patch.h"
#ifdef HAVE_SLV2
@@ -90,11 +88,13 @@ NodeFactory::~NodeFactory()
{
for (list<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i)
delete (*i);
+ _plugins.clear();
+
- for (list<PluginLibrary*>::iterator i = _libraries.begin(); i != _libraries.end(); ++i) {
- (*i)->close();
+ for (list<Glib::Module*>::iterator i = _libraries.begin(); i != _libraries.end(); ++i)
delete (*i);
- }
+ _libraries.clear();
+
#ifdef HAVE_SLV2
slv2_world_free(_world);
#endif
@@ -297,7 +297,7 @@ NodeFactory::load_lv2_plugins()
Plugin* om_plug = new Plugin(Plugin::LV2, uri);
om_plug->slv2_plugin(lv2_plug);
// FIXME FIXME FIXME temporary hack
- om_plug->library(NULL);
+ om_plug->module(NULL);
om_plug->lib_path("FIXME/Some/path");
om_plug->plug_label("FIXMElabel");
char* name = slv2_plugin_get_name(lv2_plug);
@@ -408,7 +408,10 @@ NodeFactory::load_dssi_plugins()
continue;
}
- PluginLibrary* plugin_library = new PluginLibrary(full_lib_name);
+ Glib::Module* plugin_library = new Glib::Module(full_lib_name);
+ if (!(*plugin_library))
+ continue;
+
_libraries.push_back(plugin_library);
const LADSPA_Descriptor* ld = NULL;
@@ -418,8 +421,7 @@ NodeFactory::load_dssi_plugins()
assert(ld != NULL);
string uri = string("dssi:") + pfile->d_name +":"+ ld->Label;
Plugin* plugin = new Plugin(Plugin::DSSI, uri);
- assert(plugin_library != NULL);
- plugin->library(plugin_library);
+ plugin->module(plugin_library);
plugin->lib_path(dir + "/" + pfile->d_name);
plugin->plug_label(ld->Label);
plugin->name(ld->Name);
@@ -466,7 +468,6 @@ NodeFactory::load_dssi_plugin(const string& uri,
DSSI_Descriptor_Function df = NULL;
const Plugin* plugin = NULL;
Node* n = NULL;
- void* handle = NULL;
// Attempt to find the lib
list<Plugin*>::iterator i;
@@ -481,15 +482,8 @@ NodeFactory::load_dssi_plugin(const string& uri,
cerr << "Did not find DSSI plugin " << uri << " in database." << endl;
return NULL;
} else {
- assert(plugin != NULL);
- plugin->library()->open();
- handle = plugin->library()->handle();
- assert(handle != NULL);
-
- // Load descriptor function
- dlerror();
- df = (DSSI_Descriptor_Function)dlsym(handle, "dssi_descriptor");
- if (df == NULL || dlerror() != NULL) {
+ assert(plugin);
+ if (!plugin->module()->get_symbol("dssi_descriptor", (void*&)df)) {
cerr << "Looks like this isn't a DSSI plugin." << endl;
return NULL;
}
@@ -578,7 +572,10 @@ NodeFactory::load_ladspa_plugins()
continue;
}
- PluginLibrary* plugin_library = new PluginLibrary(full_lib_name);
+ Glib::Module* plugin_library = new Glib::Module(full_lib_name);
+ if (!(*plugin_library))
+ continue;
+
_libraries.push_back(plugin_library);
for (unsigned long i=0; (descriptor = (LADSPA_Descriptor*)df(i)) != NULL; ++i) {
@@ -588,7 +585,7 @@ NodeFactory::load_ladspa_plugins()
Plugin* plugin = new Plugin(Plugin::LADSPA, uri);
assert(plugin_library != NULL);
- plugin->library(plugin_library);
+ plugin->module(plugin_library);
plugin->lib_path(dir + "/" + pfile->d_name);
plugin->plug_label(descriptor->Label);
plugin->name(descriptor->Name);
@@ -638,7 +635,6 @@ NodeFactory::load_ladspa_plugin(const string& uri,
LADSPA_Descriptor_Function df = NULL;
Plugin* plugin = NULL;
Node* n = NULL;
- void* plugin_lib = NULL;
// Attempt to find the lib
list<Plugin*>::iterator i;
@@ -653,15 +649,7 @@ NodeFactory::load_ladspa_plugin(const string& uri,
cerr << "Did not find LADSPA plugin " << uri << " in database." << endl;
return NULL;
} else {
- assert(plugin != NULL);
- plugin->library()->open();
- plugin_lib = plugin->library()->handle();
- assert(plugin_lib != NULL);
-
- // Load descriptor function
- dlerror();
- df = (LADSPA_Descriptor_Function)dlsym(plugin_lib, "ladspa_descriptor");
- if (df == NULL || dlerror() != NULL) {
+ if (!plugin->module()->get_symbol("ladspa_descriptor", (void*&)df)) {
cerr << "Looks like this isn't a LADSPA plugin." << endl;
return NULL;
}
diff --git a/src/libs/engine/NodeFactory.h b/src/libs/engine/NodeFactory.h
index fcd4179e..bc41de23 100644
--- a/src/libs/engine/NodeFactory.h
+++ b/src/libs/engine/NodeFactory.h
@@ -25,6 +25,7 @@
#include <string>
#include <ladspa.h>
#include <pthread.h>
+#include <glibmm/module.h>
#ifdef HAVE_SLV2
#include <slv2/slv2.h>
#endif
@@ -35,7 +36,6 @@ namespace Ingen {
class Node;
class Patch;
-class PluginLibrary;
class Plugin;
@@ -83,9 +83,9 @@ private:
Node* load_internal_plugin(const string& plug_label, const string& name, size_t poly, Patch* parent, SampleRate srate, size_t buffer_size);
- list<PluginLibrary*> _libraries;
- list<Plugin*> _internal_plugins;
- list<Plugin*> _plugins; // FIXME: make a map
+ list<Glib::Module*> _libraries;
+ list<Plugin*> _internal_plugins;
+ list<Plugin*> _plugins; // FIXME: make a map
bool _has_loaded;
};
diff --git a/src/libs/engine/Plugin.h b/src/libs/engine/Plugin.h
index 47faddc1..1a43e6fc 100644
--- a/src/libs/engine/Plugin.h
+++ b/src/libs/engine/Plugin.h
@@ -21,6 +21,7 @@
#include "config.h"
#include <cstdlib>
+#include <glibmm/module.h>
#include <boost/utility.hpp>
#include <dlfcn.h>
#include <string>
@@ -34,7 +35,6 @@ using std::cerr; using std::endl;
namespace Ingen {
-class PluginLibrary;
class Patch;
class Node;
@@ -54,7 +54,7 @@ public:
: _type(type)
, _uri(uri)
, _id(0)
- , _library(NULL)
+ , _module(NULL)
#ifdef HAVE_SLV2
, _slv2_plugin(NULL)
#endif
@@ -84,26 +84,25 @@ public:
_plug_label = copy->_plug_label;
_name = copy->_name;
_id = _id;
- _library = copy->_library;
+ _module = copy->_module;
}
- Type type() const { return _type; }
- void type(Type t) { _type = t; }
- const string& lib_path() const { return _lib_path; }
- void lib_path(const string& s) { _lib_path = s; _lib_name = _lib_path.substr(_lib_path.find_last_of("/")+1); }
- string lib_name() const { return _lib_name; }
- void lib_name(const string& s) { _lib_name = s; }
- const string& plug_label() const { return _plug_label; }
- void plug_label(const string& s) { _plug_label = s; }
- const string& name() const { return _name; }
- void name(const string& s) { _name = s; }
- unsigned long id() const { return _id; }
- void id(unsigned long i) { _id = i; }
- const string uri() const { return _uri; }
- void uri(const string& s) { _uri = s; }
-
- PluginLibrary* library() const { return _library; }
- void library(PluginLibrary* const library) { _library = library; }
+ Type type() const { return _type; }
+ void type(Type t) { _type = t; }
+ const string& lib_path() const { return _lib_path; }
+ void lib_path(const string& s) { _lib_path = s; _lib_name = _lib_path.substr(_lib_path.find_last_of("/")+1); }
+ string lib_name() const { return _lib_name; }
+ void lib_name(const string& s) { _lib_name = s; }
+ const string& plug_label() const { return _plug_label; }
+ void plug_label(const string& s) { _plug_label = s; }
+ const string& name() const { return _name; }
+ void name(const string& s) { _name = s; }
+ unsigned long id() const { return _id; }
+ void id(unsigned long i) { _id = i; }
+ const string uri() const { return _uri; }
+ void uri(const string& s) { _uri = s; }
+ Glib::Module* module() const { return _module; }
+ void module(Glib::Module* module) { _module = module; }
const char* type_string() const {
if (_type == LADSPA) return "LADSPA";
@@ -143,7 +142,7 @@ private:
string _name; ///< LADSPA/DSSI only
unsigned long _id; ///< LADSPA/DSSI only
- PluginLibrary* _library;
+ Glib::Module* _module;
#ifdef HAVE_SLV2
SLV2Plugin _slv2_plugin;
diff --git a/src/libs/engine/PluginLibrary.h b/src/libs/engine/PluginLibrary.h
deleted file mode 100644
index e91775d1..00000000
--- a/src/libs/engine/PluginLibrary.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#ifndef PLUGINLIBRARY_H
-#define PLUGINLIBRARY_H
-
-#include <iostream>
-#include <string>
-#include <boost/utility.hpp>
-#include <dlfcn.h>
-using std::string;
-using std::cerr; using std::endl;
-
-
-namespace Ingen {
-
-
-/** Representation of a shared library containing at least one Plugin.
- *
- * In the NodeFactory, this represents one loaded shared library instance,
- * which is what handle() returns.
- */
-class PluginLibrary : boost::noncopyable
-{
-public:
- /** Construct a new PluginLibrary.
- *
- * Path is assumed to be the path of a valid shared library that can be
- * successfully dlopen'ed.
- */
- PluginLibrary(const string& path)
- : _path(path), _handle(NULL)
- {}
-
- ~PluginLibrary()
- {
- close();
- }
-
- /** Load and resolve all symbols in this shared library
- * (dlopen with RTLD_NOW).
- *
- * It is okay to call this many times, the library will only be opened
- * once.
- */
- void open()
- {
- if (_handle == NULL) {
- dlerror();
- _handle = dlopen(_path.c_str(), RTLD_NOW);
- if (_handle == NULL)
- cerr << "[PluginLibrary] Warning: Error opening shared library "
- << _path << "(" << dlerror() << ")" << endl;
- }
- }
-
- /** Close the dynamic library.
- *
- * This can be called on an already closed PluginLibrary without problems.
- */
- void close()
- {
- if (_handle != NULL) {
- dlerror();
- if (dlclose(_handle))
- cerr << "[PluginLibrary] Error closing shared library " << _path
- << "(" << dlerror() << ")" << endl;
- }
- _handle = NULL;
- }
-
- void* handle() const { return _handle; }
-
-private:
- string _path;
- void* _handle;
-};
-
-
-} // namespace Ingen
-
-#endif // PLUGINLIBRARY_H
-
diff --git a/src/libs/module/Module.h b/src/libs/module/Module.h
index b0fdee1b..58ed014f 100644
--- a/src/libs/module/Module.h
+++ b/src/libs/module/Module.h
@@ -19,10 +19,6 @@
#include <glibmm/module.h>
#include <raul/SharedPtr.h>
-#ifndef INGEN_MODULE_DIR
-#error This file expects INGEN_MODULE_DIR to be defined.
-#endif
-
namespace Ingen {
namespace Shared {