changeset 15:6c5466fbea90

* fix failure to pick up all but first plugin's outputs
author cannam
date Thu, 06 Apr 2006 17:23:41 +0000
parents b63909cbbf57
children 61887dda7fe0
files vamp-sdk/PluginAdapter.cpp vamp-sdk/PluginHostAdapter.cpp
diffstat 2 files changed, 28 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/vamp-sdk/PluginAdapter.cpp	Thu Apr 06 16:36:24 2006 +0000
+++ b/vamp-sdk/PluginAdapter.cpp	Thu Apr 06 17:23:41 2006 +0000
@@ -123,8 +123,8 @@
     
     if (!m_adapterMap) {
         m_adapterMap = new AdapterMap;
-        (*m_adapterMap)[&m_descriptor] = this;
     }
+    (*m_adapterMap)[&m_descriptor] = this;
 
     delete plugin;
 
@@ -184,8 +184,15 @@
 PluginAdapterBase::vampInstantiate(const VampPluginDescriptor *desc,
                                    float inputSampleRate)
 {
-    if (!m_adapterMap) return 0;
-    if (m_adapterMap->find(desc) == m_adapterMap->end()) return 0;
+    if (!m_adapterMap) {
+        m_adapterMap = new AdapterMap();
+    }
+
+    if (m_adapterMap->find(desc) == m_adapterMap->end()) {
+        std::cerr << "WARNING: PluginAdapterBase::vampInstantiate: Descriptor " << desc << " not in adapter map" << std::endl;
+        return 0;
+    }
+
     PluginAdapterBase *adapter = (*m_adapterMap)[desc];
     if (desc != &adapter->m_descriptor) return 0;
 
@@ -296,6 +303,9 @@
 PluginAdapterBase::vampGetOutputCount(VampPluginHandle handle)
 {
     PluginAdapterBase *adapter = lookupAdapter(handle);
+
+//    std::cerr << "vampGetOutputCount: handle " << handle << " -> adapter "<< adapter << std::endl;
+
     if (!adapter) return 0;
     return adapter->getOutputCount((Plugin *)handle);
 }
@@ -305,6 +315,9 @@
                                            unsigned int i)
 {
     PluginAdapterBase *adapter = lookupAdapter(handle);
+
+//    std::cerr << "vampGetOutputDescriptor: handle " << handle << " -> adapter "<< adapter << std::endl;
+
     if (!adapter) return 0;
     return adapter->getOutputDescriptor((Plugin *)handle, i);
 }
@@ -392,9 +405,11 @@
 void 
 PluginAdapterBase::checkOutputMap(Plugin *plugin)
 {
-    if (!m_pluginOutputs[plugin]) {
+    if (m_pluginOutputs.find(plugin) == m_pluginOutputs.end() ||
+        !m_pluginOutputs[plugin]) {
         m_pluginOutputs[plugin] = new Plugin::OutputList
             (plugin->getOutputDescriptors());
+//        std::cerr << "PluginAdapterBase::checkOutputMap: Have " << m_pluginOutputs[plugin]->size() << " outputs for plugin label " << plugin->getName() << std::endl;
     }
 }
 
--- a/vamp-sdk/PluginHostAdapter.cpp	Thu Apr 06 16:36:24 2006 +0000
+++ b/vamp-sdk/PluginHostAdapter.cpp	Thu Apr 06 17:23:41 2006 +0000
@@ -44,12 +44,16 @@
     Plugin(inputSampleRate),
     m_descriptor(descriptor)
 {
-    std::cerr << "PluginHostAdapter::PluginHostAdapter (plugin = " << descriptor->name << ")" << std::endl;
+//    std::cerr << "PluginHostAdapter::PluginHostAdapter (plugin = " << descriptor->name << ")" << std::endl;
     m_handle = m_descriptor->instantiate(m_descriptor, inputSampleRate);
+    if (!m_handle) {
+//        std::cerr << "WARNING: PluginHostAdapter: Plugin instantiation failed for plugin " << m_descriptor->name << std::endl;
+    }
 }
 
 PluginHostAdapter::~PluginHostAdapter()
 {
+//    std::cerr << "PluginHostAdapter::~PluginHostAdapter (plugin = " << m_descriptor->name << ")" << std::endl;
     if (m_handle) m_descriptor->cleanup(m_handle);
 }
 
@@ -215,7 +219,10 @@
 PluginHostAdapter::getOutputDescriptors() const
 {
     OutputList list;
-    if (!m_handle) return list;
+    if (!m_handle) {
+//        std::cerr << "PluginHostAdapter::getOutputDescriptors: no handle " << std::endl;
+        return list;
+    }
 
     unsigned int count = m_descriptor->getOutputCount(m_handle);