# HG changeset patch # User Chris Cannam # Date 1526044264 -3600 # Node ID 91bb68146dfced88f3988ea8a959a4f35116862e # Parent 2b2b58ae8b592e0581cea38d295bfcf5a86f274d Add getPluginLibraryPath throughout, in order to provide diagnostic about which plugins were loaded from where diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/DSSIPluginFactory.cpp --- a/plugin/DSSIPluginFactory.cpp Thu May 10 10:12:13 2018 +0100 +++ b/plugin/DSSIPluginFactory.cpp Fri May 11 14:11:04 2018 +0100 @@ -418,6 +418,8 @@ m_identifiers.push_back(identifier); + m_libraries[identifier] = soname; + m_rtDescriptors[identifier] = rtd; ++index; diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/FeatureExtractionPluginFactory.h --- a/plugin/FeatureExtractionPluginFactory.h Thu May 10 10:12:13 2018 +0100 +++ b/plugin/FeatureExtractionPluginFactory.h Fri May 11 14:11:04 2018 +0100 @@ -34,17 +34,13 @@ /** * Return all installed plugin identifiers. */ - virtual std::vector getPluginIdentifiers(QString &errorMessage) { - return instance()->getPluginIdentifiers(errorMessage); - } - + virtual std::vector getPluginIdentifiers(QString &errorMsg) = 0; + /** * Return static data for the given plugin. */ - virtual piper_vamp::PluginStaticData getPluginStaticData(QString identifier) { - return instance()->getPluginStaticData(identifier); - } - + virtual piper_vamp::PluginStaticData getPluginStaticData(QString ident) = 0; + /** * Instantiate (load) and return pointer to the plugin with the * given identifier, at the given sample rate. We don't set @@ -52,16 +48,20 @@ * via initialize() on the plugin itself after loading. */ virtual Vamp::Plugin *instantiatePlugin(QString identifier, - sv_samplerate_t inputSampleRate) { - return instance()->instantiatePlugin(identifier, inputSampleRate); - } - + sv_samplerate_t inputSampleRate) = 0; + /** * Get category metadata about a plugin (without instantiating it). */ - virtual QString getPluginCategory(QString identifier) { - return instance()->getPluginCategory(identifier); - } + virtual QString getPluginCategory(QString identifier) = 0; + + /** + * Get the full file path (including both directory and filename) + * of the library file that provides a given plugin + * identifier. Note getPluginIdentifiers() must have been called + * before this has access to the necessary information. + */ + virtual QString getPluginLibraryPath(QString identifier) = 0; }; #endif diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/LADSPAPluginFactory.cpp --- a/plugin/LADSPAPluginFactory.cpp Thu May 10 10:12:13 2018 +0100 +++ b/plugin/LADSPAPluginFactory.cpp Fri May 11 14:11:04 2018 +0100 @@ -69,6 +69,12 @@ return m_identifiers; } +QString +LADSPAPluginFactory::getPluginLibraryPath(QString identifier) +{ + return m_libraries[identifier]; +} + void LADSPAPluginFactory::enumeratePlugins(std::vector &list) { @@ -794,6 +800,8 @@ m_identifiers.push_back(identifier); + m_libraries[identifier] = soname; + m_rtDescriptors[identifier] = rtd; ++index; diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/LADSPAPluginFactory.h --- a/plugin/LADSPAPluginFactory.h Thu May 10 10:12:13 2018 +0100 +++ b/plugin/LADSPAPluginFactory.h Fri May 11 14:11:04 2018 +0100 @@ -55,6 +55,8 @@ virtual QString getPluginCategory(QString identifier); + virtual QString getPluginLibraryPath(QString identifier); + float getPortMinimum(const LADSPA_Descriptor *, int port); float getPortMaximum(const LADSPA_Descriptor *, int port); float getPortDefault(const LADSPA_Descriptor *, int port); @@ -86,6 +88,7 @@ void unloadUnusedLibraries(); std::vector m_identifiers; + std::map m_libraries; // identifier -> full file path std::map m_rtDescriptors; std::map m_taxonomy; diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/NativeVampPluginFactory.cpp --- a/plugin/NativeVampPluginFactory.cpp Thu May 10 10:12:13 2018 +0100 +++ b/plugin/NativeVampPluginFactory.cpp Fri May 11 14:11:04 2018 +0100 @@ -95,8 +95,8 @@ QDir::Files | QDir::Readable); for (unsigned int i = 0; i < dir.count(); ++i) { - QString soname = dir.filePath(dir[i]); - candidates.push_back({ soname, "" }); + QString libpath = dir.filePath(dir[i]); + candidates.push_back({ libpath, "" }); } } @@ -121,14 +121,14 @@ for (auto candidate : candidates) { - QString soname = candidate.libraryPath; + QString libpath = candidate.libraryPath; - SVDEBUG << "INFO: Considering candidate Vamp plugin library " << soname << endl; + SVDEBUG << "INFO: Considering candidate Vamp plugin library " << libpath << endl; - void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); + void *libraryHandle = DLOPEN(libpath, RTLD_LAZY | RTLD_LOCAL); if (!libraryHandle) { - SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl; + SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to load library " << libpath << ": " << DLERROR() << endl; continue; } @@ -136,9 +136,9 @@ DLSYM(libraryHandle, "vampGetPluginDescriptor"); if (!fn) { - SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: No descriptor function in " << soname << endl; + SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: No descriptor function in " << libpath << endl; if (DLCLOSE(libraryHandle) != 0) { - SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl; + SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << libpath << endl; } continue; } @@ -157,12 +157,12 @@ if (known.find(descriptor->identifier) != known.end()) { SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Plugin library " - << soname - << " returns the same plugin identifier \"" - << descriptor->identifier << "\" at indices " - << known[descriptor->identifier] << " and " - << index << endl; - SVDEBUG << "NativeVampPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; + << libpath + << " returns the same plugin identifier \"" + << descriptor->identifier << "\" at indices " + << known[descriptor->identifier] << " and " + << index << endl; + SVDEBUG << "NativeVampPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; ok = false; break; } else { @@ -179,8 +179,9 @@ while ((descriptor = fn(VAMP_API_VERSION, index))) { QString id = PluginIdentifier::createIdentifier - ("vamp", soname, descriptor->identifier); + ("vamp", libpath, descriptor->identifier); m_identifiers.push_back(id); + m_libraries[id] = libpath; #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE cerr << "NativeVampPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl; #endif @@ -189,7 +190,7 @@ } if (DLCLOSE(libraryHandle) != 0) { - SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl; + SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << libpath << endl; } } @@ -392,6 +393,12 @@ return m_taxonomy[identifier]; } +QString +NativeVampPluginFactory::getPluginLibraryPath(QString identifier) +{ + return m_libraries[identifier]; +} + void NativeVampPluginFactory::generateTaxonomy() { diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/NativeVampPluginFactory.h --- a/plugin/NativeVampPluginFactory.h Thu May 10 10:12:13 2018 +0100 +++ b/plugin/NativeVampPluginFactory.h Fri May 11 14:11:04 2018 +0100 @@ -44,17 +44,17 @@ sv_samplerate_t inputSampleRate) override; - /** - * Get category metadata about a plugin (without instantiating it). - */ virtual QString getPluginCategory(QString identifier) override; + virtual QString getPluginLibraryPath(QString identifier) override; + protected: QMutex m_mutex; std::vector m_pluginPath; std::vector m_identifiers; std::map m_taxonomy; // identifier -> category string std::map m_pluginData; // identifier -> data (created opportunistically) + std::map m_libraries; // identifier -> full file path friend class PluginDeletionNotifyAdapter; void pluginDeleted(Vamp::Plugin *); diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/PiperVampPluginFactory.cpp --- a/plugin/PiperVampPluginFactory.cpp Thu May 10 10:12:13 2018 +0100 +++ b/plugin/PiperVampPluginFactory.cpp Fri May 11 14:11:04 2018 +0100 @@ -160,6 +160,27 @@ } } +QString +PiperVampPluginFactory::getPluginLibraryPath(QString identifier) +{ + // What we want to return here is the file path of the library in + // which the plugin was actually found -- we want to be paranoid + // about that and not just query + // Vamp::HostExt::PluginLoader::getLibraryPathForPlugin to return + // what the SDK thinks the likely location would be (in case our + // search order turns out to have been different) + + QStringList bits = identifier.split(':'); + if (bits.size() > 1) { + QString soname = bits[bits.size() - 2]; + auto i = m_libraries.find(soname); + if (i != m_libraries.end()) { + return i->second; + } + } + return QString(); +} + void PiperVampPluginFactory::populate(QString &errorMessage) { @@ -196,6 +217,7 @@ string soname = QFileInfo(c.libraryPath).baseName().toStdString(); SVDEBUG << "INFO: For tag \"" << tag << "\" giving library " << soname << endl; from.push_back(soname); + m_libraries[QString::fromStdString(soname)] = c.libraryPath; } } diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/PiperVampPluginFactory.h --- a/plugin/PiperVampPluginFactory.h Thu May 10 10:12:13 2018 +0100 +++ b/plugin/PiperVampPluginFactory.h Fri May 11 14:11:04 2018 +0100 @@ -49,10 +49,13 @@ virtual QString getPluginCategory(QString identifier) override; + virtual QString getPluginLibraryPath(QString identifier) override; + protected: QMutex m_mutex; QList m_servers; // executable file paths std::map m_origins; // plugin identifier -> server path + std::map m_libraries; // soname -> full file path std::map m_pluginData; // identifier -> data std::map m_taxonomy; // identifier -> category string diff -r 2b2b58ae8b59 -r 91bb68146dfc plugin/RealTimePluginFactory.h --- a/plugin/RealTimePluginFactory.h Thu May 10 10:12:13 2018 +0100 +++ b/plugin/RealTimePluginFactory.h Fri May 11 14:11:04 2018 +0100 @@ -97,6 +97,14 @@ */ virtual QString getPluginCategory(QString identifier) = 0; + /** + * Get the full file path (including both directory and filename) + * of the library file that provides a given plugin + * identifier. Note getPluginIdentifiers() must have been called + * before this has access to the necessary information. + */ + virtual QString getPluginLibraryPath(QString identifier) = 0; + protected: RealTimePluginFactory() { }