comparison vamp-sdk/PluginAdapter.cpp @ 49:aa64a46320d4

* Rename "name" and "description" to "identifier" and "name"; add new "description" that actually contains a description
author cannam
date Mon, 26 Feb 2007 18:08:48 +0000
parents be8fdfe25693
children b907557b2fb9
comparison
equal deleted inserted replaced
48:f46bf5e0fa42 49:aa64a46320d4
61 Plugin *plugin = createPlugin(48000); 61 Plugin *plugin = createPlugin(48000);
62 62
63 m_parameters = plugin->getParameterDescriptors(); 63 m_parameters = plugin->getParameterDescriptors();
64 m_programs = plugin->getPrograms(); 64 m_programs = plugin->getPrograms();
65 65
66 m_descriptor.identifier = strdup(plugin->getIdentifier().c_str());
66 m_descriptor.name = strdup(plugin->getName().c_str()); 67 m_descriptor.name = strdup(plugin->getName().c_str());
67 m_descriptor.description = strdup(plugin->getDescription().c_str()); 68 m_descriptor.description = strdup(plugin->getDescription().c_str());
68 m_descriptor.maker = strdup(plugin->getMaker().c_str()); 69 m_descriptor.maker = strdup(plugin->getMaker().c_str());
69 m_descriptor.pluginVersion = plugin->getPluginVersion(); 70 m_descriptor.pluginVersion = plugin->getPluginVersion();
70 m_descriptor.copyright = strdup(plugin->getCopyright().c_str()); 71 m_descriptor.copyright = strdup(plugin->getCopyright().c_str());
76 unsigned int i; 77 unsigned int i;
77 78
78 for (i = 0; i < m_parameters.size(); ++i) { 79 for (i = 0; i < m_parameters.size(); ++i) {
79 VampParameterDescriptor *desc = (VampParameterDescriptor *) 80 VampParameterDescriptor *desc = (VampParameterDescriptor *)
80 malloc(sizeof(VampParameterDescriptor)); 81 malloc(sizeof(VampParameterDescriptor));
82 desc->identifier = strdup(m_parameters[i].identifier.c_str());
81 desc->name = strdup(m_parameters[i].name.c_str()); 83 desc->name = strdup(m_parameters[i].name.c_str());
82 desc->description = strdup(m_parameters[i].description.c_str()); 84 desc->description = strdup(m_parameters[i].description.c_str());
83 desc->unit = strdup(m_parameters[i].unit.c_str()); 85 desc->unit = strdup(m_parameters[i].unit.c_str());
84 desc->minValue = m_parameters[i].minValue; 86 desc->minValue = m_parameters[i].minValue;
85 desc->maxValue = m_parameters[i].maxValue; 87 desc->maxValue = m_parameters[i].maxValue;
148 std::cerr << "PluginAdapterBase[" << this << "]::~PluginAdapterBase" << std::endl; 150 std::cerr << "PluginAdapterBase[" << this << "]::~PluginAdapterBase" << std::endl;
149 #endif 151 #endif
150 152
151 if (!m_populated) return; 153 if (!m_populated) return;
152 154
155 free((void *)m_descriptor.identifier);
153 free((void *)m_descriptor.name); 156 free((void *)m_descriptor.name);
154 free((void *)m_descriptor.description); 157 free((void *)m_descriptor.description);
155 free((void *)m_descriptor.maker); 158 free((void *)m_descriptor.maker);
156 free((void *)m_descriptor.copyright); 159 free((void *)m_descriptor.copyright);
157 160
158 for (unsigned int i = 0; i < m_descriptor.parameterCount; ++i) { 161 for (unsigned int i = 0; i < m_descriptor.parameterCount; ++i) {
159 const VampParameterDescriptor *desc = m_descriptor.parameters[i]; 162 const VampParameterDescriptor *desc = m_descriptor.parameters[i];
163 free((void *)desc->identifier);
160 free((void *)desc->name); 164 free((void *)desc->name);
161 free((void *)desc->description); 165 free((void *)desc->description);
162 free((void *)desc->unit); 166 free((void *)desc->unit);
163 if (desc->valueNames) { 167 if (desc->valueNames) {
164 for (unsigned int j = 0; desc->valueNames[j]; ++j) { 168 for (unsigned int j = 0; desc->valueNames[j]; ++j) {
279 #endif 283 #endif
280 284
281 PluginAdapterBase *adapter = lookupAdapter(handle); 285 PluginAdapterBase *adapter = lookupAdapter(handle);
282 if (!adapter) return 0.0; 286 if (!adapter) return 0.0;
283 Plugin::ParameterList &list = adapter->m_parameters; 287 Plugin::ParameterList &list = adapter->m_parameters;
284 return ((Plugin *)handle)->getParameter(list[param].name); 288 return ((Plugin *)handle)->getParameter(list[param].identifier);
285 } 289 }
286 290
287 void 291 void
288 PluginAdapterBase::vampSetParameter(VampPluginHandle handle, 292 PluginAdapterBase::vampSetParameter(VampPluginHandle handle,
289 int param, float value) 293 int param, float value)
293 #endif 297 #endif
294 298
295 PluginAdapterBase *adapter = lookupAdapter(handle); 299 PluginAdapterBase *adapter = lookupAdapter(handle);
296 if (!adapter) return; 300 if (!adapter) return;
297 Plugin::ParameterList &list = adapter->m_parameters; 301 Plugin::ParameterList &list = adapter->m_parameters;
298 ((Plugin *)handle)->setParameter(list[param].name, value); 302 ((Plugin *)handle)->setParameter(list[param].identifier, value);
299 } 303 }
300 304
301 unsigned int 305 unsigned int
302 PluginAdapterBase::vampGetCurrentProgram(VampPluginHandle handle) 306 PluginAdapterBase::vampGetCurrentProgram(VampPluginHandle handle)
303 { 307 {
405 { 409 {
406 #ifdef DEBUG_PLUGIN_ADAPTER 410 #ifdef DEBUG_PLUGIN_ADAPTER
407 std::cerr << "PluginAdapterBase::vampReleaseOutputDescriptor(" << desc << ")" << std::endl; 411 std::cerr << "PluginAdapterBase::vampReleaseOutputDescriptor(" << desc << ")" << std::endl;
408 #endif 412 #endif
409 413
414 if (desc->identifier) free((void *)desc->identifier);
410 if (desc->name) free((void *)desc->name); 415 if (desc->name) free((void *)desc->name);
411 if (desc->description) free((void *)desc->description); 416 if (desc->description) free((void *)desc->description);
412 if (desc->unit) free((void *)desc->unit); 417 if (desc->unit) free((void *)desc->unit);
413 if (desc->hasFixedBinCount && desc->binNames) { 418 if (desc->hasFixedBinCount && desc->binNames) {
414 for (unsigned int i = 0; i < desc->binCount; ++i) { 419 for (unsigned int i = 0; i < desc->binCount; ++i) {
504 { 509 {
505 if (m_pluginOutputs.find(plugin) == m_pluginOutputs.end() || 510 if (m_pluginOutputs.find(plugin) == m_pluginOutputs.end() ||
506 !m_pluginOutputs[plugin]) { 511 !m_pluginOutputs[plugin]) {
507 m_pluginOutputs[plugin] = new Plugin::OutputList 512 m_pluginOutputs[plugin] = new Plugin::OutputList
508 (plugin->getOutputDescriptors()); 513 (plugin->getOutputDescriptors());
509 // std::cerr << "PluginAdapterBase::checkOutputMap: Have " << m_pluginOutputs[plugin]->size() << " outputs for plugin label " << plugin->getName() << std::endl; 514 // std::cerr << "PluginAdapterBase::checkOutputMap: Have " << m_pluginOutputs[plugin]->size() << " outputs for plugin " << plugin->getIdentifier() << std::endl;
510 } 515 }
511 } 516 }
512 517
513 unsigned int 518 unsigned int
514 PluginAdapterBase::getOutputCount(Plugin *plugin) 519 PluginAdapterBase::getOutputCount(Plugin *plugin)
526 (*m_pluginOutputs[plugin])[i]; 531 (*m_pluginOutputs[plugin])[i];
527 532
528 VampOutputDescriptor *desc = (VampOutputDescriptor *) 533 VampOutputDescriptor *desc = (VampOutputDescriptor *)
529 malloc(sizeof(VampOutputDescriptor)); 534 malloc(sizeof(VampOutputDescriptor));
530 535
536 desc->identifier = strdup(od.identifier.c_str());
531 desc->name = strdup(od.name.c_str()); 537 desc->name = strdup(od.name.c_str());
532 desc->description = strdup(od.description.c_str()); 538 desc->description = strdup(od.description.c_str());
533 desc->unit = strdup(od.unit.c_str()); 539 desc->unit = strdup(od.unit.c_str());
534 desc->hasFixedBinCount = od.hasFixedBinCount; 540 desc->hasFixedBinCount = od.hasFixedBinCount;
535 desc->binCount = od.binCount; 541 desc->binCount = od.binCount;