diff plugin/FeatureExtractionPluginFactory.cpp @ 249:d3ac9f953ebf

* Fix #1672407 confused by plugin-named files in cwd (or home?) * Fix #1491848 crash when loading new file while transform plugin runs * Fix #1502287 Background remains black after spectrogram layer deleted * Fix #1604477 Replacing the main audio file silences secondary audio file * Fix failure to initialise property box layout to last preference on startup * Fix resample/wrong-rate display in Pane, ensure that right rate is chosen if all current models have an acceptable rate even if previous main model had a different one * Fix "global zoom" broken in previous commit * Some fixes to spectrogram cache area updating (makes spectrogram appear more quickly, previously it had a tendency to refresh with empty space) * Fixes to colour 3d plot normalization
author Chris Cannam
date Thu, 08 Mar 2007 16:53:08 +0000
parents 2b40f83e7627
children db0dd744fa8d
line wrap: on
line diff
--- a/plugin/FeatureExtractionPluginFactory.cpp	Wed Mar 07 18:00:49 2007 +0000
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Thu Mar 08 16:53:08 2007 +0000
@@ -28,6 +28,8 @@
 
 #include <iostream>
 
+//#define DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 1
+
 static FeatureExtractionPluginFactory *_nativeInstance = 0;
 
 FeatureExtractionPluginFactory *
@@ -90,7 +92,9 @@
     
     for (std::vector<QString>::iterator i = path.begin(); i != path.end(); ++i) {
 
-//        std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i->toStdString() << std::endl;
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+        std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i->toStdString() << std::endl;
+#endif
 
 	QDir pluginDir(*i, PLUGIN_GLOB,
                        QDir::Name | QDir::IgnoreCase,
@@ -100,6 +104,10 @@
 
             QString soname = pluginDir.filePath(pluginDir[j]);
 
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname.toStdString() << std::endl;
+#endif
+
             void *libraryHandle = DLOPEN(soname, RTLD_LAZY);
             
             if (!libraryHandle) {
@@ -107,6 +115,10 @@
                 continue;
             }
 
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << std::endl;
+#endif
+
             VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
                 DLSYM(libraryHandle, "vampGetPluginDescriptor");
 
@@ -118,6 +130,10 @@
                 continue;
             }
 
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << std::endl;
+#endif
+
             const VampPluginDescriptor *descriptor = 0;
             int index = 0;
 
@@ -125,7 +141,9 @@
                 QString id = PluginIdentifier::createIdentifier
                     ("vamp", soname, descriptor->identifier);
                 rv.push_back(id);
-//                std::cerr << "Found id " << id.toStdString() << std::endl;
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+                std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << std::endl;
+#endif
                 ++index;
             }
             
@@ -145,6 +163,12 @@
 {
     QString file = "";
 
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+    std::cerr << "FeatureExtractionPluginFactory::findPluginFile(\""
+              << soname.toStdString() << "\", \"" << inDir.toStdString() << "\")"
+              << std::endl;
+#endif
+
     if (inDir != "") {
 
         QDir dir(inDir, PLUGIN_GLOB,
@@ -153,23 +177,48 @@
         if (!dir.exists()) return "";
 
         file = dir.filePath(QFileInfo(soname).fileName());
-        if (QFileInfo(file).exists()) {
+
+        if (QFileInfo(file).exists() && QFileInfo(file).isFile()) {
+
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+            std::cerr << "FeatureExtractionPluginFactory::findPluginFile: "
+                      << "found trivially at " << file.toStdString() << std::endl;
+#endif
+
             return file;
         }
 
 	for (unsigned int j = 0; j < dir.count(); ++j) {
             file = dir.filePath(dir[j]);
             if (QFileInfo(file).baseName() == QFileInfo(soname).baseName()) {
+
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+                std::cerr << "FeatureExtractionPluginFactory::findPluginFile: "
+                          << "found at " << file.toStdString() << std::endl;
+#endif
+
                 return file;
             }
         }
 
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+        std::cerr << "FeatureExtractionPluginFactory::findPluginFile (with dir): "
+                  << "not found" << std::endl;
+#endif
+
         return "";
 
     } else {
 
         QFileInfo fi(soname);
-        if (fi.exists()) return soname;
+
+        if (fi.isAbsolute() && fi.exists() && fi.isFile()) {
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+            std::cerr << "FeatureExtractionPluginFactory::findPluginFile: "
+                      << "found trivially at " << soname.toStdString() << std::endl;
+#endif
+            return soname;
+        }
 
         if (fi.isAbsolute() && fi.absolutePath() != "") {
             file = findPluginFile(soname, fi.absolutePath());
@@ -185,6 +234,11 @@
             }
         }
 
+#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
+        std::cerr << "FeatureExtractionPluginFactory::findPluginFile: "
+                  << "not found" << std::endl;
+#endif
+
         return "";
     }
 }
@@ -211,9 +265,13 @@
         std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find library file " << soname.toStdString() << std::endl;
         return 0;
     } else if (found != soname) {
-//        std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: WARNING: Given library name was " << soname.toStdString() << ", found at " << found.toStdString() << std::endl;
-//        std::cerr << soname.toStdString() << " -> " << found.toStdString() << std::endl;
-    }
+
+#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;
+#endif
+
+    }        
 
     soname = found;