Somewhat uncertain fix to playhead misbehaviour in rewind.
[ardour.git] / libs / ardour / plugin_manager.cc
index 9b5898ddb907f770343abe9c977a0cbe89647c85..8227d5869f2f4da5b315435b58a5cee665122e89 100644 (file)
@@ -21,7 +21,6 @@
 #include "libardour-config.h"
 #endif
 
-#define __STDC_FORMAT_MACROS 1
 #include <stdint.h>
 
 #include <sys/types.h>
@@ -40,6 +39,7 @@
 #include <glibmm/miscutils.h>
 
 #include "pbd/pathscanner.h"
+#include "pbd/whitespace.h"
 
 #include "ardour/ladspa.h"
 #include "ardour/session.h"
@@ -141,6 +141,15 @@ PluginManager::PluginManager ()
        BootMessage (_("Discovering Plugins"));
 }
 
+
+PluginManager::~PluginManager()
+{
+#ifdef HAVE_SLV2
+       delete _lv2_world;
+#endif
+}
+
+
 void
 PluginManager::refresh ()
 {
@@ -191,7 +200,7 @@ PluginManager::ladspa_refresh ()
                                case ':' :
                                case '\0':
                                        continue;
-                               case '/' :
+                               case G_DIR_SEPARATOR :
                                        if (ladspa_path[found + strlen(standard_paths[i]) + 1] == ':' ||
                                            ladspa_path[found + strlen(standard_paths[i]) + 1] == '\0') {
                                                continue;
@@ -301,13 +310,12 @@ PluginManager::add_lrdf_data (const string &path)
        PathScanner scanner;
        vector<string *>* rdf_files;
        vector<string *>::iterator x;
-       string uri;
 
        rdf_files = scanner (path, rdf_filter, 0, true, true);
 
        if (rdf_files) {
                for (x = rdf_files->begin(); x != rdf_files->end (); ++x) {
-                       uri = "file://" + **x;
+                       const string uri(string("file://") + **x);
 
                        if (lrdf_read_file(uri.c_str())) {
                                warning << "Could not parse rdf file: " << uri << endmsg;
@@ -549,6 +557,7 @@ PluginManager::vst_discover (string path)
        info->index = 0;
        info->n_inputs.set_audio (finfo->numInputs);
        info->n_outputs.set_audio (finfo->numOutputs);
+       info->n_inputs.set_midi (finfo->wantMidi ? 1 : 0);
        info->type = ARDOUR::VST;
 
        _vst_plugin_info->push_back (info);
@@ -600,7 +609,7 @@ PluginManager::save_statuses ()
                        break;
                }
 
-               ofs << ' ' << (*i).unique_id << ' ';
+               ofs << ' ';
 
                switch ((*i).status) {
                case Normal:
@@ -613,7 +622,9 @@ PluginManager::save_statuses ()
                        ofs << "Hidden";
                        break;
                }
-
+       
+               ofs << ' ';
+               ofs << (*i).unique_id;;
                ofs << endl;
        }
 
@@ -630,12 +641,13 @@ PluginManager::load_statuses ()
        if (!ifs) {
                return;
        }
-
+       
        std::string stype;
-       std::string id;
        std::string sstatus;
+       std::string id;
        PluginType type;
        PluginStatusType status;
+       char buf[1024];
 
        while (ifs) {
 
@@ -644,15 +656,31 @@ PluginManager::load_statuses ()
                        break;
 
                }
-               ifs >> id;
+
+               ifs >> sstatus;
                if (!ifs) {
                        break;
+
                }
 
-               ifs >> sstatus;
+               /* rest of the line is the plugin ID */
+
+               ifs.getline (buf, sizeof (buf), '\n');
                if (!ifs) {
                        break;
+               }
 
+               if (sstatus == "Normal") {
+                       status = Normal;
+               } else if (sstatus == "Favorite") {
+                       status = Favorite;
+               } else if (sstatus == "Hidden") {
+                       status = Hidden;
+               } else {
+                       error << string_compose (_("unknown plugin status type \"%1\" - all entries ignored"), sstatus)
+                                 << endmsg;
+                       statuses.clear ();
+                       break;
                }
 
                if (stype == "LADSPA") {
@@ -668,21 +696,12 @@ PluginManager::load_statuses ()
                              << endmsg;
                        continue;
                }
-               if (sstatus == "Normal") {
-                       status = Normal;
-               } else if (sstatus == "Favorite") {
-                       status = Favorite;
-               } else if (sstatus == "Hidden") {
-                       status = Hidden;
-               } else {
-                       error << string_compose (_("unknown plugin status type \"%1\" - ignored"), stype)
-                             << endmsg;
-                       continue;
-               }
-
+               
+               id = buf;
+               strip_whitespace_edges (id);
                set_status (type, id, status);
        }
-
+       
        ifs.close ();
 }