Mercurial > hg > svcore
diff plugin/FeatureExtractionPluginFactory.cpp @ 689:573d45e9487b
Merge from debug-output branch
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 14:47:59 +0100 |
parents | 06f13a3b9e9e |
children | 1424aa29ae95 |
line wrap: on
line diff
--- a/plugin/FeatureExtractionPluginFactory.cpp Tue Jun 14 13:43:03 2011 +0100 +++ b/plugin/FeatureExtractionPluginFactory.cpp Tue Jun 14 14:47:59 2011 +0100 @@ -58,8 +58,7 @@ { if (pluginType == "vamp") { if (!_nativeInstance) { -// std::cerr << "FeatureExtractionPluginFactory::instance(" << pluginType.toStdString() -// << "): creating new FeatureExtractionPluginFactory" << std::endl; +// DEBUG << "FeatureExtractionPluginFactory::instance(" << pluginType// << "): creating new FeatureExtractionPluginFactory" << endl; _nativeInstance = new FeatureExtractionPluginFactory(); } return _nativeInstance; @@ -96,7 +95,7 @@ if (factory) { std::vector<QString> tmp = factory->getPluginIdentifiers(); for (size_t i = 0; i < tmp.size(); ++i) { -// std::cerr << "identifier: " << tmp[i].toStdString() << std::endl; +// std::cerr << "identifier: " << tmp[i] << std::endl; rv.push_back(tmp[i]); } } @@ -118,7 +117,7 @@ for (std::vector<QString>::iterator i = path.begin(); i != path.end(); ++i) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i->toStdString() << std::endl; + DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i-<< endl; #endif QDir pluginDir(*i, PLUGIN_GLOB, @@ -130,33 +129,33 @@ QString soname = pluginDir.filePath(pluginDir[j]); #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname.toStdString() << std::endl; + DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl; #endif void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); if (!libraryHandle) { - std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname.toStdString() << ": " << DLERROR() << std::endl; + std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << std::endl; continue; } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << std::endl; + DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << endl; #endif VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) DLSYM(libraryHandle, "vampGetPluginDescriptor"); if (!fn) { - std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: No descriptor function in " << soname.toStdString() << std::endl; + std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: No descriptor function in " << soname << std::endl; if (DLCLOSE(libraryHandle) != 0) { - std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl; + std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << std::endl; } continue; } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << std::endl; + DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << endl; #endif const VampPluginDescriptor *descriptor = 0; @@ -174,7 +173,7 @@ << descriptor->identifier << "\" at indices " << known[descriptor->identifier] << " and " << index << std::endl; - std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << std::endl; + DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; ok = false; break; } else { @@ -194,14 +193,14 @@ ("vamp", soname, descriptor->identifier); rv.push_back(id); #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << " at index " << index << std::endl; + DEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl; #endif ++index; } } if (DLCLOSE(libraryHandle) != 0) { - std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl; + std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << std::endl; } } } @@ -217,9 +216,9 @@ QString file = ""; #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::findPluginFile(\"" - << soname.toStdString() << "\", \"" << inDir.toStdString() << "\")" - << std::endl; + DEBUG << "FeatureExtractionPluginFactory::findPluginFile(\"" + << soname << "\", \"" << inDir << "\")" + << endl; #endif if (inDir != "") { @@ -234,8 +233,8 @@ if (QFileInfo(file).exists() && QFileInfo(file).isFile()) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::findPluginFile: " - << "found trivially at " << file.toStdString() << std::endl; + DEBUG << "FeatureExtractionPluginFactory::findPluginFile: " + << "found trivially at " << file << endl; #endif return file; @@ -246,8 +245,8 @@ if (QFileInfo(file).baseName() == QFileInfo(soname).baseName()) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::findPluginFile: " - << "found \"" << soname.toStdString() << "\" at " << file.toStdString() << std::endl; + DEBUG << "FeatureExtractionPluginFactory::findPluginFile: " + << "found \"" << soname << "\" at " << file << endl; #endif return file; @@ -255,8 +254,8 @@ } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::findPluginFile (with dir): " - << "not found" << std::endl; + DEBUG << "FeatureExtractionPluginFactory::findPluginFile (with dir): " + << "not found" << endl; #endif return ""; @@ -267,8 +266,8 @@ if (fi.isAbsolute() && fi.exists() && fi.isFile()) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::findPluginFile: " - << "found trivially at " << soname.toStdString() << std::endl; + DEBUG << "FeatureExtractionPluginFactory::findPluginFile: " + << "found trivially at " << soname << endl; #endif return soname; } @@ -288,8 +287,8 @@ } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::findPluginFile: " - << "not found" << std::endl; + DEBUG << "FeatureExtractionPluginFactory::findPluginFile: " + << "not found" << endl; #endif return ""; @@ -311,20 +310,20 @@ QString type, soname, label; PluginIdentifier::parseIdentifier(identifier, type, soname, label); if (type != "vamp") { - std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type.toStdString() << std::endl; + DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl; return 0; } QString found = findPluginFile(soname); if (found == "") { - std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find library file " << soname.toStdString() << std::endl; + std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find library file " << soname << std::endl; return 0; } else if (found != soname) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname.toStdString() << ", found at " << found.toStdString() << std::endl; - std::cerr << soname.toStdString() << " -> " << found.toStdString() << std::endl; + DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl; + std::cerr << soname << " -> " << found << std::endl; #endif } @@ -334,7 +333,7 @@ void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); if (!libraryHandle) { - std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to load library " << soname.toStdString() << ": " << DLERROR() << std::endl; + std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to load library " << soname << ": " << DLERROR() << std::endl; return 0; } @@ -342,7 +341,7 @@ DLSYM(libraryHandle, "vampGetPluginDescriptor"); if (!fn) { - std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname.toStdString() << std::endl; + DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname << endl; goto done; } @@ -352,7 +351,7 @@ } if (!descriptor) { - std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find plugin \"" << label.toStdString() << "\" in library " << soname.toStdString() << std::endl; + std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find plugin \"" << label << "\" in library " << soname << std::endl; goto done; } @@ -363,18 +362,18 @@ rv = new PluginDeletionNotifyAdapter(plugin, this); } -// std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Constructed Vamp plugin, rv is " << rv << std::endl; +// DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Constructed Vamp plugin, rv is " << rv << endl; //!!! need to dlclose() when plugins from a given library are unloaded done: if (!rv) { if (DLCLOSE(libraryHandle) != 0) { - std::cerr << "WARNING: FeatureExtractionPluginFactory::instantiatePlugin: Failed to unload library " << soname.toStdString() << std::endl; + std::cerr << "WARNING: FeatureExtractionPluginFactory::instantiatePlugin: Failed to unload library " << soname << std::endl; } } -// std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label.toStdString() << " from library " << soname.toStdString() << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << std::endl; +// DEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << endl; return rv; } @@ -384,7 +383,7 @@ { void *handle = m_handleMap[plugin]; if (handle) { -// std::cerr << "unloading library " << handle << " for plugin " << plugin << std::endl; +// DEBUG << "unloading library " << handle << " for plugin " << plugin << endl; DLCLOSE(handle); } m_handleMap.erase(plugin); @@ -416,12 +415,12 @@ QDir dir(path[i], "*.cat"); -// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i].toStdString() << " has " << dir.count() << " .cat files" << std::endl; +// DEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl; for (unsigned int j = 0; j < dir.count(); ++j) { QFile file(path[i] + "/" + dir[j]); -// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i].toStdString() + "/" + dir[j].toStdString()) << std::endl; +// DEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl; if (file.open(QIODevice::ReadOnly)) { // std::cerr << "...opened" << std::endl; @@ -430,12 +429,12 @@ while (!stream.atEnd()) { line = stream.readLine(); -// std::cerr << "line is: \"" << line.toStdString() << "\"" << std::endl; +// std::cerr << "line is: \"" << line << "\"" << std::endl; QString id = PluginIdentifier::canonicalise (line.section("::", 0, 0)); QString cat = line.section("::", 1, 1); m_taxonomy[id] = cat; -// std::cerr << "FeatureExtractionPluginFactory: set id \"" << id.toStdString() << "\" to cat \"" << cat.toStdString() << "\"" << std::endl; +// std::cerr << "FeatureExtractionPluginFactory: set id \"" << id << "\" to cat \"" << cat << "\"" << std::endl; } } }