comparison plugin/NativeVampPluginFactory.cpp @ 1464:91bb68146dfc

Add getPluginLibraryPath throughout, in order to provide diagnostic about which plugins were loaded from where
author Chris Cannam
date Fri, 11 May 2018 14:11:04 +0100
parents 48e9f538e6e9
children 232d6ddf257d
comparison
equal deleted inserted replaced
1463:2b2b58ae8b59 1464:91bb68146dfc
93 QDir dir(dirname.c_str(), PLUGIN_GLOB, 93 QDir dir(dirname.c_str(), PLUGIN_GLOB,
94 QDir::Name | QDir::IgnoreCase, 94 QDir::Name | QDir::IgnoreCase,
95 QDir::Files | QDir::Readable); 95 QDir::Files | QDir::Readable);
96 96
97 for (unsigned int i = 0; i < dir.count(); ++i) { 97 for (unsigned int i = 0; i < dir.count(); ++i) {
98 QString soname = dir.filePath(dir[i]); 98 QString libpath = dir.filePath(dir[i]);
99 candidates.push_back({ soname, "" }); 99 candidates.push_back({ libpath, "" });
100 } 100 }
101 } 101 }
102 102
103 return candidates; 103 return candidates;
104 #endif 104 #endif
119 119
120 SVDEBUG << "INFO: Have " << candidates.size() << " candidate Vamp plugin libraries" << endl; 120 SVDEBUG << "INFO: Have " << candidates.size() << " candidate Vamp plugin libraries" << endl;
121 121
122 for (auto candidate : candidates) { 122 for (auto candidate : candidates) {
123 123
124 QString soname = candidate.libraryPath; 124 QString libpath = candidate.libraryPath;
125 125
126 SVDEBUG << "INFO: Considering candidate Vamp plugin library " << soname << endl; 126 SVDEBUG << "INFO: Considering candidate Vamp plugin library " << libpath << endl;
127 127
128 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); 128 void *libraryHandle = DLOPEN(libpath, RTLD_LAZY | RTLD_LOCAL);
129 129
130 if (!libraryHandle) { 130 if (!libraryHandle) {
131 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl; 131 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to load library " << libpath << ": " << DLERROR() << endl;
132 continue; 132 continue;
133 } 133 }
134 134
135 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) 135 VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
136 DLSYM(libraryHandle, "vampGetPluginDescriptor"); 136 DLSYM(libraryHandle, "vampGetPluginDescriptor");
137 137
138 if (!fn) { 138 if (!fn) {
139 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: No descriptor function in " << soname << endl; 139 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: No descriptor function in " << libpath << endl;
140 if (DLCLOSE(libraryHandle) != 0) { 140 if (DLCLOSE(libraryHandle) != 0) {
141 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl; 141 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << libpath << endl;
142 } 142 }
143 continue; 143 continue;
144 } 144 }
145 145
146 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 146 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
155 155
156 while ((descriptor = fn(VAMP_API_VERSION, index))) { 156 while ((descriptor = fn(VAMP_API_VERSION, index))) {
157 157
158 if (known.find(descriptor->identifier) != known.end()) { 158 if (known.find(descriptor->identifier) != known.end()) {
159 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Plugin library " 159 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Plugin library "
160 << soname 160 << libpath
161 << " returns the same plugin identifier \"" 161 << " returns the same plugin identifier \""
162 << descriptor->identifier << "\" at indices " 162 << descriptor->identifier << "\" at indices "
163 << known[descriptor->identifier] << " and " 163 << known[descriptor->identifier] << " and "
164 << index << endl; 164 << index << endl;
165 SVDEBUG << "NativeVampPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; 165 SVDEBUG << "NativeVampPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl;
166 ok = false; 166 ok = false;
167 break; 167 break;
168 } else { 168 } else {
169 known[descriptor->identifier] = index; 169 known[descriptor->identifier] = index;
170 } 170 }
177 index = 0; 177 index = 0;
178 178
179 while ((descriptor = fn(VAMP_API_VERSION, index))) { 179 while ((descriptor = fn(VAMP_API_VERSION, index))) {
180 180
181 QString id = PluginIdentifier::createIdentifier 181 QString id = PluginIdentifier::createIdentifier
182 ("vamp", soname, descriptor->identifier); 182 ("vamp", libpath, descriptor->identifier);
183 m_identifiers.push_back(id); 183 m_identifiers.push_back(id);
184 m_libraries[id] = libpath;
184 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 185 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
185 cerr << "NativeVampPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl; 186 cerr << "NativeVampPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl;
186 #endif 187 #endif
187 ++index; 188 ++index;
188 } 189 }
189 } 190 }
190 191
191 if (DLCLOSE(libraryHandle) != 0) { 192 if (DLCLOSE(libraryHandle) != 0) {
192 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << soname << endl; 193 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to unload library " << libpath << endl;
193 } 194 }
194 } 195 }
195 196
196 generateTaxonomy(); 197 generateTaxonomy();
197 198
388 389
389 QString 390 QString
390 NativeVampPluginFactory::getPluginCategory(QString identifier) 391 NativeVampPluginFactory::getPluginCategory(QString identifier)
391 { 392 {
392 return m_taxonomy[identifier]; 393 return m_taxonomy[identifier];
394 }
395
396 QString
397 NativeVampPluginFactory::getPluginLibraryPath(QString identifier)
398 {
399 return m_libraries[identifier];
393 } 400 }
394 401
395 void 402 void
396 NativeVampPluginFactory::generateTaxonomy() 403 NativeVampPluginFactory::generateTaxonomy()
397 { 404 {