comparison plugin/LADSPAPluginFactory.cpp @ 1527:710e6250a401 zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:14 +0100
parents 850bc66d6a70
children 70e172e6cc59
comparison
equal deleted inserted replaced
1324:d4a28d1479a8 1527:710e6250a401
38 38
39 #ifdef HAVE_LRDF 39 #ifdef HAVE_LRDF
40 #include "lrdf.h" 40 #include "lrdf.h"
41 #endif // HAVE_LRDF 41 #endif // HAVE_LRDF
42 42
43 using std::string;
43 44
44 LADSPAPluginFactory::LADSPAPluginFactory() 45 LADSPAPluginFactory::LADSPAPluginFactory()
45 { 46 {
46 #ifdef HAVE_LRDF 47 #ifdef HAVE_LRDF
47 lrdf_init(); 48 lrdf_init();
49 } 50 }
50 51
51 LADSPAPluginFactory::~LADSPAPluginFactory() 52 LADSPAPluginFactory::~LADSPAPluginFactory()
52 { 53 {
53 for (std::set<RealTimePluginInstance *>::iterator i = m_instances.begin(); 54 for (std::set<RealTimePluginInstance *>::iterator i = m_instances.begin();
54 i != m_instances.end(); ++i) { 55 i != m_instances.end(); ++i) {
55 (*i)->setFactory(0); 56 (*i)->setFactory(0);
56 delete *i; 57 delete *i;
57 } 58 }
58 m_instances.clear(); 59 m_instances.clear();
59 unloadUnusedLibraries(); 60 unloadUnusedLibraries();
60 61
61 #ifdef HAVE_LRDF 62 #ifdef HAVE_LRDF
67 LADSPAPluginFactory::getPluginIdentifiers() const 68 LADSPAPluginFactory::getPluginIdentifiers() const
68 { 69 {
69 return m_identifiers; 70 return m_identifiers;
70 } 71 }
71 72
73 QString
74 LADSPAPluginFactory::getPluginLibraryPath(QString identifier)
75 {
76 return m_libraries[identifier];
77 }
78
72 void 79 void
73 LADSPAPluginFactory::enumeratePlugins(std::vector<QString> &list) 80 LADSPAPluginFactory::enumeratePlugins(std::vector<QString> &list)
74 { 81 {
75 Profiler profiler("LADSPAPluginFactory::enumeratePlugins"); 82 Profiler profiler("LADSPAPluginFactory::enumeratePlugins");
76 83
77 for (std::vector<QString>::iterator i = m_identifiers.begin(); 84 for (std::vector<QString>::iterator i = m_identifiers.begin();
78 i != m_identifiers.end(); ++i) { 85 i != m_identifiers.end(); ++i) {
79 86
80 const LADSPA_Descriptor *descriptor = getLADSPADescriptor(*i); 87 const LADSPA_Descriptor *descriptor = getLADSPADescriptor(*i);
81 88
82 if (!descriptor) { 89 if (!descriptor) {
83 cerr << "WARNING: LADSPAPluginFactory::enumeratePlugins: couldn't get descriptor for identifier " << *i << endl; 90 cerr << "WARNING: LADSPAPluginFactory::enumeratePlugins: couldn't get descriptor for identifier " << *i << endl;
84 continue; 91 continue;
85 } 92 }
86 93
87 list.push_back(*i); 94 list.push_back(*i);
88 list.push_back(descriptor->Name); 95 list.push_back(descriptor->Name);
89 list.push_back(QString("%1").arg(descriptor->UniqueID)); 96 list.push_back(QString("%1").arg(descriptor->UniqueID));
90 list.push_back(descriptor->Label); 97 list.push_back(descriptor->Label);
91 list.push_back(descriptor->Maker); 98 list.push_back(descriptor->Maker);
92 list.push_back(descriptor->Copyright); 99 list.push_back(descriptor->Copyright);
93 list.push_back("false"); // is synth 100 list.push_back("false"); // is synth
94 list.push_back("false"); // is grouped 101 list.push_back("false"); // is grouped
95 102
96 if (m_taxonomy.find(*i) != m_taxonomy.end() && m_taxonomy[*i] != "") { 103 if (m_taxonomy.find(*i) != m_taxonomy.end() && m_taxonomy[*i] != "") {
97 // cerr << "LADSPAPluginFactory: cat for " << *i << " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << endl; 104 // cerr << "LADSPAPluginFactory: cat for " << *i << " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << endl;
98 list.push_back(m_taxonomy[*i]); 105 list.push_back(m_taxonomy[*i]);
99 } else { 106 } else {
100 list.push_back(""); 107 list.push_back("");
101 // cerr << "LADSPAPluginFactory: cat for " << *i << " not found (despite having " << m_fallbackCategories.size() << " fallbacks)" << endl; 108 // cerr << "LADSPAPluginFactory: cat for " << *i << " not found (despite having " << m_fallbackCategories.size() << " fallbacks)" << endl;
102 109
103 } 110 }
104 111
105 list.push_back(QString("%1").arg(descriptor->PortCount)); 112 list.push_back(QString("%1").arg(descriptor->PortCount));
106 113
107 for (int p = 0; p < (int)descriptor->PortCount; ++p) { 114 for (int p = 0; p < (int)descriptor->PortCount; ++p) {
108 115
109 int type = 0; 116 int type = 0;
110 if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) { 117 if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) {
111 type |= PortType::Control; 118 type |= PortType::Control;
112 } else { 119 } else {
113 type |= PortType::Audio; 120 type |= PortType::Audio;
114 } 121 }
115 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[p])) { 122 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[p])) {
116 type |= PortType::Input; 123 type |= PortType::Input;
117 } else { 124 } else {
118 type |= PortType::Output; 125 type |= PortType::Output;
119 } 126 }
120 127
121 list.push_back(QString("%1").arg(p)); 128 list.push_back(QString("%1").arg(p));
122 list.push_back(descriptor->PortNames[p]); 129 list.push_back(descriptor->PortNames[p]);
123 list.push_back(QString("%1").arg(type)); 130 list.push_back(QString("%1").arg(type));
124 list.push_back(QString("%1").arg(getPortDisplayHint(descriptor, p))); 131 list.push_back(QString("%1").arg(getPortDisplayHint(descriptor, p)));
125 list.push_back(QString("%1").arg(getPortMinimum(descriptor, p))); 132 list.push_back(QString("%1").arg(getPortMinimum(descriptor, p)));
126 list.push_back(QString("%1").arg(getPortMaximum(descriptor, p))); 133 list.push_back(QString("%1").arg(getPortMaximum(descriptor, p)));
127 list.push_back(QString("%1").arg(getPortDefault(descriptor, p))); 134 list.push_back(QString("%1").arg(getPortDefault(descriptor, p)));
128 } 135 }
129 } 136 }
130 137
131 unloadUnusedLibraries(); 138 unloadUnusedLibraries();
132 } 139 }
133 140
134 const RealTimePluginDescriptor * 141 const RealTimePluginDescriptor *
135 LADSPAPluginFactory::getPluginDescriptor(QString identifier) const 142 LADSPAPluginFactory::getPluginDescriptor(QString identifier) const
136 { 143 {
137 std::map<QString, RealTimePluginDescriptor *>::const_iterator i = 144 std::map<QString, RealTimePluginDescriptor *>::const_iterator i =
138 m_rtDescriptors.find(identifier); 145 m_rtDescriptors.find(identifier);
146 153
147 float 154 float
148 LADSPAPluginFactory::getPortMinimum(const LADSPA_Descriptor *descriptor, int port) 155 LADSPAPluginFactory::getPortMinimum(const LADSPA_Descriptor *descriptor, int port)
149 { 156 {
150 LADSPA_PortRangeHintDescriptor d = 157 LADSPA_PortRangeHintDescriptor d =
151 descriptor->PortRangeHints[port].HintDescriptor; 158 descriptor->PortRangeHints[port].HintDescriptor;
152 159
153 float minimum = 0.f; 160 float minimum = 0.f;
154 161
155 if (LADSPA_IS_HINT_BOUNDED_BELOW(d)) { 162 if (LADSPA_IS_HINT_BOUNDED_BELOW(d)) {
156 float lb = descriptor->PortRangeHints[port].LowerBound; 163 float lb = descriptor->PortRangeHints[port].LowerBound;
157 minimum = lb; 164 minimum = lb;
158 } else if (LADSPA_IS_HINT_BOUNDED_ABOVE(d)) { 165 } else if (LADSPA_IS_HINT_BOUNDED_ABOVE(d)) {
159 float ub = descriptor->PortRangeHints[port].UpperBound; 166 float ub = descriptor->PortRangeHints[port].UpperBound;
160 minimum = std::min(0.f, ub - 1.f); 167 minimum = std::min(0.f, ub - 1.f);
161 } 168 }
162 169
163 if (LADSPA_IS_HINT_SAMPLE_RATE(d)) { 170 if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
164 minimum = float(minimum * m_sampleRate); 171 minimum = float(minimum * m_sampleRate);
165 } 172 }
166 173
167 if (LADSPA_IS_HINT_LOGARITHMIC(d)) { 174 if (LADSPA_IS_HINT_LOGARITHMIC(d)) {
168 if (minimum == 0.f) minimum = 1.f; 175 if (minimum == 0.f) minimum = 1.f;
169 } 176 }
173 180
174 float 181 float
175 LADSPAPluginFactory::getPortMaximum(const LADSPA_Descriptor *descriptor, int port) 182 LADSPAPluginFactory::getPortMaximum(const LADSPA_Descriptor *descriptor, int port)
176 { 183 {
177 LADSPA_PortRangeHintDescriptor d = 184 LADSPA_PortRangeHintDescriptor d =
178 descriptor->PortRangeHints[port].HintDescriptor; 185 descriptor->PortRangeHints[port].HintDescriptor;
179 186
180 float maximum = 1.f; 187 float maximum = 1.f;
181 188
182 if (LADSPA_IS_HINT_BOUNDED_ABOVE(d)) { 189 if (LADSPA_IS_HINT_BOUNDED_ABOVE(d)) {
183 float ub = descriptor->PortRangeHints[port].UpperBound; 190 float ub = descriptor->PortRangeHints[port].UpperBound;
184 maximum = ub; 191 maximum = ub;
185 } else { 192 } else {
186 float lb = descriptor->PortRangeHints[port].LowerBound; 193 float lb = descriptor->PortRangeHints[port].LowerBound;
187 maximum = lb + 1.f; 194 maximum = lb + 1.f;
188 } 195 }
189 196
190 if (LADSPA_IS_HINT_SAMPLE_RATE(d)) { 197 if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
191 maximum = float(maximum * m_sampleRate); 198 maximum = float(maximum * m_sampleRate);
192 } 199 }
193 200
194 return maximum; 201 return maximum;
195 } 202 }
196 203
200 float minimum = getPortMinimum(descriptor, port); 207 float minimum = getPortMinimum(descriptor, port);
201 float maximum = getPortMaximum(descriptor, port); 208 float maximum = getPortMaximum(descriptor, port);
202 float deft; 209 float deft;
203 210
204 if (m_portDefaults.find(descriptor->UniqueID) != 211 if (m_portDefaults.find(descriptor->UniqueID) !=
205 m_portDefaults.end()) { 212 m_portDefaults.end()) {
206 if (m_portDefaults[descriptor->UniqueID].find(port) != 213 if (m_portDefaults[descriptor->UniqueID].find(port) !=
207 m_portDefaults[descriptor->UniqueID].end()) { 214 m_portDefaults[descriptor->UniqueID].end()) {
208 215
209 deft = m_portDefaults[descriptor->UniqueID][port]; 216 deft = m_portDefaults[descriptor->UniqueID][port];
210 if (deft < minimum) deft = minimum; 217 if (deft < minimum) deft = minimum;
211 if (deft > maximum) deft = maximum; 218 if (deft > maximum) deft = maximum;
212 return deft; 219 return deft;
213 } 220 }
214 } 221 }
215 222
216 LADSPA_PortRangeHintDescriptor d = 223 LADSPA_PortRangeHintDescriptor d =
217 descriptor->PortRangeHints[port].HintDescriptor; 224 descriptor->PortRangeHints[port].HintDescriptor;
218 225
219 bool logarithmic = LADSPA_IS_HINT_LOGARITHMIC(d); 226 bool logarithmic = LADSPA_IS_HINT_LOGARITHMIC(d);
220 227
221 float logmin = 0, logmax = 0; 228 float logmin = 0, logmax = 0;
222 if (logarithmic) { 229 if (logarithmic) {
228 } 235 }
229 236
230 // SVDEBUG << "LADSPAPluginFactory::getPortDefault: hint = " << d << endl; 237 // SVDEBUG << "LADSPAPluginFactory::getPortDefault: hint = " << d << endl;
231 238
232 if (!LADSPA_IS_HINT_HAS_DEFAULT(d)) { 239 if (!LADSPA_IS_HINT_HAS_DEFAULT(d)) {
233 240
234 deft = minimum; 241 deft = minimum;
235 242
236 } else if (LADSPA_IS_HINT_DEFAULT_MINIMUM(d)) { 243 } else if (LADSPA_IS_HINT_DEFAULT_MINIMUM(d)) {
237 244
238 deft = minimum; 245 deft = minimum;
239 246
240 } else if (LADSPA_IS_HINT_DEFAULT_LOW(d)) { 247 } else if (LADSPA_IS_HINT_DEFAULT_LOW(d)) {
241 248
242 if (logarithmic) { 249 if (logarithmic) {
243 deft = powf(10, logmin * 0.75f + logmax * 0.25f); 250 deft = powf(10, logmin * 0.75f + logmax * 0.25f);
244 } else { 251 } else {
245 deft = minimum * 0.75f + maximum * 0.25f; 252 deft = minimum * 0.75f + maximum * 0.25f;
246 } 253 }
247 254
248 } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(d)) { 255 } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(d)) {
249 256
250 if (logarithmic) { 257 if (logarithmic) {
251 deft = powf(10, logmin * 0.5f + logmax * 0.5f); 258 deft = powf(10, logmin * 0.5f + logmax * 0.5f);
252 } else { 259 } else {
253 deft = minimum * 0.5f + maximum * 0.5f; 260 deft = minimum * 0.5f + maximum * 0.5f;
254 } 261 }
255 262
256 } else if (LADSPA_IS_HINT_DEFAULT_HIGH(d)) { 263 } else if (LADSPA_IS_HINT_DEFAULT_HIGH(d)) {
257 264
258 if (logarithmic) { 265 if (logarithmic) {
259 deft = powf(10, logmin * 0.25f + logmax * 0.75f); 266 deft = powf(10, logmin * 0.25f + logmax * 0.75f);
260 } else { 267 } else {
261 deft = minimum * 0.25f + maximum * 0.75f; 268 deft = minimum * 0.25f + maximum * 0.75f;
262 } 269 }
263 270
264 } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(d)) { 271 } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(d)) {
265 272
266 deft = maximum; 273 deft = maximum;
267 274
268 } else if (LADSPA_IS_HINT_DEFAULT_0(d)) { 275 } else if (LADSPA_IS_HINT_DEFAULT_0(d)) {
269 276
270 deft = 0.0; 277 deft = 0.0;
271 278
272 } else if (LADSPA_IS_HINT_DEFAULT_1(d)) { 279 } else if (LADSPA_IS_HINT_DEFAULT_1(d)) {
273 280
274 deft = 1.0; 281 deft = 1.0;
275 282
276 } else if (LADSPA_IS_HINT_DEFAULT_100(d)) { 283 } else if (LADSPA_IS_HINT_DEFAULT_100(d)) {
277 284
278 deft = 100.0; 285 deft = 100.0;
279 286
280 } else if (LADSPA_IS_HINT_DEFAULT_440(d)) { 287 } else if (LADSPA_IS_HINT_DEFAULT_440(d)) {
281 288
282 // deft = 440.0; 289 // deft = 440.0;
283 deft = (float)Preferences::getInstance()->getTuningFrequency(); 290 deft = (float)Preferences::getInstance()->getTuningFrequency();
284 291
285 } else { 292 } else {
286 293
287 deft = minimum; 294 deft = minimum;
288 } 295 }
289 296
290 //!!! No -- the min and max have already been multiplied by the rate, 297 //!!! No -- the min and max have already been multiplied by the rate,
291 //so it would happen twice if we did it here -- and e.g. DEFAULT_440 298 //so it would happen twice if we did it here -- and e.g. DEFAULT_440
292 //doesn't want to be multiplied by the rate either 299 //doesn't want to be multiplied by the rate either
293 300
294 // if (LADSPA_IS_HINT_SAMPLE_RATE(d)) { 301 // if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
295 // deft *= m_sampleRate; 302 // deft *= m_sampleRate;
296 // } 303 // }
297 304
298 return deft; 305 return deft;
299 } 306 }
300 307
314 321
315 int 322 int
316 LADSPAPluginFactory::getPortDisplayHint(const LADSPA_Descriptor *descriptor, int port) 323 LADSPAPluginFactory::getPortDisplayHint(const LADSPA_Descriptor *descriptor, int port)
317 { 324 {
318 LADSPA_PortRangeHintDescriptor d = 325 LADSPA_PortRangeHintDescriptor d =
319 descriptor->PortRangeHints[port].HintDescriptor; 326 descriptor->PortRangeHints[port].HintDescriptor;
320 int hint = PortHint::NoHint; 327 int hint = PortHint::NoHint;
321 328
322 if (LADSPA_IS_HINT_TOGGLED(d)) hint |= PortHint::Toggled; 329 if (LADSPA_IS_HINT_TOGGLED(d)) hint |= PortHint::Toggled;
323 if (LADSPA_IS_HINT_INTEGER(d)) hint |= PortHint::Integer; 330 if (LADSPA_IS_HINT_INTEGER(d)) hint |= PortHint::Integer;
324 if (LADSPA_IS_HINT_LOGARITHMIC(d)) hint |= PortHint::Logarithmic; 331 if (LADSPA_IS_HINT_LOGARITHMIC(d)) hint |= PortHint::Logarithmic;
327 } 334 }
328 335
329 336
330 RealTimePluginInstance * 337 RealTimePluginInstance *
331 LADSPAPluginFactory::instantiatePlugin(QString identifier, 338 LADSPAPluginFactory::instantiatePlugin(QString identifier,
332 int instrument, 339 int instrument,
333 int position, 340 int position,
334 sv_samplerate_t sampleRate, 341 sv_samplerate_t sampleRate,
335 int blockSize, 342 int blockSize,
336 int channels) 343 int channels)
337 { 344 {
338 Profiler profiler("LADSPAPluginFactory::instantiatePlugin"); 345 Profiler profiler("LADSPAPluginFactory::instantiatePlugin");
339 346
340 const LADSPA_Descriptor *descriptor = getLADSPADescriptor(identifier); 347 const LADSPA_Descriptor *descriptor = getLADSPADescriptor(identifier);
341 348
342 if (descriptor) { 349 if (descriptor) {
343 350
344 LADSPAPluginInstance *instance = 351 LADSPAPluginInstance *instance =
345 new LADSPAPluginInstance 352 new LADSPAPluginInstance
346 (this, instrument, identifier, position, sampleRate, blockSize, channels, 353 (this, instrument, identifier, position, sampleRate, blockSize, channels,
347 descriptor); 354 descriptor);
348 355
349 m_instances.insert(instance); 356 m_instances.insert(instance);
350 357
351 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY 358 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
352 SVDEBUG << "LADSPAPluginFactory::instantiatePlugin(" 359 SVDEBUG << "LADSPAPluginFactory::instantiatePlugin("
353 << identifier << ": now have " << m_instances.size() << " instances" << endl; 360 << identifier << ": now have " << m_instances.size() << " instances" << endl;
354 #endif 361 #endif
355 362
356 return instance; 363 return instance;
357 } 364 }
358 365
359 return 0; 366 return 0;
360 } 367 }
361 368
362 void 369 void
363 LADSPAPluginFactory::releasePlugin(RealTimePluginInstance *instance, 370 LADSPAPluginFactory::releasePlugin(RealTimePluginInstance *instance,
364 QString identifier) 371 QString identifier)
365 { 372 {
366 Profiler profiler("LADSPAPluginFactory::releasePlugin"); 373 Profiler profiler("LADSPAPluginFactory::releasePlugin");
367 374
368 if (m_instances.find(instance) == m_instances.end()) { 375 if (m_instances.find(instance) == m_instances.end()) {
369 cerr << "WARNING: LADSPAPluginFactory::releasePlugin: Not one of mine!" 376 cerr << "WARNING: LADSPAPluginFactory::releasePlugin: Not one of mine!"
370 << endl; 377 << endl;
371 return; 378 return;
372 } 379 }
373 380
374 QString type, soname, label; 381 QString type, soname, label;
375 PluginIdentifier::parseIdentifier(identifier, type, soname, label); 382 PluginIdentifier::parseIdentifier(identifier, type, soname, label);
376 383
377 m_instances.erase(instance); 384 m_instances.erase(instance);
378 385
379 bool stillInUse = false; 386 bool stillInUse = false;
380 387
381 for (std::set<RealTimePluginInstance *>::iterator ii = m_instances.begin(); 388 for (std::set<RealTimePluginInstance *>::iterator ii = m_instances.begin();
382 ii != m_instances.end(); ++ii) { 389 ii != m_instances.end(); ++ii) {
383 QString itype, isoname, ilabel; 390 QString itype, isoname, ilabel;
384 PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel); 391 PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel);
385 if (isoname == soname) { 392 if (isoname == soname) {
386 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY 393 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
387 SVDEBUG << "LADSPAPluginFactory::releasePlugin: dll " << soname << " is still in use for plugin " << ilabel << endl; 394 SVDEBUG << "LADSPAPluginFactory::releasePlugin: dll " << soname << " is still in use for plugin " << ilabel << endl;
388 #endif 395 #endif
389 stillInUse = true; 396 stillInUse = true;
390 break; 397 break;
391 } 398 }
392 } 399 }
393 400
394 if (!stillInUse) { 401 if (!stillInUse) {
395 if (soname != PluginIdentifier::BUILTIN_PLUGIN_SONAME) { 402 if (soname != PluginIdentifier::BUILTIN_PLUGIN_SONAME) {
396 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY 403 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
411 { 418 {
412 QString type, soname, label; 419 QString type, soname, label;
413 PluginIdentifier::parseIdentifier(identifier, type, soname, label); 420 PluginIdentifier::parseIdentifier(identifier, type, soname, label);
414 421
415 if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { 422 if (m_libraryHandles.find(soname) == m_libraryHandles.end()) {
416 loadLibrary(soname); 423 loadLibrary(soname);
417 if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { 424 if (m_libraryHandles.find(soname) == m_libraryHandles.end()) {
418 cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: loadLibrary failed for " << soname << endl; 425 SVCERR << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: loadLibrary failed for " << soname << endl;
419 return 0; 426 return 0;
420 } 427 }
421 } 428 }
422 429
423 void *libraryHandle = m_libraryHandles[soname]; 430 void *libraryHandle = m_libraryHandles[soname];
424 431
425 LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function) 432 LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function)
426 DLSYM(libraryHandle, "ladspa_descriptor"); 433 DLSYM(libraryHandle, "ladspa_descriptor");
427 434
428 if (!fn) { 435 if (!fn) {
429 cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No descriptor function in library " << soname << endl; 436 SVCERR << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No descriptor function in library " << soname << endl;
430 return 0; 437 return 0;
431 } 438 }
432 439
433 const LADSPA_Descriptor *descriptor = 0; 440 const LADSPA_Descriptor *descriptor = 0;
434 441
435 int index = 0; 442 int index = 0;
436 while ((descriptor = fn(index))) { 443 while ((descriptor = fn(index))) {
437 if (descriptor->Label == label) return descriptor; 444 if (descriptor->Label == label) return descriptor;
438 ++index; 445 ++index;
439 } 446 }
440 447
441 cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No such plugin as " << label << " in library " << soname << endl; 448 SVCERR << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No such plugin as " << label << " in library " << soname << endl;
442 449
443 return 0; 450 return 0;
444 } 451 }
445 452
446 void 453 void
453 return; 460 return;
454 } 461 }
455 462
456 if (QFileInfo(soName).exists()) { 463 if (QFileInfo(soName).exists()) {
457 DLERROR(); 464 DLERROR();
458 cerr << "LADSPAPluginFactory::loadLibrary: Library \"" << soName << "\" exists, but failed to load it" << endl; 465 SVCERR << "LADSPAPluginFactory::loadLibrary: Library \"" << soName << "\" exists, but failed to load it" << endl;
459 return; 466 return;
460 } 467 }
461 468
462 std::vector<QString> pathList = getPluginPath(); 469 std::vector<QString> pathList = getPluginPath();
463 470
464 QString fileName = QFile(soName).fileName(); 471 QString fileName = QFile(soName).fileName();
465 QString base = QFileInfo(soName).baseName(); 472 QString base = QFileInfo(soName).baseName();
466 473
467 for (std::vector<QString>::iterator i = pathList.begin(); 474 for (std::vector<QString>::iterator i = pathList.begin();
468 i != pathList.end(); ++i) { 475 i != pathList.end(); ++i) {
469 476
470 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY 477 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
471 SVDEBUG << "Looking at: " << (*i) << endl; 478 SVDEBUG << "Looking at: " << (*i) << endl;
472 #endif 479 #endif
473 480
475 QDir::Name | QDir::IgnoreCase, 482 QDir::Name | QDir::IgnoreCase,
476 QDir::Files | QDir::Readable); 483 QDir::Files | QDir::Readable);
477 484
478 if (QFileInfo(dir.filePath(fileName)).exists()) { 485 if (QFileInfo(dir.filePath(fileName)).exists()) {
479 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY 486 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
480 cerr << "Loading: " << fileName << endl; 487 SVDEBUG << "Loading: " << fileName << endl;
481 #endif 488 #endif
482 libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW); 489 libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW);
483 if (libraryHandle) { 490 if (libraryHandle) {
484 m_libraryHandles[soName] = libraryHandle; 491 m_libraryHandles[soName] = libraryHandle;
485 return; 492 return;
486 } 493 }
487 } 494 }
488 495
489 for (unsigned int j = 0; j < dir.count(); ++j) { 496 for (unsigned int j = 0; j < dir.count(); ++j) {
490 QString file = dir.filePath(dir[j]); 497 QString file = dir.filePath(dir[j]);
491 if (QFileInfo(file).baseName() == base) { 498 if (QFileInfo(file).baseName() == base) {
492 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY 499 #ifdef DEBUG_LADSPA_PLUGIN_FACTORY
493 cerr << "Loading: " << file << endl; 500 SVDEBUG << "Loading: " << file << endl;
494 #endif 501 #endif
495 libraryHandle = DLOPEN(file, RTLD_NOW); 502 libraryHandle = DLOPEN(file, RTLD_NOW);
496 if (libraryHandle) { 503 if (libraryHandle) {
497 m_libraryHandles[soName] = libraryHandle; 504 m_libraryHandles[soName] = libraryHandle;
498 return; 505 return;
499 } 506 }
500 } 507 }
501 } 508 }
502 } 509 }
503 510
504 cerr << "LADSPAPluginFactory::loadLibrary: Failed to locate plugin library \"" << soName << "\"" << endl; 511 SVCERR << "LADSPAPluginFactory::loadLibrary: Failed to locate plugin library \"" << soName << "\"" << endl;
505 } 512 }
506 513
507 void 514 void
508 LADSPAPluginFactory::unloadLibrary(QString soName) 515 LADSPAPluginFactory::unloadLibrary(QString soName)
509 { 516 {
510 LibraryHandleMap::iterator li = m_libraryHandles.find(soName); 517 LibraryHandleMap::iterator li = m_libraryHandles.find(soName);
511 if (li != m_libraryHandles.end()) { 518 if (li != m_libraryHandles.end()) {
512 // SVDEBUG << "unloading " << soname << endl; 519 // SVDEBUG << "unloading " << soname << endl;
513 DLCLOSE(m_libraryHandles[soName]); 520 DLCLOSE(m_libraryHandles[soName]);
514 m_libraryHandles.erase(li); 521 m_libraryHandles.erase(li);
515 } 522 }
516 } 523 }
517 524
518 void 525 void
519 LADSPAPluginFactory::unloadUnusedLibraries() 526 LADSPAPluginFactory::unloadUnusedLibraries()
520 { 527 {
521 std::vector<QString> toUnload; 528 std::vector<QString> toUnload;
522 529
523 for (LibraryHandleMap::iterator i = m_libraryHandles.begin(); 530 for (LibraryHandleMap::iterator i = m_libraryHandles.begin();
524 i != m_libraryHandles.end(); ++i) { 531 i != m_libraryHandles.end(); ++i) {
525 532
526 bool stillInUse = false; 533 bool stillInUse = false;
527 534
528 for (std::set<RealTimePluginInstance *>::iterator ii = m_instances.begin(); 535 for (std::set<RealTimePluginInstance *>::iterator ii = m_instances.begin();
529 ii != m_instances.end(); ++ii) { 536 ii != m_instances.end(); ++ii) {
530 537
531 QString itype, isoname, ilabel; 538 QString itype, isoname, ilabel;
532 PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel); 539 PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel);
533 if (isoname == i->first) { 540 if (isoname == i->first) {
534 stillInUse = true; 541 stillInUse = true;
535 break; 542 break;
536 } 543 }
537 } 544 }
538 545
539 if (!stillInUse) toUnload.push_back(i->first); 546 if (!stillInUse) toUnload.push_back(i->first);
540 } 547 }
541 548
542 for (std::vector<QString>::iterator i = toUnload.begin(); 549 for (std::vector<QString>::iterator i = toUnload.begin();
543 i != toUnload.end(); ++i) { 550 i != toUnload.end(); ++i) {
544 if (*i != PluginIdentifier::BUILTIN_PLUGIN_SONAME) { 551 if (*i != PluginIdentifier::BUILTIN_PLUGIN_SONAME) {
545 unloadLibrary(*i); 552 unloadLibrary(*i);
546 } 553 }
547 } 554 }
548 } 555 }
558 565
559 std::vector<QString> 566 std::vector<QString>
560 LADSPAPluginFactory::getPluginPath() 567 LADSPAPluginFactory::getPluginPath()
561 { 568 {
562 std::vector<QString> pathList; 569 std::vector<QString> pathList;
563 std::string path; 570 string path;
564 571
565 char *cpath = getenv("LADSPA_PATH"); 572 (void)getEnvUtf8("LADSPA_PATH", path);
566 if (cpath) path = cpath;
567 573
568 if (path == "") { 574 if (path == "") {
569 575
570 path = DEFAULT_LADSPA_PATH; 576 path = DEFAULT_LADSPA_PATH;
571 577
572 char *home = getenv("HOME"); 578 string home;
573 if (home) { 579 if (getEnvUtf8("HOME", home)) {
574 std::string::size_type f; 580 string::size_type f;
575 while ((f = path.find("$HOME")) != std::string::npos && 581 while ((f = path.find("$HOME")) != string::npos &&
576 f < path.length()) { 582 f < path.length()) {
577 path.replace(f, 5, home); 583 path.replace(f, 5, home);
578 } 584 }
579 } 585 }
580 586
581 #ifdef _WIN32 587 #ifdef _WIN32
582 const char *pfiles = getenv("ProgramFiles"); 588 string pfiles;
583 if (!pfiles) pfiles = "C:\\Program Files"; 589 if (!getEnvUtf8("ProgramFiles", pfiles)) {
584 { 590 pfiles = "C:\\Program Files";
585 std::string::size_type f; 591 }
586 while ((f = path.find("%ProgramFiles%")) != std::string::npos && 592
593 string::size_type f;
594 while ((f = path.find("%ProgramFiles%")) != string::npos &&
587 f < path.length()) { 595 f < path.length()) {
588 path.replace(f, 14, pfiles); 596 path.replace(f, 14, pfiles);
589 } 597 }
590 } 598 #endif
591 #endif 599 }
592 } 600
593 601 string::size_type index = 0, newindex = 0;
594 std::string::size_type index = 0, newindex = 0;
595 602
596 while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) { 603 while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) {
597 pathList.push_back(path.substr(index, newindex - index).c_str()); 604 pathList.push_back(path.substr(index, newindex - index).c_str());
598 index = newindex + 1; 605 index = newindex + 1;
599 } 606 }
600 607
601 pathList.push_back(path.substr(index).c_str()); 608 pathList.push_back(path.substr(index).c_str());
602 609
603 return pathList; 610 return pathList;
614 621
615 lrdfPaths.push_back("/usr/local/share/ladspa/rdf"); 622 lrdfPaths.push_back("/usr/local/share/ladspa/rdf");
616 lrdfPaths.push_back("/usr/share/ladspa/rdf"); 623 lrdfPaths.push_back("/usr/share/ladspa/rdf");
617 624
618 for (std::vector<QString>::iterator i = pathList.begin(); 625 for (std::vector<QString>::iterator i = pathList.begin();
619 i != pathList.end(); ++i) { 626 i != pathList.end(); ++i) {
620 lrdfPaths.push_back(*i + "/rdf"); 627 lrdfPaths.push_back(*i + "/rdf");
621 } 628 }
622 629
623 baseUri = LADSPA_BASE; 630 baseUri = LADSPA_BASE;
624 #else 631 #else
625 baseUri = ""; 632 baseUri = "";
634 Profiler profiler("LADSPAPluginFactory::discoverPlugins"); 641 Profiler profiler("LADSPAPluginFactory::discoverPlugins");
635 642
636 std::vector<QString> pathList = getPluginPath(); 643 std::vector<QString> pathList = getPluginPath();
637 644
638 // SVDEBUG << "LADSPAPluginFactory::discoverPlugins - " 645 // SVDEBUG << "LADSPAPluginFactory::discoverPlugins - "
639 // << "discovering plugins; path is "; 646 // << "discovering plugins; path is ";
640 // for (std::vector<QString>::iterator i = pathList.begin(); 647 // for (std::vector<QString>::iterator i = pathList.begin();
641 // i != pathList.end(); ++i) { 648 // i != pathList.end(); ++i) {
642 // SVDEBUG << "[" << i-<< "] "; 649 // SVDEBUG << "[" << i-<< "] ";
643 // } 650 // }
644 // SVDEBUG << endl; 651 // SVDEBUG << endl;
645 652
646 #ifdef HAVE_LRDF 653 #ifdef HAVE_LRDF
647 // read the description files 654 // read the description files
650 std::vector<QString> lrdfPaths = getLRDFPath(baseUri); 657 std::vector<QString> lrdfPaths = getLRDFPath(baseUri);
651 658
652 bool haveSomething = false; 659 bool haveSomething = false;
653 660
654 for (size_t i = 0; i < lrdfPaths.size(); ++i) { 661 for (size_t i = 0; i < lrdfPaths.size(); ++i) {
655 QDir dir(lrdfPaths[i], "*.rdf;*.rdfs"); 662 QDir dir(lrdfPaths[i], "*.rdf;*.rdfs");
656 for (unsigned int j = 0; j < dir.count(); ++j) { 663 for (unsigned int j = 0; j < dir.count(); ++j) {
657 if (!lrdf_read_file(QString("file:" + lrdfPaths[i] + "/" + dir[j]).toStdString().c_str())) { 664 if (!lrdf_read_file(QString("file:" + lrdfPaths[i] + "/" + dir[j]).toStdString().c_str())) {
658 // cerr << "LADSPAPluginFactory: read RDF file " << (lrdfPaths[i] + "/" + dir[j]) << endl; 665 // cerr << "LADSPAPluginFactory: read RDF file " << (lrdfPaths[i] + "/" + dir[j]) << endl;
659 haveSomething = true; 666 haveSomething = true;
660 } 667 }
661 } 668 }
662 } 669 }
663 670
664 if (haveSomething) { 671 if (haveSomething) {
665 generateTaxonomy(baseUri + "Plugin", ""); 672 generateTaxonomy(baseUri + "Plugin", "");
666 } 673 }
667 #endif // HAVE_LRDF 674 #endif // HAVE_LRDF
668 675
669 generateFallbackCategories(); 676 generateFallbackCategories();
670 677
686 << soname << " - " << DLERROR() << endl; 693 << soname << " - " << DLERROR() << endl;
687 return; 694 return;
688 } 695 }
689 696
690 LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function) 697 LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function)
691 DLSYM(libraryHandle, "ladspa_descriptor"); 698 DLSYM(libraryHandle, "ladspa_descriptor");
692 699
693 if (!fn) { 700 if (!fn) {
694 cerr << "WARNING: LADSPAPluginFactory::discoverPlugins: No descriptor function in " << soname << endl; 701 cerr << "WARNING: LADSPAPluginFactory::discoverPlugins: No descriptor function in " << soname << endl;
695 return; 702 return;
696 } 703 }
697 704
698 const LADSPA_Descriptor *descriptor = 0; 705 const LADSPA_Descriptor *descriptor = 0;
699 706
700 int index = 0; 707 int index = 0;
710 rtd->parameterCount = 0; 717 rtd->parameterCount = 0;
711 rtd->audioInputPortCount = 0; 718 rtd->audioInputPortCount = 0;
712 rtd->audioOutputPortCount = 0; 719 rtd->audioOutputPortCount = 0;
713 rtd->controlOutputPortCount = 0; 720 rtd->controlOutputPortCount = 0;
714 721
715 QString identifier = PluginIdentifier::createIdentifier 722 QString identifier = PluginIdentifier::createIdentifier
716 ("ladspa", soname, descriptor->Label); 723 ("ladspa", soname, descriptor->Label);
717 724
718 #ifdef HAVE_LRDF 725 #ifdef HAVE_LRDF
719 char *def_uri = 0; 726 char *def_uri = 0;
720 lrdf_defaults *defs = 0; 727 lrdf_defaults *defs = 0;
721 728
722 if (m_lrdfTaxonomy[descriptor->UniqueID] != "") { 729 if (m_lrdfTaxonomy[descriptor->UniqueID] != "") {
723 m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->UniqueID]; 730 m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->UniqueID];
724 // cerr << "set id \"" << identifier << "\" to cat \"" << m_taxonomy[identifier] << "\" from LRDF" << endl; 731 // cerr << "set id \"" << identifier << "\" to cat \"" << m_taxonomy[identifier] << "\" from LRDF" << endl;
725 // cout << identifier << "::" << m_taxonomy[identifier] << endl; 732 // cout << identifier << "::" << m_taxonomy[identifier] << endl;
726 } 733 }
727 734
728 QString category = m_taxonomy[identifier]; 735 QString category = m_taxonomy[identifier];
729 736
730 if (category == "") { 737 if (category == "") {
731 std::string name = rtd->name; 738 string name = rtd->name;
732 if (name.length() > 4 && 739 if (name.length() > 4 &&
733 name.substr(name.length() - 4) == " VST") { 740 name.substr(name.length() - 4) == " VST") {
734 category = "VST effects"; 741 category = "VST effects";
735 m_taxonomy[identifier] = category; 742 m_taxonomy[identifier] = category;
736 } 743 }
737 } 744 }
738 745
739 rtd->category = category.toStdString(); 746 rtd->category = category.toStdString();
740 747
741 // cerr << "Plugin id is " << descriptor->UniqueID 748 // cerr << "Plugin id is " << descriptor->UniqueID
742 // << ", category is \"" << (category ? category : QString("(none)")) 749 // << ", category is \"" << (category ? category : QString("(none)"))
743 // << "\", name is " << descriptor->Name 750 // << "\", name is " << descriptor->Name
744 // << ", label is " << descriptor->Label 751 // << ", label is " << descriptor->Label
745 // << endl; 752 // << endl;
746 753
747 def_uri = lrdf_get_default_uri(descriptor->UniqueID); 754 def_uri = lrdf_get_default_uri(descriptor->UniqueID);
748 if (def_uri) { 755 if (def_uri) {
749 defs = lrdf_get_setting_values(def_uri); 756 defs = lrdf_get_setting_values(def_uri);
750 } 757 }
751 758
752 unsigned int controlPortNumber = 1; 759 unsigned int controlPortNumber = 1;
753 760
754 for (int i = 0; i < (int)descriptor->PortCount; i++) { 761 for (int i = 0; i < (int)descriptor->PortCount; i++) {
755 762
756 if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) { 763 if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) {
757 764
758 if (def_uri && defs) { 765 if (def_uri && defs) {
759 766
760 for (unsigned int j = 0; j < defs->count; j++) { 767 for (unsigned int j = 0; j < defs->count; j++) {
761 if (defs->items[j].pid == controlPortNumber) { 768 if (defs->items[j].pid == controlPortNumber) {
762 // cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << descriptor->PortNames[i] << endl; 769 // cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << descriptor->PortNames[i] << endl;
763 m_portDefaults[descriptor->UniqueID][i] = 770 m_portDefaults[descriptor->UniqueID][i] =
764 defs->items[j].value; 771 defs->items[j].value;
765 } 772 }
766 } 773 }
767 } 774 }
768 775
769 ++controlPortNumber; 776 ++controlPortNumber;
770 } 777 }
771 } 778 }
772 #endif // HAVE_LRDF 779 #endif // HAVE_LRDF
773 780
774 for (int i = 0; i < (int)descriptor->PortCount; i++) { 781 for (int i = 0; i < (int)descriptor->PortCount; i++) {
775 if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) { 782 if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) {
776 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { 783 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) {
777 ++rtd->parameterCount; 784 ++rtd->parameterCount;
778 } else { 785 } else {
779 if (strcmp(descriptor->PortNames[i], "latency") && 786 if (strcmp(descriptor->PortNames[i], "latency") &&
780 strcmp(descriptor->PortNames[i], "_latency")) { 787 strcmp(descriptor->PortNames[i], "_latency")) {
790 ++rtd->audioOutputPortCount; 797 ++rtd->audioOutputPortCount;
791 } 798 }
792 } 799 }
793 } 800 }
794 801
795 m_identifiers.push_back(identifier); 802 m_identifiers.push_back(identifier);
803
804 m_libraries[identifier] = soname;
796 805
797 m_rtDescriptors[identifier] = rtd; 806 m_rtDescriptors[identifier] = rtd;
798 807
799 ++index; 808 ++index;
800 } 809 }
801 810
802 if (DLCLOSE(libraryHandle) != 0) { 811 if (DLCLOSE(libraryHandle) != 0) {
803 cerr << "WARNING: LADSPAPluginFactory::discoverPlugins - can't unload " << libraryHandle << endl; 812 cerr << "WARNING: LADSPAPluginFactory::discoverPlugins - can't unload " << libraryHandle << endl;
804 return; 813 return;
810 { 819 {
811 std::vector<QString> pluginPath = getPluginPath(); 820 std::vector<QString> pluginPath = getPluginPath();
812 std::vector<QString> path; 821 std::vector<QString> path;
813 822
814 for (size_t i = 0; i < pluginPath.size(); ++i) { 823 for (size_t i = 0; i < pluginPath.size(); ++i) {
815 if (pluginPath[i].contains("/lib/")) { 824 if (pluginPath[i].contains("/lib/")) {
816 QString p(pluginPath[i]); 825 QString p(pluginPath[i]);
817 path.push_back(p); 826 path.push_back(p);
818 p.replace("/lib/", "/share/"); 827 p.replace("/lib/", "/share/");
819 path.push_back(p); 828 path.push_back(p);
820 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << p << endl; 829 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << p << endl;
821 } 830 }
822 path.push_back(pluginPath[i]); 831 path.push_back(pluginPath[i]);
823 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i] << endl; 832 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i] << endl;
824 } 833 }
825 834
826 for (size_t i = 0; i < path.size(); ++i) { 835 for (size_t i = 0; i < path.size(); ++i) {
827 836
828 QDir dir(path[i], "*.cat"); 837 QDir dir(path[i], "*.cat");
829 838
830 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl; 839 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl;
831 for (unsigned int j = 0; j < dir.count(); ++j) { 840 for (unsigned int j = 0; j < dir.count(); ++j) {
832 841
833 QFile file(path[i] + "/" + dir[j]); 842 QFile file(path[i] + "/" + dir[j]);
834 843
835 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl; 844 // SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl;
836 845
837 if (file.open(QIODevice::ReadOnly)) { 846 if (file.open(QIODevice::ReadOnly)) {
838 // cerr << "...opened" << endl; 847 // cerr << "...opened" << endl;
839 QTextStream stream(&file); 848 QTextStream stream(&file);
840 QString line; 849 QString line;
841 850
842 while (!stream.atEnd()) { 851 while (!stream.atEnd()) {
843 line = stream.readLine(); 852 line = stream.readLine();
844 // cerr << "line is: \"" << line << "\"" << endl; 853 // cerr << "line is: \"" << line << "\"" << endl;
845 QString id = PluginIdentifier::canonicalise 854 QString id = PluginIdentifier::canonicalise
846 (line.section("::", 0, 0)); 855 (line.section("::", 0, 0));
847 QString cat = line.section("::", 1, 1); 856 QString cat = line.section("::", 1, 1);
848 m_taxonomy[id] = cat; 857 m_taxonomy[id] = cat;
849 // cerr << "set id \"" << id << "\" to cat \"" << cat << "\"" << endl; 858 // cerr << "set id \"" << id << "\" to cat \"" << cat << "\"" << endl;
850 } 859 }
851 } 860 }
852 } 861 }
853 } 862 }
854 } 863 }
855 864
856 void 865 void
857 LADSPAPluginFactory::generateTaxonomy(QString uri, QString base) 866 LADSPAPluginFactory::generateTaxonomy(QString uri, QString base)
858 { 867 {
859 #ifdef HAVE_LRDF 868 #ifdef HAVE_LRDF
860 lrdf_uris *uris = lrdf_get_instances(uri.toStdString().c_str()); 869 lrdf_uris *uris = lrdf_get_instances(uri.toStdString().c_str());
861 870
862 if (uris != NULL) { 871 if (uris != NULL) {
863 for (unsigned int i = 0; i < uris->count; ++i) { 872 for (unsigned int i = 0; i < uris->count; ++i) {
864 m_lrdfTaxonomy[lrdf_get_uid(uris->items[i])] = base; 873 m_lrdfTaxonomy[lrdf_get_uid(uris->items[i])] = base;
865 } 874 }
866 lrdf_free_uris(uris); 875 lrdf_free_uris(uris);
867 } 876 }
868 877
869 uris = lrdf_get_subclasses(uri.toStdString().c_str()); 878 uris = lrdf_get_subclasses(uri.toStdString().c_str());
870 879
871 if (uris != NULL) { 880 if (uris != NULL) {
872 for (unsigned int i = 0; i < uris->count; ++i) { 881 for (unsigned int i = 0; i < uris->count; ++i) {
873 char *label = lrdf_get_label(uris->items[i]); 882 char *label = lrdf_get_label(uris->items[i]);
874 generateTaxonomy(uris->items[i], 883 generateTaxonomy(uris->items[i],
875 base + (base.length() > 0 ? " > " : "") + label); 884 base + (base.length() > 0 ? " > " : "") + label);
876 } 885 }
877 lrdf_free_uris(uris); 886 lrdf_free_uris(uris);
878 } 887 }
879 #else 888 #else
880 // avoid unused parameter 889 // avoid unused parameter
881 (void)uri; 890 (void)uri;
882 (void)base; 891 (void)base;