Mercurial > hg > svcore
comparison plugin/FeatureExtractionPluginFactory.cpp @ 1160:ea636412f9fe 3.0-integration
Merge from the default branch
author | Chris Cannam |
---|---|
date | Thu, 04 Feb 2016 11:16:05 +0000 |
parents | fc4cb3901316 c7f1300dbf64 |
children | 6877f4200912 |
comparison
equal
deleted
inserted
replaced
1159:444d133b5ab7 | 1160:ea636412f9fe |
---|---|
117 vector<QString> candidates; | 117 vector<QString> candidates; |
118 | 118 |
119 for (QString dirname : path) { | 119 for (QString dirname : path) { |
120 | 120 |
121 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 121 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
122 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << dirname << endl; | 122 cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << dirname << endl; |
123 #endif | 123 #endif |
124 | 124 |
125 QDir pluginDir(dirname, PLUGIN_GLOB, | 125 QDir pluginDir(dirname, PLUGIN_GLOB, |
126 QDir::Name | QDir::IgnoreCase, | 126 QDir::Name | QDir::IgnoreCase, |
127 QDir::Files | QDir::Readable); | 127 QDir::Files | QDir::Readable); |
194 m_pluginScanError); | 194 m_pluginScanError); |
195 | 195 |
196 for (QString soname : candidates) { | 196 for (QString soname : candidates) { |
197 | 197 |
198 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 198 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
199 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl; | 199 cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl; |
200 #endif | 200 #endif |
201 | 201 |
202 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); | 202 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); |
203 | 203 |
204 if (!libraryHandle) { | 204 if (!libraryHandle) { |
205 cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl; | 205 cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl; |
206 continue; | 206 continue; |
207 } | 207 } |
208 | 208 |
209 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 209 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
210 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << endl; | 210 cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << endl; |
211 #endif | 211 #endif |
212 | 212 |
213 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) | 213 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) |
214 DLSYM(libraryHandle, "vampGetPluginDescriptor"); | 214 DLSYM(libraryHandle, "vampGetPluginDescriptor"); |
215 | 215 |
220 } | 220 } |
221 continue; | 221 continue; |
222 } | 222 } |
223 | 223 |
224 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 224 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
225 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << endl; | 225 cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << endl; |
226 #endif | 226 #endif |
227 | 227 |
228 const VampPluginDescriptor *descriptor = 0; | 228 const VampPluginDescriptor *descriptor = 0; |
229 int index = 0; | 229 int index = 0; |
230 | 230 |
238 << soname | 238 << soname |
239 << " returns the same plugin identifier \"" | 239 << " returns the same plugin identifier \"" |
240 << descriptor->identifier << "\" at indices " | 240 << descriptor->identifier << "\" at indices " |
241 << known[descriptor->identifier] << " and " | 241 << known[descriptor->identifier] << " and " |
242 << index << endl; | 242 << index << endl; |
243 cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; | 243 cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; |
244 ok = false; | 244 ok = false; |
245 break; | 245 break; |
246 } else { | 246 } else { |
247 known[descriptor->identifier] = index; | 247 known[descriptor->identifier] = index; |
248 } | 248 } |
258 | 258 |
259 QString id = PluginIdentifier::createIdentifier | 259 QString id = PluginIdentifier::createIdentifier |
260 ("vamp", soname, descriptor->identifier); | 260 ("vamp", soname, descriptor->identifier); |
261 rv.push_back(id); | 261 rv.push_back(id); |
262 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 262 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
263 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl; | 263 cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl; |
264 #endif | 264 #endif |
265 ++index; | 265 ++index; |
266 } | 266 } |
267 } | 267 } |
268 | 268 |
280 FeatureExtractionPluginFactory::findPluginFile(QString soname, QString inDir) | 280 FeatureExtractionPluginFactory::findPluginFile(QString soname, QString inDir) |
281 { | 281 { |
282 QString file = ""; | 282 QString file = ""; |
283 | 283 |
284 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 284 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
285 SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile(\"" | 285 cerr << "FeatureExtractionPluginFactory::findPluginFile(\"" |
286 << soname << "\", \"" << inDir << "\")" | 286 << soname << "\", \"" << inDir << "\")" |
287 << endl; | 287 << endl; |
288 #endif | 288 #endif |
289 | 289 |
290 if (inDir != "") { | 290 if (inDir != "") { |
297 file = dir.filePath(QFileInfo(soname).fileName()); | 297 file = dir.filePath(QFileInfo(soname).fileName()); |
298 | 298 |
299 if (QFileInfo(file).exists() && QFileInfo(file).isFile()) { | 299 if (QFileInfo(file).exists() && QFileInfo(file).isFile()) { |
300 | 300 |
301 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 301 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
302 SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: " | 302 cerr << "FeatureExtractionPluginFactory::findPluginFile: " |
303 << "found trivially at " << file << endl; | 303 << "found trivially at " << file << endl; |
304 #endif | 304 #endif |
305 | 305 |
306 return file; | 306 return file; |
307 } | 307 } |
309 for (unsigned int j = 0; j < dir.count(); ++j) { | 309 for (unsigned int j = 0; j < dir.count(); ++j) { |
310 file = dir.filePath(dir[j]); | 310 file = dir.filePath(dir[j]); |
311 if (QFileInfo(file).baseName() == QFileInfo(soname).baseName()) { | 311 if (QFileInfo(file).baseName() == QFileInfo(soname).baseName()) { |
312 | 312 |
313 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 313 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
314 SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: " | 314 cerr << "FeatureExtractionPluginFactory::findPluginFile: " |
315 << "found \"" << soname << "\" at " << file << endl; | 315 << "found \"" << soname << "\" at " << file << endl; |
316 #endif | 316 #endif |
317 | 317 |
318 return file; | 318 return file; |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 322 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
323 SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile (with dir): " | 323 cerr << "FeatureExtractionPluginFactory::findPluginFile (with dir): " |
324 << "not found" << endl; | 324 << "not found" << endl; |
325 #endif | 325 #endif |
326 | 326 |
327 return ""; | 327 return ""; |
328 | 328 |
330 | 330 |
331 QFileInfo fi(soname); | 331 QFileInfo fi(soname); |
332 | 332 |
333 if (fi.isAbsolute() && fi.exists() && fi.isFile()) { | 333 if (fi.isAbsolute() && fi.exists() && fi.isFile()) { |
334 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 334 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
335 SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: " | 335 cerr << "FeatureExtractionPluginFactory::findPluginFile: " |
336 << "found trivially at " << soname << endl; | 336 << "found trivially at " << soname << endl; |
337 #endif | 337 #endif |
338 return soname; | 338 return soname; |
339 } | 339 } |
340 | 340 |
351 if (file != "") return file; | 351 if (file != "") return file; |
352 } | 352 } |
353 } | 353 } |
354 | 354 |
355 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 355 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
356 SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: " | 356 cerr << "FeatureExtractionPluginFactory::findPluginFile: " |
357 << "not found" << endl; | 357 << "not found" << endl; |
358 #endif | 358 #endif |
359 | 359 |
360 return ""; | 360 return ""; |
361 } | 361 } |