comparison plugin/FeatureExtractionPluginFactory.cpp @ 1150:fc4cb3901316 3.0-integration

Debug bits
author Chris Cannam
date Fri, 22 Jan 2016 09:52:08 +0000
parents afed8be79032
children ea636412f9fe
comparison
equal deleted inserted replaced
1149:afed8be79032 1150:fc4cb3901316
162 if (!bad.empty()) { 162 if (!bad.empty()) {
163 warningMessage = 163 warningMessage =
164 QObject::tr("<b>Failed to load plugins</b>" 164 QObject::tr("<b>Failed to load plugins</b>"
165 "<p>Failed to load one or more plugin libraries:</p>\n"); 165 "<p>Failed to load one or more plugin libraries:</p>\n");
166 warningMessage += "<ul>"; 166 warningMessage += "<ul>";
167 for (int i = 0; i < bad.size(); ++i) { 167 for (int i = 0; in_range_for(bad, i); ++i) {
168 QString m; 168 QString m;
169 if (badStatuses[i] == PluginLoadFailedToLoadLibrary) { 169 if (badStatuses[i] == PluginLoadFailedToLoadLibrary) {
170 m = QObject::tr("Failed to load library"); 170 m = QObject::tr("Failed to load library");
171 } else if (badStatuses[i] == PluginLoadFailedToFindDescriptor) { 171 } else if (badStatuses[i] == PluginLoadFailedToFindDescriptor) {
172 m = QObject::tr("Failed to query plugins from library after loading"); 172 m = QObject::tr("Failed to query plugins from library after loading");
374 int index = 0; 374 int index = 0;
375 375
376 QString type, soname, label; 376 QString type, soname, label;
377 PluginIdentifier::parseIdentifier(identifier, type, soname, label); 377 PluginIdentifier::parseIdentifier(identifier, type, soname, label);
378 if (type != "vamp") { 378 if (type != "vamp") {
379 SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl; 379 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
380 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl;
381 #endif
380 return 0; 382 return 0;
381 } 383 }
382 384
383 QString found = findPluginFile(soname); 385 QString found = findPluginFile(soname);
384 386
386 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find library file " << soname << endl; 388 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find library file " << soname << endl;
387 return 0; 389 return 0;
388 } else if (found != soname) { 390 } else if (found != soname) {
389 391
390 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 392 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
391 SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl; 393 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl;
392 cerr << soname << " -> " << found << endl; 394 cerr << soname << " -> " << found << endl;
393 #endif 395 #endif
394 396
395 } 397 }
396 398
405 407
406 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) 408 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
407 DLSYM(libraryHandle, "vampGetPluginDescriptor"); 409 DLSYM(libraryHandle, "vampGetPluginDescriptor");
408 410
409 if (!fn) { 411 if (!fn) {
410 SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname << endl; 412 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname << endl;
411 goto done; 413 goto done;
412 } 414 }
413 415
414 while ((descriptor = fn(VAMP_API_VERSION, index))) { 416 while ((descriptor = fn(VAMP_API_VERSION, index))) {
415 if (label == descriptor->identifier) break; 417 if (label == descriptor->identifier) break;
437 if (DLCLOSE(libraryHandle) != 0) { 439 if (DLCLOSE(libraryHandle) != 0) {
438 cerr << "WARNING: FeatureExtractionPluginFactory::instantiatePlugin: Failed to unload library " << soname << endl; 440 cerr << "WARNING: FeatureExtractionPluginFactory::instantiatePlugin: Failed to unload library " << soname << endl;
439 } 441 }
440 } 442 }
441 443
442 // SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << endl; 444 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
445 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << endl;
446 #endif
443 447
444 return rv; 448 return rv;
445 } 449 }
446 450
447 void 451 void
448 FeatureExtractionPluginFactory::pluginDeleted(Vamp::Plugin *plugin) 452 FeatureExtractionPluginFactory::pluginDeleted(Vamp::Plugin *plugin)
449 { 453 {
450 void *handle = m_handleMap[plugin]; 454 void *handle = m_handleMap[plugin];
451 if (handle) { 455 if (handle) {
452 // SVDEBUG << "unloading library " << handle << " for plugin " << plugin << endl; 456 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
457 cerr << "unloading library " << handle << " for plugin " << plugin << endl;
458 #endif
453 DLCLOSE(handle); 459 DLCLOSE(handle);
454 } 460 }
455 m_handleMap.erase(plugin); 461 m_handleMap.erase(plugin);
456 } 462 }
457 463