comparison plugin/LADSPAPluginFactory.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
78 i != m_identifiers.end(); ++i) { 78 i != m_identifiers.end(); ++i) {
79 79
80 const LADSPA_Descriptor *descriptor = getLADSPADescriptor(*i); 80 const LADSPA_Descriptor *descriptor = getLADSPADescriptor(*i);
81 81
82 if (!descriptor) { 82 if (!descriptor) {
83 std::cerr << "WARNING: LADSPAPluginFactory::enumeratePlugins: couldn't get descriptor for identifier " << i->toStdString() << std::endl; 83 cerr << "WARNING: LADSPAPluginFactory::enumeratePlugins: couldn't get descriptor for identifier " << i->toStdString() << endl;
84 continue; 84 continue;
85 } 85 }
86 86
87 list.push_back(*i); 87 list.push_back(*i);
88 list.push_back(descriptor->Name); 88 list.push_back(descriptor->Name);
92 list.push_back(descriptor->Copyright); 92 list.push_back(descriptor->Copyright);
93 list.push_back("false"); // is synth 93 list.push_back("false"); // is synth
94 list.push_back("false"); // is grouped 94 list.push_back("false"); // is grouped
95 95
96 if (m_taxonomy.find(*i) != m_taxonomy.end() && m_taxonomy[*i] != "") { 96 if (m_taxonomy.find(*i) != m_taxonomy.end() && m_taxonomy[*i] != "") {
97 // std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString()<< " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << std::endl; 97 // cerr << "LADSPAPluginFactory: cat for " << i->toStdString()<< " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << endl;
98 list.push_back(m_taxonomy[*i]); 98 list.push_back(m_taxonomy[*i]);
99 } else { 99 } else {
100 list.push_back(""); 100 list.push_back("");
101 // std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString() << " not found (despite having " << m_fallbackCategories.size() << " fallbacks)" << std::endl; 101 // cerr << "LADSPAPluginFactory: cat for " << i->toStdString() << " not found (despite having " << m_fallbackCategories.size() << " fallbacks)" << endl;
102 102
103 } 103 }
104 104
105 list.push_back(QString("%1").arg(descriptor->PortCount)); 105 list.push_back(QString("%1").arg(descriptor->PortCount));
106 106
364 QString identifier) 364 QString identifier)
365 { 365 {
366 Profiler profiler("LADSPAPluginFactory::releasePlugin"); 366 Profiler profiler("LADSPAPluginFactory::releasePlugin");
367 367
368 if (m_instances.find(instance) == m_instances.end()) { 368 if (m_instances.find(instance) == m_instances.end()) {
369 std::cerr << "WARNING: LADSPAPluginFactory::releasePlugin: Not one of mine!" 369 cerr << "WARNING: LADSPAPluginFactory::releasePlugin: Not one of mine!"
370 << std::endl; 370 << endl;
371 return; 371 return;
372 } 372 }
373 373
374 QString type, soname, label; 374 QString type, soname, label;
375 PluginIdentifier::parseIdentifier(identifier, type, soname, label); 375 PluginIdentifier::parseIdentifier(identifier, type, soname, label);
413 PluginIdentifier::parseIdentifier(identifier, type, soname, label); 413 PluginIdentifier::parseIdentifier(identifier, type, soname, label);
414 414
415 if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { 415 if (m_libraryHandles.find(soname) == m_libraryHandles.end()) {
416 loadLibrary(soname); 416 loadLibrary(soname);
417 if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { 417 if (m_libraryHandles.find(soname) == m_libraryHandles.end()) {
418 std::cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: loadLibrary failed for " << soname << std::endl; 418 cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: loadLibrary failed for " << soname << endl;
419 return 0; 419 return 0;
420 } 420 }
421 } 421 }
422 422
423 void *libraryHandle = m_libraryHandles[soname]; 423 void *libraryHandle = m_libraryHandles[soname];
424 424
425 LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function) 425 LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function)
426 DLSYM(libraryHandle, "ladspa_descriptor"); 426 DLSYM(libraryHandle, "ladspa_descriptor");
427 427
428 if (!fn) { 428 if (!fn) {
429 std::cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No descriptor function in library " << soname << std::endl; 429 cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No descriptor function in library " << soname << endl;
430 return 0; 430 return 0;
431 } 431 }
432 432
433 const LADSPA_Descriptor *descriptor = 0; 433 const LADSPA_Descriptor *descriptor = 0;
434 434
436 while ((descriptor = fn(index))) { 436 while ((descriptor = fn(index))) {
437 if (descriptor->Label == label) return descriptor; 437 if (descriptor->Label == label) return descriptor;
438 ++index; 438 ++index;
439 } 439 }
440 440
441 std::cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No such plugin as " << label << " in library " << soname << std::endl; 441 cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No such plugin as " << label << " in library " << soname << endl;
442 442
443 return 0; 443 return 0;
444 } 444 }
445 445
446 void 446 void
453 return; 453 return;
454 } 454 }
455 455
456 if (QFileInfo(soName).exists()) { 456 if (QFileInfo(soName).exists()) {
457 DLERROR(); 457 DLERROR();
458 std::cerr << "LADSPAPluginFactory::loadLibrary: Library \"" << soName << "\" exists, but failed to load it" << std::endl; 458 cerr << "LADSPAPluginFactory::loadLibrary: Library \"" << soName << "\" exists, but failed to load it" << endl;
459 return; 459 return;
460 } 460 }
461 461
462 std::vector<QString> pathList = getPluginPath(); 462 std::vector<QString> pathList = getPluginPath();
463 463
475 QDir::Name | QDir::IgnoreCase, 475 QDir::Name | QDir::IgnoreCase,
476 QDir::Files | QDir::Readable); 476 QDir::Files | QDir::Readable);
477 477
478 if (QFileInfo(dir.filePath(fileName)).exists()) { 478 if (QFileInfo(dir.filePath(fileName)).exists()) {
479 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY 479 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
480 std::cerr << "Loading: " << fileName << std::endl; 480 cerr << "Loading: " << fileName << endl;
481 #endif 481 #endif
482 libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW); 482 libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW);
483 if (libraryHandle) { 483 if (libraryHandle) {
484 m_libraryHandles[soName] = libraryHandle; 484 m_libraryHandles[soName] = libraryHandle;
485 return; 485 return;
488 488
489 for (unsigned int j = 0; j < dir.count(); ++j) { 489 for (unsigned int j = 0; j < dir.count(); ++j) {
490 QString file = dir.filePath(dir[j]); 490 QString file = dir.filePath(dir[j]);
491 if (QFileInfo(file).baseName() == base) { 491 if (QFileInfo(file).baseName() == base) {
492 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY 492 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
493 std::cerr << "Loading: " << file << std::endl; 493 cerr << "Loading: " << file << endl;
494 #endif 494 #endif
495 libraryHandle = DLOPEN(file, RTLD_NOW); 495 libraryHandle = DLOPEN(file, RTLD_NOW);
496 if (libraryHandle) { 496 if (libraryHandle) {
497 m_libraryHandles[soName] = libraryHandle; 497 m_libraryHandles[soName] = libraryHandle;
498 return; 498 return;
499 } 499 }
500 } 500 }
501 } 501 }
502 } 502 }
503 503
504 std::cerr << "LADSPAPluginFactory::loadLibrary: Failed to locate plugin library \"" << soName << "\"" << std::endl; 504 cerr << "LADSPAPluginFactory::loadLibrary: Failed to locate plugin library \"" << soName << "\"" << endl;
505 } 505 }
506 506
507 void 507 void
508 LADSPAPluginFactory::unloadLibrary(QString soName) 508 LADSPAPluginFactory::unloadLibrary(QString soName)
509 { 509 {
651 651
652 for (size_t i = 0; i < lrdfPaths.size(); ++i) { 652 for (size_t i = 0; i < lrdfPaths.size(); ++i) {
653 QDir dir(lrdfPaths[i], "*.rdf;*.rdfs"); 653 QDir dir(lrdfPaths[i], "*.rdf;*.rdfs");
654 for (unsigned int j = 0; j < dir.count(); ++j) { 654 for (unsigned int j = 0; j < dir.count(); ++j) {
655 if (!lrdf_read_file(QString("file:" + lrdfPaths[i] + "/" + dir[j]).toStdString().c_str())) { 655 if (!lrdf_read_file(QString("file:" + lrdfPaths[i] + "/" + dir[j]).toStdString().c_str())) {
656 // std::cerr << "LADSPAPluginFactory: read RDF file " << (lrdfPaths[i] + "/" + dir[j]) << std::endl; 656 // cerr << "LADSPAPluginFactory: read RDF file " << (lrdfPaths[i] + "/" + dir[j]) << endl;
657 haveSomething = true; 657 haveSomething = true;
658 } 658 }
659 } 659 }
660 } 660 }
661 661
681 LADSPAPluginFactory::discoverPlugins(QString soname) 681 LADSPAPluginFactory::discoverPlugins(QString soname)
682 { 682 {
683 void *libraryHandle = DLOPEN(soname, RTLD_LAZY); 683 void *libraryHandle = DLOPEN(soname, RTLD_LAZY);
684 684
685 if (!libraryHandle) { 685 if (!libraryHandle) {
686 std::cerr << "WARNING: LADSPAPluginFactory::discoverPlugins: couldn't load plugin library " 686 cerr << "WARNING: LADSPAPluginFactory::discoverPlugins: couldn't load plugin library "
687 << soname << " - " << DLERROR() << std::endl; 687 << soname << " - " << DLERROR() << endl;
688 return; 688 return;
689 } 689 }
690 690
691 LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function) 691 LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function)
692 DLSYM(libraryHandle, "ladspa_descriptor"); 692 DLSYM(libraryHandle, "ladspa_descriptor");
693 693
694 if (!fn) { 694 if (!fn) {
695 std::cerr << "WARNING: LADSPAPluginFactory::discoverPlugins: No descriptor function in " << soname << std::endl; 695 cerr << "WARNING: LADSPAPluginFactory::discoverPlugins: No descriptor function in " << soname << endl;
696 return; 696 return;
697 } 697 }
698 698
699 const LADSPA_Descriptor *descriptor = 0; 699 const LADSPA_Descriptor *descriptor = 0;
700 700
720 char *def_uri = 0; 720 char *def_uri = 0;
721 lrdf_defaults *defs = 0; 721 lrdf_defaults *defs = 0;
722 722
723 if (m_lrdfTaxonomy[descriptor->UniqueID] != "") { 723 if (m_lrdfTaxonomy[descriptor->UniqueID] != "") {
724 m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->UniqueID]; 724 m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->UniqueID];
725 // std::cerr << "set id \"" << identifier << "\" to cat \"" << m_taxonomy[identifier] << "\" from LRDF" << std::endl; 725 // cerr << "set id \"" << identifier << "\" to cat \"" << m_taxonomy[identifier] << "\" from LRDF" << endl;
726 // std::cout << identifier << "::" << m_taxonomy[identifier] << std::endl; 726 // cout << identifier << "::" << m_taxonomy[identifier] << endl;
727 } 727 }
728 728
729 QString category = m_taxonomy[identifier]; 729 QString category = m_taxonomy[identifier];
730 730
731 if (category == "" && descriptor->Name != 0) { 731 if (category == "" && descriptor->Name != 0) {
737 } 737 }
738 } 738 }
739 739
740 rtd->category = category.toStdString(); 740 rtd->category = category.toStdString();
741 741
742 // std::cerr << "Plugin id is " << descriptor->UniqueID 742 // cerr << "Plugin id is " << descriptor->UniqueID
743 // << ", category is \"" << (category ? category : QString("(none)")) 743 // << ", category is \"" << (category ? category : QString("(none)"))
744 // << "\", name is " << descriptor->Name 744 // << "\", name is " << descriptor->Name
745 // << ", label is " << descriptor->Label 745 // << ", label is " << descriptor->Label
746 // << std::endl; 746 // << endl;
747 747
748 def_uri = lrdf_get_default_uri(descriptor->UniqueID); 748 def_uri = lrdf_get_default_uri(descriptor->UniqueID);
749 if (def_uri) { 749 if (def_uri) {
750 defs = lrdf_get_setting_values(def_uri); 750 defs = lrdf_get_setting_values(def_uri);
751 } 751 }
758 758
759 if (def_uri && defs) { 759 if (def_uri && defs) {
760 760
761 for (unsigned int j = 0; j < defs->count; j++) { 761 for (unsigned int j = 0; j < defs->count; j++) {
762 if (defs->items[j].pid == controlPortNumber) { 762 if (defs->items[j].pid == controlPortNumber) {
763 // std::cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << descriptor->PortNames[i] << std::endl; 763 // cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << descriptor->PortNames[i] << endl;
764 m_portDefaults[descriptor->UniqueID][i] = 764 m_portDefaults[descriptor->UniqueID][i] =
765 defs->items[j].value; 765 defs->items[j].value;
766 } 766 }
767 } 767 }
768 } 768 }
799 799
800 ++index; 800 ++index;
801 } 801 }
802 802
803 if (DLCLOSE(libraryHandle) != 0) { 803 if (DLCLOSE(libraryHandle) != 0) {
804 std::cerr << "WARNING: LADSPAPluginFactory::discoverPlugins - can't unload " << libraryHandle << std::endl; 804 cerr << "WARNING: LADSPAPluginFactory::discoverPlugins - can't unload " << libraryHandle << endl;
805 return; 805 return;
806 } 806 }
807 } 807 }
808 808
809 void 809 void
834 QFile file(path[i] + "/" + dir[j]); 834 QFile file(path[i] + "/" + dir[j]);
835 835
836 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl; 836 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl;
837 837
838 if (file.open(QIODevice::ReadOnly)) { 838 if (file.open(QIODevice::ReadOnly)) {
839 // std::cerr << "...opened" << std::endl; 839 // cerr << "...opened" << endl;
840 QTextStream stream(&file); 840 QTextStream stream(&file);
841 QString line; 841 QString line;
842 842
843 while (!stream.atEnd()) { 843 while (!stream.atEnd()) {
844 line = stream.readLine(); 844 line = stream.readLine();
845 // std::cerr << "line is: \"" << line << "\"" << std::endl; 845 // cerr << "line is: \"" << line << "\"" << endl;
846 QString id = PluginIdentifier::canonicalise 846 QString id = PluginIdentifier::canonicalise
847 (line.section("::", 0, 0)); 847 (line.section("::", 0, 0));
848 QString cat = line.section("::", 1, 1); 848 QString cat = line.section("::", 1, 1);
849 m_taxonomy[id] = cat; 849 m_taxonomy[id] = cat;
850 // std::cerr << "set id \"" << id << "\" to cat \"" << cat << "\"" << std::endl; 850 // cerr << "set id \"" << id << "\" to cat \"" << cat << "\"" << endl;
851 } 851 }
852 } 852 }
853 } 853 }
854 } 854 }
855 } 855 }