Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/PluginAdapter.cpp @ 13:85801331454c
* Make static adapter map a pointer to avoid any confusion about static
destructor ordering
author | cannam |
---|---|
date | Thu, 06 Apr 2006 16:35:49 +0000 |
parents | a3d35e11c3fe |
children | 6c5466fbea90 |
comparison
equal
deleted
inserted
replaced
12:a3d35e11c3fe | 13:85801331454c |
---|---|
119 m_descriptor.releaseOutputDescriptor = vampReleaseOutputDescriptor; | 119 m_descriptor.releaseOutputDescriptor = vampReleaseOutputDescriptor; |
120 m_descriptor.process = vampProcess; | 120 m_descriptor.process = vampProcess; |
121 m_descriptor.getRemainingFeatures = vampGetRemainingFeatures; | 121 m_descriptor.getRemainingFeatures = vampGetRemainingFeatures; |
122 m_descriptor.releaseFeatureSet = vampReleaseFeatureSet; | 122 m_descriptor.releaseFeatureSet = vampReleaseFeatureSet; |
123 | 123 |
124 m_adapterMap[&m_descriptor] = this; | 124 if (!m_adapterMap) { |
125 m_adapterMap = new AdapterMap; | |
126 (*m_adapterMap)[&m_descriptor] = this; | |
127 } | |
125 | 128 |
126 delete plugin; | 129 delete plugin; |
127 | 130 |
128 m_populated = true; | 131 m_populated = true; |
129 return &m_descriptor; | 132 return &m_descriptor; |
155 for (unsigned int i = 0; i < m_descriptor.programCount; ++i) { | 158 for (unsigned int i = 0; i < m_descriptor.programCount; ++i) { |
156 free((void *)m_descriptor.programs[i]); | 159 free((void *)m_descriptor.programs[i]); |
157 } | 160 } |
158 free((void *)m_descriptor.programs); | 161 free((void *)m_descriptor.programs); |
159 | 162 |
160 m_adapterMap.erase(&m_descriptor); | 163 if (m_adapterMap) { |
164 | |
165 m_adapterMap->erase(&m_descriptor); | |
166 | |
167 if (m_adapterMap->empty()) { | |
168 delete m_adapterMap; | |
169 m_adapterMap = 0; | |
170 } | |
171 } | |
161 } | 172 } |
162 | 173 |
163 PluginAdapterBase * | 174 PluginAdapterBase * |
164 PluginAdapterBase::lookupAdapter(VampPluginHandle handle) | 175 PluginAdapterBase::lookupAdapter(VampPluginHandle handle) |
165 { | 176 { |
166 AdapterMap::const_iterator i = m_adapterMap.find(handle); | 177 if (!m_adapterMap) return 0; |
167 if (i == m_adapterMap.end()) return 0; | 178 AdapterMap::const_iterator i = m_adapterMap->find(handle); |
179 if (i == m_adapterMap->end()) return 0; | |
168 return i->second; | 180 return i->second; |
169 } | 181 } |
170 | 182 |
171 VampPluginHandle | 183 VampPluginHandle |
172 PluginAdapterBase::vampInstantiate(const VampPluginDescriptor *desc, | 184 PluginAdapterBase::vampInstantiate(const VampPluginDescriptor *desc, |
173 float inputSampleRate) | 185 float inputSampleRate) |
174 { | 186 { |
175 if (m_adapterMap.find(desc) == m_adapterMap.end()) return 0; | 187 if (!m_adapterMap) return 0; |
176 PluginAdapterBase *adapter = m_adapterMap[desc]; | 188 if (m_adapterMap->find(desc) == m_adapterMap->end()) return 0; |
189 PluginAdapterBase *adapter = (*m_adapterMap)[desc]; | |
177 if (desc != &adapter->m_descriptor) return 0; | 190 if (desc != &adapter->m_descriptor) return 0; |
178 | 191 |
179 Plugin *plugin = adapter->createPlugin(inputSampleRate); | 192 Plugin *plugin = adapter->createPlugin(inputSampleRate); |
180 if (plugin) { | 193 if (plugin) { |
181 m_adapterMap[plugin] = adapter; | 194 (*m_adapterMap)[plugin] = adapter; |
182 } | 195 } |
183 | 196 |
184 return plugin; | 197 return plugin; |
185 } | 198 } |
186 | 199 |
361 | 374 |
362 if (m_pluginOutputs.find(plugin) != m_pluginOutputs.end()) { | 375 if (m_pluginOutputs.find(plugin) != m_pluginOutputs.end()) { |
363 delete m_pluginOutputs[plugin]; | 376 delete m_pluginOutputs[plugin]; |
364 m_pluginOutputs.erase(plugin); | 377 m_pluginOutputs.erase(plugin); |
365 } | 378 } |
366 m_adapterMap.erase(plugin); | 379 |
380 if (m_adapterMap) { | |
381 m_adapterMap->erase(plugin); | |
382 | |
383 if (m_adapterMap->empty()) { | |
384 delete m_adapterMap; | |
385 m_adapterMap = 0; | |
386 } | |
387 } | |
388 | |
367 delete ((Plugin *)plugin); | 389 delete ((Plugin *)plugin); |
368 } | 390 } |
369 | 391 |
370 void | 392 void |
371 PluginAdapterBase::checkOutputMap(Plugin *plugin) | 393 PluginAdapterBase::checkOutputMap(Plugin *plugin) |
594 (m_fs[plugin][n].features[j].values, sz * sizeof(float)); | 616 (m_fs[plugin][n].features[j].values, sz * sizeof(float)); |
595 | 617 |
596 m_fvsizes[plugin][n][j] = sz; | 618 m_fvsizes[plugin][n][j] = sz; |
597 } | 619 } |
598 | 620 |
599 PluginAdapterBase::AdapterMap | 621 PluginAdapterBase::AdapterMap * |
600 PluginAdapterBase::m_adapterMap; | 622 PluginAdapterBase::m_adapterMap = 0; |
601 | 623 |
602 } | 624 } |
603 | 625 |