comparison plugin/FeatureExtractionPluginFactory.cpp @ 251:db0dd744fa8d

* Fix hang and memory leak on startup when encountering a pre-Vamp-1.0 plugin
author Chris Cannam
date Tue, 20 Mar 2007 11:49:11 +0000
parents d3ac9f953ebf
children dc46851837d6
comparison
equal deleted inserted replaced
250:40db5491bcf8 251:db0dd744fa8d
135 #endif 135 #endif
136 136
137 const VampPluginDescriptor *descriptor = 0; 137 const VampPluginDescriptor *descriptor = 0;
138 int index = 0; 138 int index = 0;
139 139
140 std::map<std::string, int> known;
141 bool ok = true;
142
140 while ((descriptor = fn(VAMP_API_VERSION, index))) { 143 while ((descriptor = fn(VAMP_API_VERSION, index))) {
141 QString id = PluginIdentifier::createIdentifier 144
142 ("vamp", soname, descriptor->identifier); 145 if (known.find(descriptor->identifier) != known.end()) {
143 rv.push_back(id); 146 std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Plugin library "
144 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 147 << soname.toStdString()
145 std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << std::endl; 148 << " returns the same plugin identifier \""
146 #endif 149 << descriptor->identifier << "\" at indices "
150 << known[descriptor->identifier] << " and "
151 << index << std::endl;
152 std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << std::endl;
153 ok = false;
154 break;
155 } else {
156 known[descriptor->identifier] = index;
157 }
158
147 ++index; 159 ++index;
160 }
161
162 if (ok) {
163
164 index = 0;
165
166 while ((descriptor = fn(VAMP_API_VERSION, index))) {
167
168 QString id = PluginIdentifier::createIdentifier
169 ("vamp", soname, descriptor->identifier);
170 rv.push_back(id);
171 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
172 std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << " at index " << index << std::endl;
173 #endif
174 ++index;
175 }
148 } 176 }
149 177
150 if (DLCLOSE(libraryHandle) != 0) { 178 if (DLCLOSE(libraryHandle) != 0) {
151 std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl; 179 std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl;
152 } 180 }