comparison plugin/PiperVampPluginFactory.cpp @ 1241:c6bdf247016a 3.0-integration

Support multiple plugin checker helpers, as for multiple piper servers
author Chris Cannam
date Tue, 01 Nov 2016 14:06:47 +0000
parents 42a4b058f8ba
children 604b0b2a58e1
comparison
equal deleted inserted replaced
1240:42a4b058f8ba 1241:c6bdf247016a
2 2
3 /* 3 /*
4 Sonic Visualiser 4 Sonic Visualiser
5 An audio file viewer and annotation editor. 5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London. 6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam and QMUL. 7 This file copyright 2006-2016 Chris Cannam and QMUL.
8 8
9 This program is free software; you can redistribute it and/or 9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as 10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
35 #include <QCoreApplication> 35 #include <QCoreApplication>
36 36
37 #include <iostream> 37 #include <iostream>
38 38
39 #include "base/Profiler.h" 39 #include "base/Profiler.h"
40 #include "base/HelperExecPath.h"
40 41
41 #include "vamp-client/ProcessQtTransport.h" 42 #include "vamp-client/ProcessQtTransport.h"
42 #include "vamp-client/CapnpRRClient.h" 43 #include "vamp-client/CapnpRRClient.h"
43 44
44 using namespace std; 45 using namespace std;
45 46
46 //#define DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 1 47 //#define DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 1
47 48
48 PiperVampPluginFactory::PiperVampPluginFactory() 49 PiperVampPluginFactory::PiperVampPluginFactory()
49 { 50 {
50 // Server must exist either in the same directory as this one or 51 QString serverName = "piper-vamp-simple-server";
51 // (preferably) a subdirectory called "piper-bin". 52
52 //!!! todo: merge this with plugin scan checker thingy used in main.cpp? 53 m_servers = HelperExecPath::getHelperExecutables(serverName);
53
54 QString myDir = QCoreApplication::applicationDirPath();
55 QString name = "piper-vamp-simple-server";
56 QStringList suffixes = getServerSuffixes();
57 QString extension = "";
58 #ifdef _WIN32
59 extension = ".exe";
60 #endif
61
62 for (QString s: suffixes) {
63
64 QString path = myDir + "/piper-bin/" + name + s + extension;
65
66 if (QFile(path).exists()) {
67 m_servers.push_back(path);
68 } else {
69 cerr << "NOTE: Piper Vamp server " << name << s
70 << " not found at " << path
71 << ", trying in my own directory" << endl;
72 path = myDir + "/" + name + s + extension;
73
74 if (QFile(path).exists()) {
75 m_servers.push_back(path);
76 } else {
77 cerr << "NOTE: Piper Vamp server " << name << s
78 << " not found at " << path << endl;
79 }
80 }
81 }
82 54
83 if (m_servers.empty()) { 55 if (m_servers.empty()) {
84 cerr << "NOTE: No Piper Vamp servers found" << endl; 56 cerr << "NOTE: No Piper Vamp servers found in installation;"
57 << " found none of the following:" << endl;
58 for (auto d: HelperExecPath::getHelperCandidatePaths(serverName)) {
59 cerr << "NOTE: " << d << endl;
60 }
85 } 61 }
86 } 62 }
87 63
88 QStringList 64 QStringList
89 PiperVampPluginFactory::getServerSuffixes() 65 PiperVampPluginFactory::getServerSuffixes()