display results of a bounce in the region list
[ardour.git] / libs / ardour / plugin_manager.cc
index 0adf8203b6d4772631fe161cea00d91b93a0e51c..5b3a4658a80fd55e2658038ad0acda9c3b06ab78 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    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
@@ -27,7 +27,7 @@
 #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;
@@ -94,16 +97,12 @@ PluginManager::refresh ()
        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) {
@@ -198,7 +197,6 @@ PluginManager::add_presets(string domain)
        vector_delete (presets);
 }
 
-
 void
 PluginManager::add_lrdf_data (const string &path)
 {
@@ -225,7 +223,6 @@ 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;
@@ -250,14 +247,15 @@ PluginManager::ladspa_discover (string path)
                        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]) ) {
@@ -279,77 +277,6 @@ PluginManager::ladspa_discover (string path)
        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)
 {
@@ -391,10 +318,6 @@ 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) {
@@ -448,7 +371,6 @@ int
 PluginManager::vst_discover (string path)
 {
        FSTInfo* finfo;
-       PluginInfo* info;
 
        if ((finfo = fst_get_info (const_cast<char *> (path.c_str()))) == 0) {
                return -1;
@@ -460,7 +382,7 @@ PluginManager::vst_discover (string path)
                        << endl;
        }
        
-       info = new PluginInfo;
+       PluginInfoPtr info(new VSTPluginInfo);
 
        /* what a goddam joke freeware VST is */
 
@@ -475,7 +397,7 @@ PluginManager::vst_discover (string path)
        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);
@@ -483,4 +405,4 @@ PluginManager::vst_discover (string path)
        return 0;
 }
 
-#endif
+#endif // VST_SUPPORT