Mercurial > hg > svcore
comparison plugin/PiperVampPluginFactory.cpp @ 1264:a99641535e02 3.0-integration
Debug output improvements, and make the checker actually attempt to call the descriptor function for known plugin types
author | Chris Cannam |
---|---|
date | Wed, 16 Nov 2016 16:12:42 +0000 |
parents | c2d66e3c83d0 |
children | 54fabf5aceb8 |
comparison
equal
deleted
inserted
replaced
1263:abfc498c52bc | 1264:a99641535e02 |
---|---|
46 | 46 |
47 using namespace std; | 47 using namespace std; |
48 | 48 |
49 //#define DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 1 | 49 //#define DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 1 |
50 | 50 |
51 PiperVampPluginFactory::PiperVampPluginFactory() | 51 class PiperVampPluginFactory::Logger : public piper_vamp::client::LogCallback { |
52 protected: | |
53 void log(std::string message) const override { | |
54 SVDEBUG << "PiperVampPluginFactory: " << message << endl; | |
55 } | |
56 }; | |
57 | |
58 PiperVampPluginFactory::PiperVampPluginFactory() : | |
59 m_logger(new Logger) | |
52 { | 60 { |
53 QString serverName = "piper-vamp-simple-server"; | 61 QString serverName = "piper-vamp-simple-server"; |
54 | 62 |
55 HelperExecPath hep(HelperExecPath::AllInstalled); | 63 HelperExecPath hep(HelperExecPath::AllInstalled); |
56 m_servers = hep.getHelperExecutables(serverName); | 64 m_servers = hep.getHelperExecutables(serverName); |
67 SVDEBUG << "NOTE: " << d << endl; | 75 SVDEBUG << "NOTE: " << d << endl; |
68 } | 76 } |
69 } | 77 } |
70 } | 78 } |
71 | 79 |
80 PiperVampPluginFactory::~PiperVampPluginFactory() | |
81 { | |
82 delete m_logger; | |
83 } | |
84 | |
72 vector<QString> | 85 vector<QString> |
73 PiperVampPluginFactory::getPluginIdentifiers(QString &errorMessage) | 86 PiperVampPluginFactory::getPluginIdentifiers(QString &errorMessage) |
74 { | 87 { |
75 Profiler profiler("PiperVampPluginFactory::getPluginIdentifiers"); | 88 Profiler profiler("PiperVampPluginFactory::getPluginIdentifiers"); |
76 | 89 |
108 | 121 |
109 auto psd = getPluginStaticData(identifier); | 122 auto psd = getPluginStaticData(identifier); |
110 if (psd.pluginKey == "") { | 123 if (psd.pluginKey == "") { |
111 return 0; | 124 return 0; |
112 } | 125 } |
126 | |
127 SVDEBUG << "PiperVampPluginFactory: Creating Piper AutoPlugin for server " | |
128 << m_origins[identifier] << ", identifier " << identifier << endl; | |
113 | 129 |
114 auto ap = new piper_vamp::client::AutoPlugin | 130 auto ap = new piper_vamp::client::AutoPlugin |
115 (m_origins[identifier].toStdString(), | 131 (m_origins[identifier].toStdString(), |
116 psd.pluginKey, float(inputSampleRate), 0); | 132 psd.pluginKey, |
133 float(inputSampleRate), | |
134 0, | |
135 m_logger); | |
117 | 136 |
118 if (!ap->isOK()) { | 137 if (!ap->isOK()) { |
119 delete ap; | 138 delete ap; |
120 return 0; | 139 return 0; |
121 } | 140 } |
167 | 186 |
168 PluginScan *scan = PluginScan::getInstance(); | 187 PluginScan *scan = PluginScan::getInstance(); |
169 auto candidateLibraries = | 188 auto candidateLibraries = |
170 scan->getCandidateLibrariesFor(PluginScan::VampPlugin); | 189 scan->getCandidateLibrariesFor(PluginScan::VampPlugin); |
171 | 190 |
191 SVDEBUG << "PiperVampPluginFactory: Populating from " << executable << endl; | |
172 SVDEBUG << "INFO: Have " << candidateLibraries.size() | 192 SVDEBUG << "INFO: Have " << candidateLibraries.size() |
173 << " candidate Vamp plugin libraries" << endl; | 193 << " candidate Vamp plugin libraries from scanner" << endl; |
174 | 194 |
175 vector<string> from; | 195 vector<string> from; |
176 for (const auto &c: candidateLibraries) { | 196 for (const auto &c: candidateLibraries) { |
177 if (c.helperTag == tag) { | 197 if (c.helperTag == tag) { |
178 string soname = QFileInfo(c.libraryPath).baseName().toStdString(); | 198 string soname = QFileInfo(c.libraryPath).baseName().toStdString(); |
193 } else { | 213 } else { |
194 SVDEBUG << ", but it seems the scan failed, so bumbling on anyway" << endl; | 214 SVDEBUG << ", but it seems the scan failed, so bumbling on anyway" << endl; |
195 } | 215 } |
196 } | 216 } |
197 | 217 |
198 piper_vamp::client::ProcessQtTransport transport(executable, "capnp"); | 218 piper_vamp::client::ProcessQtTransport transport(executable, "capnp", m_logger); |
199 if (!transport.isOK()) { | 219 if (!transport.isOK()) { |
220 SVDEBUG << "PiperVampPluginFactory: Failed to start Piper process transport" << endl; | |
200 errorMessage = QObject::tr("Could not start external plugin host"); | 221 errorMessage = QObject::tr("Could not start external plugin host"); |
201 return; | 222 return; |
202 } | 223 } |
203 | 224 |
204 piper_vamp::client::CapnpRRClient client(&transport); | 225 piper_vamp::client::CapnpRRClient client(&transport, m_logger); |
205 | 226 |
206 piper_vamp::ListRequest req; | 227 piper_vamp::ListRequest req; |
207 req.from = from; | 228 req.from = from; |
208 | 229 |
209 piper_vamp::ListResponse resp; | 230 piper_vamp::ListResponse resp; |
210 | 231 |
211 try { | 232 try { |
212 resp = client.listPluginData(req); | 233 resp = client.listPluginData(req); |
213 } catch (piper_vamp::client::ServerCrashed) { | 234 } catch (piper_vamp::client::ServerCrashed) { |
235 SVDEBUG << "PiperVampPluginFactory: Piper server crashed" << endl; | |
214 errorMessage = QObject::tr | 236 errorMessage = QObject::tr |
215 ("External plugin host exited unexpectedly while listing plugins"); | 237 ("External plugin host exited unexpectedly while listing plugins"); |
216 return; | 238 return; |
217 } catch (const std::exception &e) { | 239 } catch (const std::exception &e) { |
240 SVDEBUG << "PiperVampPluginFactory: Exception caught: " << e.what() << endl; | |
218 errorMessage = QObject::tr("External plugin host invocation failed: %1") | 241 errorMessage = QObject::tr("External plugin host invocation failed: %1") |
219 .arg(e.what()); | 242 .arg(e.what()); |
220 return; | 243 return; |
221 } | 244 } |
222 | 245 |