/*
- Copyright (C) 2000-2004 Paul Davis
+ Copyright (C) 2000-2006 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <fst.h>
#include <pbd/basename.h>
#include <string.h>
-#endif
+#endif // VST_SUPPORT
#include <pbd/pathscanner.h>
#include <ardour/plugin_manager.h>
#include <ardour/plugin.h>
#include <ardour/ladspa_plugin.h>
+
+#ifdef VST_SUPPORT
#include <ardour/vst_plugin.h>
+#endif
#include <pbd/error.h>
#include <pbd/stl_delete.h>
#include "i18n.h"
using namespace ARDOUR;
+using namespace PBD;
PluginManager* PluginManager::_manager = 0;
-PluginManager::PluginManager (AudioEngine& e)
- : _engine (e)
+PluginManager::PluginManager ()
{
char* s;
string lrdf_path;
if (Config->get_use_vst()) {
vst_refresh ();
}
-#endif
+#endif // VST_SUPPORT
}
void
PluginManager::ladspa_refresh ()
{
- for (std::list<PluginInfo*>::iterator i = _ladspa_plugin_info.begin(); i != _ladspa_plugin_info.end(); ++i) {
- delete *i;
- }
-
_ladspa_plugin_info.clear ();
if (ladspa_path.length() == 0) {
vector_delete (presets);
}
-
void
PluginManager::add_lrdf_data (const string &path)
{
int
PluginManager::ladspa_discover (string path)
{
- PluginInfo *info;
void *module;
const LADSPA_Descriptor *descriptor;
LADSPA_Descriptor_Function dfunc;
break;
}
- info = new PluginInfo;
+ PluginInfoPtr info(new LadspaPluginInfo);
info->name = descriptor->Name;
info->category = get_ladspa_category(descriptor->UniqueID);
info->path = path;
info->index = i;
info->n_inputs = 0;
info->n_outputs = 0;
- info->type = PluginInfo::LADSPA;
+ info->type = ARDOUR::LADSPA;
+ info->unique_id = descriptor->UniqueID;
for (uint32_t n=0; n < descriptor->PortCount; ++n) {
if ( LADSPA_IS_PORT_AUDIO (descriptor->PortDescriptors[n]) ) {
return 0;
}
-Plugin *
-PluginManager::load (Session& session, PluginInfo *info)
-{
- void *module;
- Plugin *plugin = 0;
-
- try {
- if (info->type == PluginInfo::VST) {
-
-#ifdef VST_SUPPORT
- if (Config->get_use_vst()) {
- FSTHandle* handle;
-
- if ((handle = fst_load (info->path.c_str())) == 0) {
- error << string_compose(_("VST: cannot load module from \"%1\""), info->path) << endmsg;
- } else {
- plugin = new VSTPlugin (_engine, session, handle);
- }
- } else {
- error << _("You asked ardour to not use any VST plugins") << endmsg;
- }
-#else
- error << _("This version of ardour has no support for VST plugins") << endmsg;
- return 0;
-#endif
-
- } else {
-
- if ((module = dlopen (info->path.c_str(), RTLD_NOW)) == 0) {
- error << string_compose(_("LADSPA: cannot load module from \"%1\""), info->path) << endmsg;
- error << dlerror() << endmsg;
- } else {
- plugin = new LadspaPlugin (module, _engine, session, info->index, session.frame_rate());
- }
- }
-
- plugin->set_info(*info);
- }
-
- catch (failed_constructor &err) {
- plugin = 0;
- }
-
- return plugin;
-}
-
-Plugin *
-ARDOUR::find_plugin(Session& session, string name, PluginInfo::Type type)
-{
- PluginManager *mgr = PluginManager::the_manager();
- list<PluginInfo *>::iterator i;
- list<PluginInfo *>* plugs = 0;
-
- switch (type) {
- case PluginInfo::LADSPA:
- plugs = &mgr->ladspa_plugin_info();
- break;
- case PluginInfo::VST:
- plugs = &mgr->vst_plugin_info();
- break;
- }
-
- for (i = plugs->begin(); i != plugs->end(); ++i) {
- if ((*i)->name == name) {
- return mgr->load (session, *i);
- }
- }
-
- return 0;
-}
-
string
PluginManager::get_ladspa_category (uint32_t plugin_id)
{
void
PluginManager::vst_refresh ()
{
- for (std::list<PluginInfo*>::iterator i = _vst_plugin_info.begin(); i != _vst_plugin_info.end(); ++i) {
- delete *i;
- }
-
_vst_plugin_info.clear ();
if (vst_path.length() == 0) {
PluginManager::vst_discover (string path)
{
FSTInfo* finfo;
- PluginInfo* info;
if ((finfo = fst_get_info (const_cast<char *> (path.c_str()))) == 0) {
return -1;
<< endl;
}
- info = new PluginInfo;
+ PluginInfoPtr info(new VSTPluginInfo);
/* what a goddam joke freeware VST is */
info->index = 0;
info->n_inputs = finfo->numInputs;
info->n_outputs = finfo->numOutputs;
- info->type = PluginInfo::VST;
+ info->type = ARDOUR::VST;
_vst_plugin_info.push_back (info);
fst_free_info (finfo);
return 0;
}
-#endif
+#endif // VST_SUPPORT