summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/Engine.cpp10
-rw-r--r--src/libs/engine/Engine.hpp4
-rw-r--r--src/libs/engine/JackAudioDriver.cpp9
-rw-r--r--src/libs/engine/NodeFactory.cpp98
-rw-r--r--src/libs/engine/NodeFactory.hpp11
5 files changed, 76 insertions, 56 deletions
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp
index 438d5540..a77662a3 100644
--- a/src/libs/engine/Engine.cpp
+++ b/src/libs/engine/Engine.cpp
@@ -37,6 +37,7 @@
#include "CreatePatchEvent.hpp"
#include "EnablePatchEvent.hpp"
#include "OSCEngineReceiver.hpp"
+#include "PostProcessor.hpp"
#ifdef HAVE_JACK_MIDI
#include "JackMidiDriver.hpp"
#endif
@@ -60,7 +61,7 @@ Engine::Engine(Ingen::Shared::World* world)
/*#ifdef HAVE_LASH
_lash_driver(new LashDriver()),
#else */
- _lash_driver(NULL),
+// _lash_driver(NULL),
//#endif
_quit_flag(false),
_activated(false)
@@ -78,12 +79,17 @@ Engine::~Engine()
delete i->second;
}
+ _event_source.reset();
+ _audio_driver.reset();
+
delete _object_store;
delete _broadcaster;
delete _node_factory;
delete _midi_driver;
delete _osc_driver;
-
+ delete _post_processor;
+ //delete _lash_driver;
+
delete _maid;
munlockall();
diff --git a/src/libs/engine/Engine.hpp b/src/libs/engine/Engine.hpp
index 7570e61f..562a2fa3 100644
--- a/src/libs/engine/Engine.hpp
+++ b/src/libs/engine/Engine.hpp
@@ -90,7 +90,7 @@ public:
ClientBroadcaster* broadcaster() const { return _broadcaster; }
ObjectStore* object_store() const { return _object_store; }
NodeFactory* node_factory() const { return _node_factory; }
- LashDriver* lash_driver() const { return _lash_driver; }
+ //LashDriver* lash_driver() const { return _lash_driver; }
/** Return the active driver for the given type */
Driver* driver(DataType type);
@@ -110,7 +110,7 @@ private:
ClientBroadcaster* _broadcaster;
ObjectStore* _object_store;
NodeFactory* _node_factory;
- LashDriver* _lash_driver;
+ //LashDriver* _lash_driver;
bool _quit_flag;
bool _activated;
diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp
index a402bfe6..ebb4708b 100644
--- a/src/libs/engine/JackAudioDriver.cpp
+++ b/src/libs/engine/JackAudioDriver.cpp
@@ -117,7 +117,7 @@ JackAudioDriver::JackAudioDriver(Engine& engine,
_buffer_size(jack_client ? jack_get_buffer_size(jack_client) : 0),
_sample_rate(jack_client ? jack_get_sample_rate(jack_client) : 0),
_is_activated(false),
- _local_client(false),
+ _local_client(true), // FIXME
_root_patch(NULL)
{
if (!_client) {
@@ -193,12 +193,13 @@ void
JackAudioDriver::deactivate()
{
if (_is_activated) {
+
+ //for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
+ // jack_port_unregister(_client, (*i)->jack_port());
+
jack_deactivate(_client);
_is_activated = false;
- for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
- jack_port_unregister(_client, (*i)->jack_port());
-
_ports.clear();
cout << "[JackAudioDriver] Deactivated Jack client." << endl;
diff --git a/src/libs/engine/NodeFactory.cpp b/src/libs/engine/NodeFactory.cpp
index 2c71d66d..b491c0c8 100644
--- a/src/libs/engine/NodeFactory.cpp
+++ b/src/libs/engine/NodeFactory.cpp
@@ -84,13 +84,33 @@ NodeFactory::~NodeFactory()
delete (*i);
_plugins.clear();
-
- for (list<Glib::Module*>::iterator i = _libraries.begin(); i != _libraries.end(); ++i)
- delete (*i);
+ for (Libraries::iterator i = _libraries.begin(); i != _libraries.end(); ++i) {
+ delete i->second;
+ }
_libraries.clear();
}
+Glib::Module*
+NodeFactory::library(const string& path)
+{
+ Glib::Module* plugin_library = NULL;
+ Libraries::iterator library_i = _libraries.find(path);
+ if (library_i != _libraries.end()) {
+ plugin_library = library_i->second;
+ assert(plugin_library);
+ } else {
+ plugin_library = new Glib::Module(path, Glib::MODULE_BIND_LOCAL | Glib::MODULE_BIND_LAZY);
+ if (plugin_library && *plugin_library) {
+ _libraries.insert(make_pair(path, plugin_library));
+ return plugin_library;
+ }
+ }
+
+ return NULL;
+}
+
+
const Plugin*
NodeFactory::plugin(const string& uri)
{
@@ -357,9 +377,6 @@ NodeFactory::load_dssi_plugins()
} else {
dssi_path = env_dssi_path;
}
-
- DSSI_Descriptor_Function df = NULL;
- DSSI_Descriptor* descriptor = NULL;
string dir;
string full_lib_name;
@@ -380,31 +397,31 @@ NodeFactory::load_dssi_plugins()
struct dirent* pfile;
while ((pfile = readdir(pdir))) {
+
+ DSSI_Descriptor_Function df = NULL;
+ DSSI_Descriptor* descriptor = NULL;
if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, ".."))
continue;
full_lib_name = dir +"/"+ pfile->d_name;
- // Load descriptor function
- // Loaded with LAZY here, will be loaded with NOW on node loading
- void* handle = dlopen(full_lib_name.c_str(), RTLD_LAZY);
- if (handle == NULL)
+ Glib::Module* plugin_library = library(full_lib_name);
+ if (!plugin_library) {
+ cerr << "WARNING: Failed to load library " << full_lib_name << endl;
continue;
-
- df = (DSSI_Descriptor_Function)dlsym(handle, "dssi_descriptor");
- if (df == NULL) {
+ }
+
+ bool found = plugin_library->get_symbol("dssi_descriptor", (void*&)df);
+ if (!found || !df) {
// Not a DSSI plugin library
- dlclose(handle);
+ cerr << "WARNING: Non-DSSI library found in DSSI path: " <<
+ full_lib_name << endl;
+ _libraries.erase(full_lib_name);
+ delete plugin_library;
continue;
}
- Glib::Module* plugin_library = new Glib::Module(full_lib_name);
- if (!(*plugin_library))
- continue;
-
- _libraries.push_back(plugin_library);
-
const LADSPA_Descriptor* ld = NULL;
for (unsigned long i=0; (descriptor = (DSSI_Descriptor*)df(i)) != NULL; ++i) {
@@ -412,6 +429,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->module(plugin_library);
plugin->lib_path(dir + "/" + pfile->d_name);
plugin->plug_label(ld->Label);
@@ -434,10 +452,6 @@ NodeFactory::load_dssi_plugins()
else
delete plugin;
}
-
- df = NULL;
- descriptor = NULL;
- dlclose(handle);
}
closedir(pdir);
}
@@ -523,9 +537,6 @@ NodeFactory::load_ladspa_plugins()
ladspa_path = env_ladspa_path;
}
- LADSPA_Descriptor_Function df = NULL;
- LADSPA_Descriptor* descriptor = NULL;
-
string dir;
string full_lib_name;
@@ -545,29 +556,30 @@ NodeFactory::load_ladspa_plugins()
struct dirent* pfile;
while ((pfile = readdir(pdir))) {
+
+ LADSPA_Descriptor_Function df = NULL;
+ LADSPA_Descriptor* descriptor = NULL;
if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, ".."))
continue;
full_lib_name = dir +"/"+ pfile->d_name;
- // Load descriptor function
- // Loaded with LAZY here, will be loaded with NOW on node loading
- void* handle = dlopen(full_lib_name.c_str(), RTLD_LAZY);
- if (handle == NULL)
+ Glib::Module* plugin_library = library(full_lib_name);
+ if (!plugin_library) {
+ cerr << "WARNING: Failed to load library " << full_lib_name << endl;
continue;
+ }
- df = (LADSPA_Descriptor_Function)dlsym(handle, "ladspa_descriptor");
- if (df == NULL) {
- dlclose(handle);
- continue;
- }
-
- Glib::Module* plugin_library = new Glib::Module(full_lib_name);
- if (!(*plugin_library))
+ bool found = plugin_library->get_symbol("ladspa_descriptor", (void*&)df);
+ if (!found || !df) {
+ cerr << "WARNING: Non-LADSPA library found in LADSPA path: " <<
+ full_lib_name << endl;
+ // Not a LADSPA plugin library
+ _libraries.erase(full_lib_name);
+ delete plugin_library;
continue;
-
- _libraries.push_back(plugin_library);
+ }
for (unsigned long i=0; (descriptor = (LADSPA_Descriptor*)df(i)) != NULL; ++i) {
char id_str[11];
@@ -598,10 +610,6 @@ NodeFactory::load_ladspa_plugins()
else
delete plugin;
}
-
- df = NULL;
- descriptor = NULL;
- dlclose(handle);
}
closedir(pdir);
}
diff --git a/src/libs/engine/NodeFactory.hpp b/src/libs/engine/NodeFactory.hpp
index 2c0b2bb6..b89f1218 100644
--- a/src/libs/engine/NodeFactory.hpp
+++ b/src/libs/engine/NodeFactory.hpp
@@ -22,6 +22,7 @@
#include "module/module.h"
#include <list>
+#include <map>
#include <string>
#include <ladspa.h>
#include <pthread.h>
@@ -81,10 +82,14 @@ private:
#endif
Node* load_internal_plugin(const string& plug_label, const string& name, uint32_t poly, Patch* parent, SampleRate srate, size_t buffer_size);
+
+ Glib::Module* library(const string& path);
- list<Glib::Module*> _libraries;
- list<Plugin*> _internal_plugins;
- list<Plugin*> _plugins; // FIXME: make a map
+ typedef std::map<std::string,Glib::Module*> Libraries;
+
+ Libraries _libraries;
+ list<Plugin*> _internal_plugins;
+ list<Plugin*> _plugins; // FIXME: make a map
Ingen::Shared::World* _world;
bool _has_loaded;