changeset 443:ea7ca3335a1a

Look up plugins in Tony-specific location in advance of generic Vamp locations (can be overridden in environment)
author Chris Cannam
date Tue, 31 Mar 2015 17:15:18 +0100
parents 12f2c987e2b5
children 2391a9d0b7df
files src/main.cpp
diffstat 1 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.cpp	Tue Mar 31 15:09:58 2015 +0100
+++ b/src/main.cpp	Tue Mar 31 17:15:18 2015 +0100
@@ -40,6 +40,8 @@
 #include <iostream>
 #include <signal.h>
 
+#include <vamp-hostsdk/PluginHostAdapter.h>
+
 static QMutex cleanupMutex;
 static bool cleanedUp = false;
 
@@ -114,6 +116,46 @@
         }
     }
 };
+
+static void
+setupTonyVampPath()
+{
+#ifdef Q_OS_WIN32
+    QChar sep(';');
+    QString programFiles = getenv("ProgramFiles");
+    if (programFiles == "") programFiles = "C:\\Program Files";
+    QString defaultTonyPath(programFiles + "\\Tony");
+#else
+    QChar sep(':');
+#ifdef Q_OS_MAC
+    QString defaultTonyPath;
+#else
+    QString defaultTonyPath("/usr/local/lib/tony:/usr/lib/tony");
+#endif
+#endif
+
+    QString tonyVampPath = getenv("TONY_VAMP_PATH");
+    if (tonyVampPath == "") {
+        tonyVampPath = defaultTonyPath;
+    }
+    if (tonyVampPath == "") {
+        // just use the default Vamp path or VAMP_PATH environment
+        // variable -- leave it up to the Vamp SDK
+        return;
+    }
+
+    std::vector<std::string> vampPathList = 
+        Vamp::PluginHostAdapter::getPluginPath();
+
+    QStringList qVampPathList;
+    for (auto p: vampPathList) qVampPathList.push_back(p.c_str());
+    QString vampPath = qVampPathList.join(sep);
+    QString newPath = tonyVampPath + sep + vampPath;
+
+    cerr << "Setting VAMP_PATH to " << newPath << " for Tony plugins" << endl;
+    
+    setenv("VAMP_PATH", newPath.toLocal8Bit().data(), 1);
+}
         
 int
 main(int argc, char **argv)
@@ -127,6 +169,8 @@
     }
 #endif
 
+    setupTonyVampPath();
+
     TonyApplication application(argc, argv);
 
     QStringList args = application.arguments();