comparison main/main.cpp @ 597:5ff3eb39e580

Merge
author Chris Cannam
date Fri, 27 Sep 2019 16:02:44 +0100
parents b76234d1a217
children e50b2e568679
comparison
equal deleted inserted replaced
596:7dfec898b6c4 597:5ff3eb39e580
40 40
41 #include <iostream> 41 #include <iostream>
42 #include <signal.h> 42 #include <signal.h>
43 #include <cstdlib> 43 #include <cstdlib>
44 44
45 #include "../version.h"
46
45 #include <vamp-hostsdk/PluginHostAdapter.h> 47 #include <vamp-hostsdk/PluginHostAdapter.h>
46 48
47 static QMutex cleanupMutex; 49 static QMutex cleanupMutex;
48 static bool cleanedUp = false; 50 static bool cleanedUp = false;
49 51
147 } 149 }
148 150
149 static void 151 static void
150 setupTonyVampPath() 152 setupTonyVampPath()
151 { 153 {
152 QString tonyVampPath = getEnvQStr("TONY_VAMP_PATH"); 154 QString myVampPath = getEnvQStr("TONY_VAMP_PATH");
153 155
154 #ifdef Q_OS_WIN32 156 #ifdef Q_OS_WIN32
155 QChar sep(';'); 157 QChar sep(';');
156 #else 158 #else
157 QChar sep(':'); 159 QChar sep(':');
158 #endif 160 #endif
159 161
160 if (tonyVampPath == "") { 162 if (myVampPath == "") {
161 tonyVampPath = QApplication::applicationDirPath(); 163
164 QString appName = QApplication::applicationName();
165 QString myDir = QApplication::applicationDirPath();
166 QString binaryName = QFileInfo(QCoreApplication::arguments().at(0))
167 .fileName();
162 168
163 #ifdef Q_OS_WIN32 169 #ifdef Q_OS_WIN32
164 QString programFiles = getEnvQStr("ProgramFiles"); 170 QString programFiles = getEnvQStr("ProgramFiles");
165 if (programFiles == "") programFiles = "C:\\Program Files"; 171 if (programFiles == "") programFiles = "C:\\Program Files";
166 QString defaultTonyPath(programFiles + "\\Tony"); 172 QString pfPath(programFiles + "\\" + appName);
167 tonyVampPath = tonyVampPath + sep + defaultTonyPath; 173 myVampPath = myDir + sep + pfPath;
168 #else 174 #else
169 #ifdef Q_OS_MAC 175 #ifdef Q_OS_MAC
170 tonyVampPath = tonyVampPath + "/../Resources:" + tonyVampPath; 176 myVampPath = myDir + "/../Resources";
171 #else 177 #else
172 QString defaultTonyPath("/usr/local/lib/tony:/usr/lib/tony"); 178 if (binaryName != "") {
173 tonyVampPath = tonyVampPath + sep + defaultTonyPath; 179 myVampPath =
174 #endif 180 myDir + "/../lib/" + binaryName + sep;
175 #endif 181 }
176 } 182 myVampPath = myVampPath +
177 183 myDir + "/../lib/" + appName + sep +
178 std::vector<std::string> vampPathList = 184 myDir;
179 Vamp::PluginHostAdapter::getPluginPath(); 185 #endif
180 186 #endif
181 for (auto p: vampPathList) { 187 }
182 tonyVampPath = tonyVampPath + sep + QString::fromUtf8(p.c_str()); 188
183 } 189 SVCERR << "Setting VAMP_PATH to " << myVampPath
184
185 SVCERR << "Setting VAMP_PATH to " << tonyVampPath
186 << " for Tony plugins" << endl; 190 << " for Tony plugins" << endl;
187 191
188 QString env = "VAMP_PATH=" + tonyVampPath; 192 QString env = "VAMP_PATH=" + myVampPath;
189 193
190 // Windows lacks setenv, must use putenv (different arg convention) 194 // Windows lacks setenv, must use putenv (different arg convention)
191 putEnvQStr(env); 195 putEnvQStr(env);
192 } 196 }
193 197
194 int 198 int
195 main(int argc, char **argv) 199 main(int argc, char **argv)
196 { 200 {
201 if (argc == 2 && (QString(argv[1]) == "--version" ||
202 QString(argv[1]) == "-v")) {
203 cerr << TONY_VERSION << endl;
204 exit(0);
205 }
206
197 svSystemSpecificInitialisation(); 207 svSystemSpecificInitialisation();
198 208
199 #ifdef Q_OS_MAC 209 #ifdef Q_OS_MAC
200 if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) { 210 if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) {
201 // Fix for OS/X 10.9 font problem 211 // Fix for OS/X 10.9 font problem
202 QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); 212 QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
203 } 213 }