Mercurial > hg > svcore
comparison plugin/DSSIPluginFactory.cpp @ 1830:5f8fbbde08ff audio-source-refactor
Use shared_ptr for plugin instances throughout
author | Chris Cannam |
---|---|
date | Fri, 20 Mar 2020 16:30:33 +0000 |
parents | 70e172e6cc59 |
children | 1adbeb52d761 |
comparison
equal
deleted
inserted
replaced
1829:51fd27fbce9a | 1830:5f8fbbde08ff |
---|---|
108 } | 108 } |
109 | 109 |
110 unloadUnusedLibraries(); | 110 unloadUnusedLibraries(); |
111 } | 111 } |
112 | 112 |
113 RealTimePluginInstance * | 113 std::shared_ptr<RealTimePluginInstance> |
114 DSSIPluginFactory::instantiatePlugin(QString identifier, | 114 DSSIPluginFactory::instantiatePlugin(QString identifier, |
115 int instrument, | 115 int instrument, |
116 int position, | 116 int position, |
117 sv_samplerate_t sampleRate, | 117 sv_samplerate_t sampleRate, |
118 int blockSize, | 118 int blockSize, |
122 | 122 |
123 const DSSI_Descriptor *descriptor = getDSSIDescriptor(identifier); | 123 const DSSI_Descriptor *descriptor = getDSSIDescriptor(identifier); |
124 | 124 |
125 if (descriptor) { | 125 if (descriptor) { |
126 | 126 |
127 DSSIPluginInstance *instance = | 127 auto instance = |
128 new DSSIPluginInstance | 128 std::shared_ptr<RealTimePluginInstance> |
129 (this, instrument, identifier, position, sampleRate, blockSize, channels, | 129 (new DSSIPluginInstance |
130 descriptor); | 130 (this, instrument, identifier, position, |
131 sampleRate, blockSize, channels, descriptor)); | |
131 | 132 |
132 m_instances.insert(instance); | 133 m_instances.insert(instance); |
133 | 134 |
134 return instance; | 135 return instance; |
135 } | 136 } |
318 cerr << "WARNING: DSSIPluginFactory::discoverPlugins: No LADSPA descriptor for plugin " << index << " in " << soname << endl; | 319 cerr << "WARNING: DSSIPluginFactory::discoverPlugins: No LADSPA descriptor for plugin " << index << " in " << soname << endl; |
319 ++index; | 320 ++index; |
320 continue; | 321 continue; |
321 } | 322 } |
322 | 323 |
323 RealTimePluginDescriptor *rtd = new RealTimePluginDescriptor; | 324 RealTimePluginDescriptor rtd; |
324 rtd->name = ladspaDescriptor->Name; | 325 rtd.name = ladspaDescriptor->Name; |
325 rtd->label = ladspaDescriptor->Label; | 326 rtd.label = ladspaDescriptor->Label; |
326 rtd->maker = ladspaDescriptor->Maker; | 327 rtd.maker = ladspaDescriptor->Maker; |
327 rtd->copyright = ladspaDescriptor->Copyright; | 328 rtd.copyright = ladspaDescriptor->Copyright; |
328 rtd->category = ""; | 329 rtd.category = ""; |
329 rtd->isSynth = (descriptor->run_synth || | 330 rtd.isSynth = (descriptor->run_synth || |
330 descriptor->run_multiple_synths); | 331 descriptor->run_multiple_synths); |
331 rtd->parameterCount = 0; | 332 rtd.parameterCount = 0; |
332 rtd->audioInputPortCount = 0; | 333 rtd.audioInputPortCount = 0; |
333 rtd->audioOutputPortCount = 0; | 334 rtd.audioOutputPortCount = 0; |
334 rtd->controlOutputPortCount = 0; | 335 rtd.controlOutputPortCount = 0; |
335 | 336 |
336 QString identifier = PluginIdentifier::createIdentifier | 337 QString identifier = PluginIdentifier::createIdentifier |
337 ("dssi", soname, ladspaDescriptor->Label); | 338 ("dssi", soname, ladspaDescriptor->Label); |
338 | 339 |
339 #ifdef HAVE_LRDF | 340 #ifdef HAVE_LRDF |
346 m_taxonomy[identifier] = m_lrdfTaxonomy[ladspaDescriptor->UniqueID]; | 347 m_taxonomy[identifier] = m_lrdfTaxonomy[ladspaDescriptor->UniqueID]; |
347 category = m_taxonomy[identifier]; | 348 category = m_taxonomy[identifier]; |
348 } | 349 } |
349 | 350 |
350 if (category == "") { | 351 if (category == "") { |
351 string name = rtd->name; | 352 string name = rtd.name; |
352 if (name.length() > 4 && | 353 if (name.length() > 4 && |
353 name.substr(name.length() - 4) == " VST") { | 354 name.substr(name.length() - 4) == " VST") { |
354 if (descriptor->run_synth || descriptor->run_multiple_synths) { | 355 if (descriptor->run_synth || descriptor->run_multiple_synths) { |
355 category = "VST instruments"; | 356 category = "VST instruments"; |
356 } else { | 357 } else { |
358 } | 359 } |
359 m_taxonomy[identifier] = category; | 360 m_taxonomy[identifier] = category; |
360 } | 361 } |
361 } | 362 } |
362 | 363 |
363 rtd->category = category.toStdString(); | 364 rtd.category = category.toStdString(); |
364 | 365 |
365 // cerr << "Plugin id is " << ladspaDescriptor->UniqueID | 366 // cerr << "Plugin id is " << ladspaDescriptor->UniqueID |
366 // << ", identifier is \"" << identifier | 367 // << ", identifier is \"" << identifier |
367 // << "\", category is \"" << category | 368 // << "\", category is \"" << category |
368 // << "\", name is " << ladspaDescriptor->Name | 369 // << "\", name is " << ladspaDescriptor->Name |
397 #endif // HAVE_LRDF | 398 #endif // HAVE_LRDF |
398 | 399 |
399 for (unsigned long i = 0; i < ladspaDescriptor->PortCount; i++) { | 400 for (unsigned long i = 0; i < ladspaDescriptor->PortCount; i++) { |
400 if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) { | 401 if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) { |
401 if (LADSPA_IS_PORT_INPUT(ladspaDescriptor->PortDescriptors[i])) { | 402 if (LADSPA_IS_PORT_INPUT(ladspaDescriptor->PortDescriptors[i])) { |
402 ++rtd->parameterCount; | 403 ++rtd.parameterCount; |
403 } else { | 404 } else { |
404 if (strcmp(ladspaDescriptor->PortNames[i], "latency") && | 405 if (strcmp(ladspaDescriptor->PortNames[i], "latency") && |
405 strcmp(ladspaDescriptor->PortNames[i], "_latency")) { | 406 strcmp(ladspaDescriptor->PortNames[i], "_latency")) { |
406 ++rtd->controlOutputPortCount; | 407 ++rtd.controlOutputPortCount; |
407 rtd->controlOutputPortNames.push_back | 408 rtd.controlOutputPortNames.push_back |
408 (ladspaDescriptor->PortNames[i]); | 409 (ladspaDescriptor->PortNames[i]); |
409 } | 410 } |
410 } | 411 } |
411 } else { | 412 } else { |
412 if (LADSPA_IS_PORT_INPUT(ladspaDescriptor->PortDescriptors[i])) { | 413 if (LADSPA_IS_PORT_INPUT(ladspaDescriptor->PortDescriptors[i])) { |
413 ++rtd->audioInputPortCount; | 414 ++rtd.audioInputPortCount; |
414 } else if (LADSPA_IS_PORT_OUTPUT(ladspaDescriptor->PortDescriptors[i])) { | 415 } else if (LADSPA_IS_PORT_OUTPUT(ladspaDescriptor->PortDescriptors[i])) { |
415 ++rtd->audioOutputPortCount; | 416 ++rtd.audioOutputPortCount; |
416 } | 417 } |
417 } | 418 } |
418 } | 419 } |
419 | 420 |
420 m_identifiers.push_back(identifier); | 421 m_identifiers.push_back(identifier); |