comparison plugin/LADSPAPluginFactory.cpp @ 166:702fc936e6a6

* Pull transforms out of Layer menu (again) and into a separate Transforms menu * Add Recent Transforms submenu * Add effects and generators to the transforms menu (not yet implemented) as well as analysis plugins and data-from-effects (control output ports) * Add a nice dictionary-volume-style alphabetic subdivision of plugin names in plugins By Name menus
author Chris Cannam
date Fri, 22 Sep 2006 16:12:23 +0000
parents 5ae5885d6ce3
children 06ad01f3e553
comparison
equal deleted inserted replaced
165:5ae5885d6ce3 166:702fc936e6a6
38 #endif // HAVE_LRDF 38 #endif // HAVE_LRDF
39 39
40 40
41 LADSPAPluginFactory::LADSPAPluginFactory() 41 LADSPAPluginFactory::LADSPAPluginFactory()
42 { 42 {
43 #ifdef HAVE_LRDF
44 lrdf_init();
45 #endif
43 } 46 }
44 47
45 LADSPAPluginFactory::~LADSPAPluginFactory() 48 LADSPAPluginFactory::~LADSPAPluginFactory()
46 { 49 {
47 for (std::set<RealTimePluginInstance *>::iterator i = m_instances.begin(); 50 for (std::set<RealTimePluginInstance *>::iterator i = m_instances.begin();
49 (*i)->setFactory(0); 52 (*i)->setFactory(0);
50 delete *i; 53 delete *i;
51 } 54 }
52 m_instances.clear(); 55 m_instances.clear();
53 unloadUnusedLibraries(); 56 unloadUnusedLibraries();
57
58 #ifdef HAVE_LRDF
59 lrdf_cleanup();
60 #endif // HAVE_LRDF
54 } 61 }
55 62
56 const std::vector<QString> & 63 const std::vector<QString> &
57 LADSPAPluginFactory::getPluginIdentifiers() const 64 LADSPAPluginFactory::getPluginIdentifiers() const
58 { 65 {
435 QDir::Files | QDir::Readable); 442 QDir::Files | QDir::Readable);
436 443
437 if (QFileInfo(dir.filePath(fileName)).exists()) { 444 if (QFileInfo(dir.filePath(fileName)).exists()) {
438 std::cerr << "Loading: " << fileName.toStdString() << std::endl; 445 std::cerr << "Loading: " << fileName.toStdString() << std::endl;
439 libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW); 446 libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW);
440 if (libraryHandle) m_libraryHandles[soName] = libraryHandle; 447 if (libraryHandle) {
441 return; 448 m_libraryHandles[soName] = libraryHandle;
449 return;
450 }
442 } 451 }
443 452
444 for (unsigned int j = 0; j < dir.count(); ++j) { 453 for (unsigned int j = 0; j < dir.count(); ++j) {
445 QString file = dir.filePath(dir[j]); 454 QString file = dir.filePath(dir[j]);
446 if (QFileInfo(file).baseName() == base) { 455 if (QFileInfo(file).baseName() == base) {
447 std::cerr << "Loading: " << file.toStdString() << std::endl; 456 std::cerr << "Loading: " << file.toStdString() << std::endl;
448 libraryHandle = DLOPEN(file, RTLD_NOW); 457 libraryHandle = DLOPEN(file, RTLD_NOW);
449 if (libraryHandle) m_libraryHandles[soName] = libraryHandle; 458 if (libraryHandle) {
450 return; 459 m_libraryHandles[soName] = libraryHandle;
460 return;
461 }
451 } 462 }
452 } 463 }
453 } 464 }
454 465
455 std::cerr << "LADSPAPluginFactory::loadLibrary: Failed to locate plugin library \"" << soName.toStdString() << "\"" << std::endl; 466 std::cerr << "LADSPAPluginFactory::loadLibrary: Failed to locate plugin library \"" << soName.toStdString() << "\"" << std::endl;
569 std::cerr << "[" << i->toStdString() << "] "; 580 std::cerr << "[" << i->toStdString() << "] ";
570 } 581 }
571 std::cerr << std::endl; 582 std::cerr << std::endl;
572 583
573 #ifdef HAVE_LRDF 584 #ifdef HAVE_LRDF
574 // Initialise liblrdf and read the description files 585 // read the description files
575 // 586 //
576 lrdf_init();
577
578 QString baseUri; 587 QString baseUri;
579 std::vector<QString> lrdfPaths = getLRDFPath(baseUri); 588 std::vector<QString> lrdfPaths = getLRDFPath(baseUri);
580 589
581 bool haveSomething = false; 590 bool haveSomething = false;
582 591
604 613
605 for (unsigned int j = 0; j < pluginDir.count(); ++j) { 614 for (unsigned int j = 0; j < pluginDir.count(); ++j) {
606 discoverPlugins(QString("%1/%2").arg(*i).arg(pluginDir[j])); 615 discoverPlugins(QString("%1/%2").arg(*i).arg(pluginDir[j]));
607 } 616 }
608 } 617 }
609
610 #ifdef HAVE_LRDF
611 // Cleanup after the RDF library
612 //
613 lrdf_cleanup();
614 #endif // HAVE_LRDF
615 } 618 }
616 619
617 void 620 void
618 LADSPAPluginFactory::discoverPlugins(QString soname) 621 LADSPAPluginFactory::discoverPlugins(QString soname)
619 { 622 {
645 rtd->copyright = descriptor->Copyright; 648 rtd->copyright = descriptor->Copyright;
646 rtd->category = ""; 649 rtd->category = "";
647 rtd->isSynth = false; 650 rtd->isSynth = false;
648 rtd->parameterCount = 0; 651 rtd->parameterCount = 0;
649 rtd->audioInputPortCount = 0; 652 rtd->audioInputPortCount = 0;
653 rtd->audioOutputPortCount = 0;
650 rtd->controlOutputPortCount = 0; 654 rtd->controlOutputPortCount = 0;
651 655
652 QString identifier = PluginIdentifier::createIdentifier 656 QString identifier = PluginIdentifier::createIdentifier
653 ("ladspa", soname, descriptor->Label); 657 ("ladspa", soname, descriptor->Label);
654 658
720 } 724 }
721 } 725 }
722 } else { 726 } else {
723 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { 727 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) {
724 ++rtd->audioInputPortCount; 728 ++rtd->audioInputPortCount;
729 } else if (LADSPA_IS_PORT_OUTPUT(descriptor->PortDescriptors[i])) {
730 ++rtd->audioOutputPortCount;
725 } 731 }
726 } 732 }
727 } 733 }
728 734
729 m_identifiers.push_back(identifier); 735 m_identifiers.push_back(identifier);