comparison plugin/NativeVampPluginFactory.cpp @ 1247:8f076d02569a piper

Make SVDEBUG always write to a log file -- formerly this was disabled in NDEBUG builds. I think there's little use to that, it just means that we keep adding more cerr debug output because we aren't getting the log we need. And SVDEBUG logging is not usually used in tight loops, I don't think the performance overhead is too serious. Also update the About box.
author Chris Cannam
date Thu, 03 Nov 2016 14:57:00 +0000
parents 75aefcc9f07d
children d45a16c232bd
comparison
equal deleted inserted replaced
1246:75aefcc9f07d 1247:8f076d02569a
89 QString soname = candidate.libraryPath; 89 QString soname = candidate.libraryPath;
90 90
91 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); 91 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
92 92
93 if (!libraryHandle) { 93 if (!libraryHandle) {
94 cerr << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl; 94 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl;
95 continue; 95 continue;
96 } 96 }
97 97
98 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) 98 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
99 DLSYM(libraryHandle, "vampGetPluginDescriptor"); 99 DLSYM(libraryHandle, "vampGetPluginDescriptor");
100 100
101 if (!fn) { 101 if (!fn) {
102 cerr << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: No descriptor function in " << soname << endl; 102 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: No descriptor function in " << soname << endl;
103 if (DLCLOSE(libraryHandle) != 0) { 103 if (DLCLOSE(libraryHandle) != 0) {
104 cerr << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl; 104 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl;
105 } 105 }
106 continue; 106 continue;
107 } 107 }
108 108
109 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 109 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
117 bool ok = true; 117 bool ok = true;
118 118
119 while ((descriptor = fn(VAMP_API_VERSION, index))) { 119 while ((descriptor = fn(VAMP_API_VERSION, index))) {
120 120
121 if (known.find(descriptor->identifier) != known.end()) { 121 if (known.find(descriptor->identifier) != known.end()) {
122 cerr << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Plugin library " 122 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Plugin library "
123 << soname 123 << soname
124 << " returns the same plugin identifier \"" 124 << " returns the same plugin identifier \""
125 << descriptor->identifier << "\" at indices " 125 << descriptor->identifier << "\" at indices "
126 << known[descriptor->identifier] << " and " 126 << known[descriptor->identifier] << " and "
127 << index << endl; 127 << index << endl;
128 cerr << "NativeVampPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; 128 SVDEBUG << "NativeVampPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl;
129 ok = false; 129 ok = false;
130 break; 130 break;
131 } else { 131 } else {
132 known[descriptor->identifier] = index; 132 known[descriptor->identifier] = index;
133 } 133 }
150 ++index; 150 ++index;
151 } 151 }
152 } 152 }
153 153
154 if (DLCLOSE(libraryHandle) != 0) { 154 if (DLCLOSE(libraryHandle) != 0) {
155 cerr << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl; 155 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl;
156 } 156 }
157 } 157 }
158 158
159 generateTaxonomy(); 159 generateTaxonomy();
160 160
271 } 271 }
272 272
273 QString found = findPluginFile(soname); 273 QString found = findPluginFile(soname);
274 274
275 if (found == "") { 275 if (found == "") {
276 cerr << "NativeVampPluginFactory::instantiatePlugin: Failed to find library file " << soname << endl; 276 SVDEBUG << "NativeVampPluginFactory::instantiatePlugin: Failed to find library file " << soname << endl;
277 return 0; 277 return 0;
278 } else if (found != soname) { 278 } else if (found != soname) {
279 279
280 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 280 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
281 cerr << "NativeVampPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl; 281 cerr << "NativeVampPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl;
287 soname = found; 287 soname = found;
288 288
289 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); 289 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
290 290
291 if (!libraryHandle) { 291 if (!libraryHandle) {
292 cerr << "NativeVampPluginFactory::instantiatePlugin: Failed to load library " << soname << ": " << DLERROR() << endl; 292 SVDEBUG << "NativeVampPluginFactory::instantiatePlugin: Failed to load library " << soname << ": " << DLERROR() << endl;
293 return 0; 293 return 0;
294 } 294 }
295 295
296 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) 296 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
297 DLSYM(libraryHandle, "vampGetPluginDescriptor"); 297 DLSYM(libraryHandle, "vampGetPluginDescriptor");
298 298
299 if (!fn) { 299 if (!fn) {
300 cerr << "NativeVampPluginFactory::instantiatePlugin: No descriptor function in " << soname << endl; 300 SVDEBUG << "NativeVampPluginFactory::instantiatePlugin: No descriptor function in " << soname << endl;
301 goto done; 301 goto done;
302 } 302 }
303 303
304 while ((descriptor = fn(VAMP_API_VERSION, index))) { 304 while ((descriptor = fn(VAMP_API_VERSION, index))) {
305 if (label == descriptor->identifier) break; 305 if (label == descriptor->identifier) break;
306 ++index; 306 ++index;
307 } 307 }
308 308
309 if (!descriptor) { 309 if (!descriptor) {
310 cerr << "NativeVampPluginFactory::instantiatePlugin: Failed to find plugin \"" << label << "\" in library " << soname << endl; 310 SVDEBUG << "NativeVampPluginFactory::instantiatePlugin: Failed to find plugin \"" << label << "\" in library " << soname << endl;
311 goto done; 311 goto done;
312 } 312 }
313 313
314 plugin = new Vamp::PluginHostAdapter(descriptor, float(inputSampleRate)); 314 plugin = new Vamp::PluginHostAdapter(descriptor, float(inputSampleRate));
315 315
323 //!!! need to dlclose() when plugins from a given library are unloaded 323 //!!! need to dlclose() when plugins from a given library are unloaded
324 324
325 done: 325 done:
326 if (!rv) { 326 if (!rv) {
327 if (DLCLOSE(libraryHandle) != 0) { 327 if (DLCLOSE(libraryHandle) != 0) {
328 cerr << "WARNING: NativeVampPluginFactory::instantiatePlugin: Failed to unload library " << soname << endl; 328 SVDEBUG << "WARNING: NativeVampPluginFactory::instantiatePlugin: Failed to unload library " << soname << endl;
329 } 329 }
330 } 330 }
331 331
332 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 332 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
333 cerr << "NativeVampPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << endl; 333 cerr << "NativeVampPluginFactory::instantiatePlugin: Instantiated plugin " << label << " from library " << soname << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << endl;