comparison plugin/LADSPAPluginFactory.cpp @ 260:d4a33cdca86f

* remove more debug output
author Chris Cannam
date Mon, 30 Apr 2007 14:31:39 +0000
parents dc46851837d6
children ca3b91119482 94fc0591ea43
comparison
equal deleted inserted replaced
259:dc46851837d6 260:d4a33cdca86f
30 #include "LADSPAPluginInstance.h" 30 #include "LADSPAPluginInstance.h"
31 #include "PluginIdentifier.h" 31 #include "PluginIdentifier.h"
32 32
33 #include "system/System.h" 33 #include "system/System.h"
34 #include "base/Preferences.h" 34 #include "base/Preferences.h"
35
36 //#define DEBUG_LADSPA_PLUGIN_FACTORY 1
35 37
36 #ifdef HAVE_LRDF 38 #ifdef HAVE_LRDF
37 #include "lrdf.h" 39 #include "lrdf.h"
38 #endif // HAVE_LRDF 40 #endif // HAVE_LRDF
39 41
323 (this, instrument, identifier, position, sampleRate, blockSize, channels, 325 (this, instrument, identifier, position, sampleRate, blockSize, channels,
324 descriptor); 326 descriptor);
325 327
326 m_instances.insert(instance); 328 m_instances.insert(instance);
327 329
330 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
328 std::cerr << "LADSPAPluginFactory::instantiatePlugin(" 331 std::cerr << "LADSPAPluginFactory::instantiatePlugin("
329 << identifier.toStdString() << ": now have " << m_instances.size() << " instances" << std::endl; 332 << identifier.toStdString() << ": now have " << m_instances.size() << " instances" << std::endl;
333 #endif
330 334
331 return instance; 335 return instance;
332 } 336 }
333 337
334 return 0; 338 return 0;
354 for (std::set<RealTimePluginInstance *>::iterator ii = m_instances.begin(); 358 for (std::set<RealTimePluginInstance *>::iterator ii = m_instances.begin();
355 ii != m_instances.end(); ++ii) { 359 ii != m_instances.end(); ++ii) {
356 QString itype, isoname, ilabel; 360 QString itype, isoname, ilabel;
357 PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel); 361 PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel);
358 if (isoname == soname) { 362 if (isoname == soname) {
363 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
359 std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname.toStdString() << " is still in use for plugin " << ilabel.toStdString() << std::endl; 364 std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname.toStdString() << " is still in use for plugin " << ilabel.toStdString() << std::endl;
365 #endif
360 stillInUse = true; 366 stillInUse = true;
361 break; 367 break;
362 } 368 }
363 } 369 }
364 370
365 if (!stillInUse) { 371 if (!stillInUse) {
366 if (soname != PluginIdentifier::BUILTIN_PLUGIN_SONAME) { 372 if (soname != PluginIdentifier::BUILTIN_PLUGIN_SONAME) {
373 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
367 std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname.toStdString() << " no longer in use, unloading" << std::endl; 374 std::cerr << "LADSPAPluginFactory::releasePlugin: dll " << soname.toStdString() << " no longer in use, unloading" << std::endl;
375 #endif
368 unloadLibrary(soname); 376 unloadLibrary(soname);
369 } 377 }
370 } 378 }
371 379
380 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
372 std::cerr << "LADSPAPluginFactory::releasePlugin(" 381 std::cerr << "LADSPAPluginFactory::releasePlugin("
373 << identifier.toStdString() << ": now have " << m_instances.size() << " instances" << std::endl; 382 << identifier.toStdString() << ": now have " << m_instances.size() << " instances" << std::endl;
383 #endif
374 } 384 }
375 385
376 const LADSPA_Descriptor * 386 const LADSPA_Descriptor *
377 LADSPAPluginFactory::getLADSPADescriptor(QString identifier) 387 LADSPAPluginFactory::getLADSPADescriptor(QString identifier)
378 { 388 {
432 QString base = QFileInfo(soName).baseName(); 442 QString base = QFileInfo(soName).baseName();
433 443
434 for (std::vector<QString>::iterator i = pathList.begin(); 444 for (std::vector<QString>::iterator i = pathList.begin();
435 i != pathList.end(); ++i) { 445 i != pathList.end(); ++i) {
436 446
447 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
437 std::cerr << "Looking at: " << (*i).toStdString() << std::endl; 448 std::cerr << "Looking at: " << (*i).toStdString() << std::endl;
449 #endif
438 450
439 QDir dir(*i, PLUGIN_GLOB, 451 QDir dir(*i, PLUGIN_GLOB,
440 QDir::Name | QDir::IgnoreCase, 452 QDir::Name | QDir::IgnoreCase,
441 QDir::Files | QDir::Readable); 453 QDir::Files | QDir::Readable);
442 454
443 if (QFileInfo(dir.filePath(fileName)).exists()) { 455 if (QFileInfo(dir.filePath(fileName)).exists()) {
456 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
444 std::cerr << "Loading: " << fileName.toStdString() << std::endl; 457 std::cerr << "Loading: " << fileName.toStdString() << std::endl;
458 #endif
445 libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW); 459 libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW);
446 if (libraryHandle) { 460 if (libraryHandle) {
447 m_libraryHandles[soName] = libraryHandle; 461 m_libraryHandles[soName] = libraryHandle;
448 return; 462 return;
449 } 463 }
450 } 464 }
451 465
452 for (unsigned int j = 0; j < dir.count(); ++j) { 466 for (unsigned int j = 0; j < dir.count(); ++j) {
453 QString file = dir.filePath(dir[j]); 467 QString file = dir.filePath(dir[j]);
454 if (QFileInfo(file).baseName() == base) { 468 if (QFileInfo(file).baseName() == base) {
469 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
455 std::cerr << "Loading: " << file.toStdString() << std::endl; 470 std::cerr << "Loading: " << file.toStdString() << std::endl;
471 #endif
456 libraryHandle = DLOPEN(file, RTLD_NOW); 472 libraryHandle = DLOPEN(file, RTLD_NOW);
457 if (libraryHandle) { 473 if (libraryHandle) {
458 m_libraryHandles[soName] = libraryHandle; 474 m_libraryHandles[soName] = libraryHandle;
459 return; 475 return;
460 } 476 }