summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--src/libs/gui/App.cpp2
-rw-r--r--src/libs/module/module.cpp7
-rw-r--r--src/progs/ingen/main.cpp11
8 files changed, 92 insertions, 60 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;
diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp
index b0ec48af..d2407c9f 100644
--- a/src/libs/gui/App.cpp
+++ b/src/libs/gui/App.cpp
@@ -126,6 +126,8 @@ App::run(int argc, char** argv,
App::instance().connect_window()->start(engine, interface);
main.run();
+
+ cout << "Gtk exiting." << endl;
}
diff --git a/src/libs/module/module.cpp b/src/libs/module/module.cpp
index 80ed035b..7584ebc7 100644
--- a/src/libs/module/module.cpp
+++ b/src/libs/module/module.cpp
@@ -45,11 +45,14 @@ get_world()
void
destroy_world()
{
+ if (world) {
#ifdef HAVE_SLV2
- slv2_world_free(world->slv2_world);
+ slv2_world_free(world->slv2_world);
#endif
- delete world;
+ delete world;
+ world = NULL;
+ }
}
diff --git a/src/progs/ingen/main.cpp b/src/progs/ingen/main.cpp
index 1172c33a..eff265c6 100644
--- a/src/progs/ingen/main.cpp
+++ b/src/progs/ingen/main.cpp
@@ -205,12 +205,19 @@ main(int argc, char** argv)
engine->activate();
engine->main();
+ }
+
+ cout << "Exiting." << endl;
- cout << "Exiting." << endl;
-
+ if (engine) {
+ engine->deactivate();
engine.reset();
}
+ engine_module.reset();
+ client_module.reset();
+ gui_module.reset();
+
Ingen::Shared::destroy_world();
return 0;