comparison plugin/FeatureExtractionPluginFactory.cpp @ 843:e802e550a1f2

Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author Chris Cannam
date Tue, 26 Nov 2013 13:35:08 +0000
parents 1424aa29ae95
children f5cd33909744
comparison
equal deleted inserted replaced
842:23d3a6eca5c3 843:e802e550a1f2
93 93
94 factory = instance("vamp"); 94 factory = instance("vamp");
95 if (factory) { 95 if (factory) {
96 std::vector<QString> tmp = factory->getPluginIdentifiers(); 96 std::vector<QString> tmp = factory->getPluginIdentifiers();
97 for (size_t i = 0; i < tmp.size(); ++i) { 97 for (size_t i = 0; i < tmp.size(); ++i) {
98 // std::cerr << "identifier: " << tmp[i] << std::endl; 98 // cerr << "identifier: " << tmp[i] << endl;
99 rv.push_back(tmp[i]); 99 rv.push_back(tmp[i]);
100 } 100 }
101 } 101 }
102 102
103 // Plugins can change the locale, revert it to default. 103 // Plugins can change the locale, revert it to default.
133 #endif 133 #endif
134 134
135 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); 135 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
136 136
137 if (!libraryHandle) { 137 if (!libraryHandle) {
138 std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << std::endl; 138 cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl;
139 continue; 139 continue;
140 } 140 }
141 141
142 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 142 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
143 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << endl; 143 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << endl;
145 145
146 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) 146 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
147 DLSYM(libraryHandle, "vampGetPluginDescriptor"); 147 DLSYM(libraryHandle, "vampGetPluginDescriptor");
148 148
149 if (!fn) { 149 if (!fn) {
150 std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: No descriptor function in " << soname << std::endl; 150 cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: No descriptor function in " << soname << endl;
151 if (DLCLOSE(libraryHandle) != 0) { 151 if (DLCLOSE(libraryHandle) != 0) {
152 std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << std::endl; 152 cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl;
153 } 153 }
154 continue; 154 continue;
155 } 155 }
156 156
157 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 157 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
165 bool ok = true; 165 bool ok = true;
166 166
167 while ((descriptor = fn(VAMP_API_VERSION, index))) { 167 while ((descriptor = fn(VAMP_API_VERSION, index))) {
168 168
169 if (known.find(descriptor->identifier) != known.end()) { 169 if (known.find(descriptor->identifier) != known.end()) {
170 std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Plugin library " 170 cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Plugin library "
171 << soname.toStdString() 171 << soname.toStdString()
172 << " returns the same plugin identifier \"" 172 << " returns the same plugin identifier \""
173 << descriptor->identifier << "\" at indices " 173 << descriptor->identifier << "\" at indices "
174 << known[descriptor->identifier] << " and " 174 << known[descriptor->identifier] << " and "
175 << index << std::endl; 175 << index << endl;
176 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; 176 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl;
177 ok = false; 177 ok = false;
178 break; 178 break;
179 } else { 179 } else {
180 known[descriptor->identifier] = index; 180 known[descriptor->identifier] = index;
198 ++index; 198 ++index;
199 } 199 }
200 } 200 }
201 201
202 if (DLCLOSE(libraryHandle) != 0) { 202 if (DLCLOSE(libraryHandle) != 0) {
203 std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << std::endl; 203 cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl;
204 } 204 }
205 } 205 }
206 } 206 }
207 207
208 generateTaxonomy(); 208 generateTaxonomy();
315 } 315 }
316 316
317 QString found = findPluginFile(soname); 317 QString found = findPluginFile(soname);
318 318
319 if (found == "") { 319 if (found == "") {
320 std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find library file " << soname << std::endl; 320 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find library file " << soname << endl;
321 return 0; 321 return 0;
322 } else if (found != soname) { 322 } else if (found != soname) {
323 323
324 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 324 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
325 SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl; 325 SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl;
326 std::cerr << soname << " -> " << found << std::endl; 326 cerr << soname << " -> " << found << endl;
327 #endif 327 #endif
328 328
329 } 329 }
330 330
331 soname = found; 331 soname = found;
332 332
333 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); 333 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
334 334
335 if (!libraryHandle) { 335 if (!libraryHandle) {
336 std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to load library " << soname << ": " << DLERROR() << std::endl; 336 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to load library " << soname << ": " << DLERROR() << endl;
337 return 0; 337 return 0;
338 } 338 }
339 339
340 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) 340 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
341 DLSYM(libraryHandle, "vampGetPluginDescriptor"); 341 DLSYM(libraryHandle, "vampGetPluginDescriptor");
349 if (label == descriptor->identifier) break; 349 if (label == descriptor->identifier) break;
350 ++index; 350 ++index;
351 } 351 }
352 352
353 if (!descriptor) { 353 if (!descriptor) {
354 std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find plugin \"" << label << "\" in library " << soname << std::endl; 354 cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find plugin \"" << label << "\" in library " << soname << endl;
355 goto done; 355 goto done;
356 } 356 }
357 357
358 plugin = new Vamp::PluginHostAdapter(descriptor, inputSampleRate); 358 plugin = new Vamp::PluginHostAdapter(descriptor, inputSampleRate);
359 359
367 //!!! need to dlclose() when plugins from a given library are unloaded 367 //!!! need to dlclose() when plugins from a given library are unloaded
368 368
369 done: 369 done:
370 if (!rv) { 370 if (!rv) {
371 if (DLCLOSE(libraryHandle) != 0) { 371 if (DLCLOSE(libraryHandle) != 0) {
372 std::cerr << "WARNING: FeatureExtractionPluginFactory::instantiatePlugin: Failed to unload library " << soname << std::endl; 372 cerr << "WARNING: FeatureExtractionPluginFactory::instantiatePlugin: Failed to unload library " << soname << endl;
373 } 373 }
374 } 374 }
375 375
376 // SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << endl; 376 // SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << endl;
377 377
421 QFile file(path[i] + "/" + dir[j]); 421 QFile file(path[i] + "/" + dir[j]);
422 422
423 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl; 423 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl;
424 424
425 if (file.open(QIODevice::ReadOnly)) { 425 if (file.open(QIODevice::ReadOnly)) {
426 // std::cerr << "...opened" << std::endl; 426 // cerr << "...opened" << endl;
427 QTextStream stream(&file); 427 QTextStream stream(&file);
428 QString line; 428 QString line;
429 429
430 while (!stream.atEnd()) { 430 while (!stream.atEnd()) {
431 line = stream.readLine(); 431 line = stream.readLine();
432 // std::cerr << "line is: \"" << line << "\"" << std::endl; 432 // cerr << "line is: \"" << line << "\"" << endl;
433 QString id = PluginIdentifier::canonicalise 433 QString id = PluginIdentifier::canonicalise
434 (line.section("::", 0, 0)); 434 (line.section("::", 0, 0));
435 QString cat = line.section("::", 1, 1); 435 QString cat = line.section("::", 1, 1);
436 m_taxonomy[id] = cat; 436 m_taxonomy[id] = cat;
437 // std::cerr << "FeatureExtractionPluginFactory: set id \"" << id << "\" to cat \"" << cat << "\"" << std::endl; 437 // cerr << "FeatureExtractionPluginFactory: set id \"" << id << "\" to cat \"" << cat << "\"" << endl;
438 } 438 }
439 } 439 }
440 } 440 }
441 } 441 }
442 } 442 }