diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-07-11 13:58:48 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-07-11 13:58:48 -0400 |
commit | 83ed3d7dcc121bb7947d7532c869ccf3e0510b86 (patch) | |
tree | 66adb4caa8b58b90d638b1086c53b0ac785e8534 /libs/ardour/ladspa_plugin.cc | |
parent | 058ebf98b928f735ac2dbd5026a4dcf3fba3e67b (diff) |
Use glibmm for modules instead of dlfch.h
Diffstat (limited to 'libs/ardour/ladspa_plugin.cc')
-rw-r--r-- | libs/ardour/ladspa_plugin.cc | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index cebff59771..b306269276 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -51,16 +51,16 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -LadspaPlugin::LadspaPlugin (void *mod, AudioEngine& e, Session& session, uint32_t index, framecnt_t rate) +LadspaPlugin::LadspaPlugin (string module_path, AudioEngine& e, Session& session, uint32_t index, framecnt_t rate) : Plugin (e, session) { - init (mod, index, rate); + init (module_path, index, rate); } LadspaPlugin::LadspaPlugin (const LadspaPlugin &other) : Plugin (other) { - init (other._module, other._index, other._sample_rate); + init (other._module_path, other._index, other._sample_rate); for (uint32_t i = 0; i < parameter_count(); ++i) { _control_data[i] = other._shadow_data[i]; @@ -69,25 +69,32 @@ LadspaPlugin::LadspaPlugin (const LadspaPlugin &other) } void -LadspaPlugin::init (void *mod, uint32_t index, framecnt_t rate) +LadspaPlugin::init (string module_path, uint32_t index, framecnt_t rate) { + void* func; LADSPA_Descriptor_Function dfunc; uint32_t i, port_cnt; - const char *errstr; - _module = mod; + _module_path = module_path; + _module = new Glib::Module(_module_path); _control_data = 0; _shadow_data = 0; _latency_control_port = 0; _was_activated = false; - dfunc = (LADSPA_Descriptor_Function) dlsym (_module, "ladspa_descriptor"); + if (!(*_module)) { + error << _("LADSPA: Unable to open module: ") << Glib::Module::get_last_error() << endmsg; + delete _module; + throw failed_constructor(); + } - if ((errstr = dlerror()) != NULL) { + if (!_module->get_symbol("ladspa_descriptor", func)) { error << _("LADSPA: module has no descriptor function.") << endmsg; throw failed_constructor(); } + dfunc = (LADSPA_Descriptor_Function)func; + if ((_descriptor = dfunc (index)) == 0) { error << _("LADSPA: plugin has gone away since discovery!") << endmsg; throw failed_constructor(); @@ -141,9 +148,8 @@ LadspaPlugin::~LadspaPlugin () deactivate (); cleanup (); - /* XXX who should close a plugin? */ - - // dlclose (module); + // glib has internal reference counting on modules so this is ok + delete _module; delete [] _control_data; delete [] _shadow_data; @@ -700,17 +706,7 @@ PluginPtr LadspaPluginInfo::load (Session& session) { try { - PluginPtr plugin; - void *module; - - if ((module = dlopen (path.c_str(), RTLD_NOW)) == 0) { - error << string_compose(_("LADSPA: cannot load module from \"%1\""), path) << endmsg; - error << dlerror() << endmsg; - return PluginPtr ((Plugin*) 0); - } else { - plugin.reset (new LadspaPlugin (module, session.engine(), session, index, session.frame_rate())); - } - + PluginPtr plugin (new LadspaPlugin (path, session.engine(), session, index, session.frame_rate())); plugin->set_info(PluginInfoPtr(new LadspaPluginInfo(*this))); return plugin; } |