Mercurial > hg > vamp-plugin-sdk
changeset 268:6579e441f2fe
* Ensure that output descriptors are re-queried after a call to
initialise, setParameter or selectProgram (following "What can
depend on a parameter?" section of programmers guide)
author | cannam |
---|---|
date | Tue, 25 Nov 2008 13:16:07 +0000 |
parents | 93c81a6c917a |
children | 91821a3ab0b6 |
files | src/vamp-hostsdk/PluginBufferingAdapter.cpp src/vamp-sdk/PluginAdapter.cpp |
diffstat | 2 files changed, 45 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/vamp-hostsdk/PluginBufferingAdapter.cpp Tue Nov 25 12:34:45 2008 +0000 +++ b/src/vamp-hostsdk/PluginBufferingAdapter.cpp Tue Nov 25 13:16:07 2008 +0000 @@ -475,6 +475,8 @@ bool success = m_plugin->initialise(m_channels, m_stepSize, m_blockSize); + std::cerr << "PluginBufferingAdapter::initialise: success = " << success << std::endl; + if (success) { // Re-query outputs; properties such as bin count may have // changed on initialise @@ -489,6 +491,8 @@ PluginBufferingAdapter::Impl::getOutputDescriptors() const { if (m_outputs.empty()) { + std::cerr << "PluginBufferingAdapter::getOutputDescriptors: querying anew" << std::endl; + m_outputs = m_plugin->getOutputDescriptors(); }
--- a/src/vamp-sdk/PluginAdapter.cpp Tue Nov 25 12:34:45 2008 +0000 +++ b/src/vamp-sdk/PluginAdapter.cpp Tue Nov 25 13:16:07 2008 +0000 @@ -98,8 +98,10 @@ static void vampReleaseFeatureSet(VampFeatureList *fs); + void checkOutputMap(Plugin *plugin); + void markOutputsChanged(Plugin *plugin); + void cleanup(Plugin *plugin); - void checkOutputMap(Plugin *plugin); unsigned int getOutputCount(Plugin *plugin); VampOutputDescriptor *getOutputDescriptor(Plugin *plugin, unsigned int i); @@ -325,7 +327,7 @@ VampPluginHandle PluginAdapterBase::Impl::vampInstantiate(const VampPluginDescriptor *desc, - float inputSampleRate) + float inputSampleRate) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampInstantiate(" << desc << ")" << std::endl; @@ -372,16 +374,18 @@ int PluginAdapterBase::Impl::vampInitialise(VampPluginHandle handle, - unsigned int channels, - unsigned int stepSize, - unsigned int blockSize) + unsigned int channels, + unsigned int stepSize, + unsigned int blockSize) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampInitialise(" << handle << ", " << channels << ", " << stepSize << ", " << blockSize << ")" << std::endl; #endif - bool result = ((Plugin *)handle)->initialise - (channels, stepSize, blockSize); + Impl *adapter = lookupAdapter(handle); + if (!adapter) return 0; + bool result = ((Plugin *)handle)->initialise(channels, stepSize, blockSize); + adapter->markOutputsChanged((Plugin *)handle); return result ? 1 : 0; } @@ -421,6 +425,7 @@ if (!adapter) return; Plugin::ParameterList &list = adapter->m_parameters; ((Plugin *)handle)->setParameter(list[param].identifier, value); + adapter->markOutputsChanged((Plugin *)handle); } unsigned int @@ -442,7 +447,7 @@ void PluginAdapterBase::Impl::vampSelectProgram(VampPluginHandle handle, - unsigned int program) + unsigned int program) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampSelectProgram(" << handle << ", " << program << ")" << std::endl; @@ -450,8 +455,11 @@ Impl *adapter = lookupAdapter(handle); if (!adapter) return; + Plugin::ProgramList &list = adapter->m_programs; ((Plugin *)handle)->selectProgram(list[program]); + + adapter->markOutputsChanged((Plugin *)handle); } unsigned int @@ -511,7 +519,7 @@ VampOutputDescriptor * PluginAdapterBase::Impl::vampGetOutputDescriptor(VampPluginHandle handle, - unsigned int i) + unsigned int i) { #ifdef DEBUG_PLUGIN_ADAPTER std::cerr << "PluginAdapterBase::Impl::vampGetOutputDescriptor(" << handle << ", " << i << ")" << std::endl; @@ -559,8 +567,7 @@ Impl *adapter = lookupAdapter(handle); if (!adapter) return 0; - return adapter->process((Plugin *)handle, - inputBuffers, sec, nsec); + return adapter->process((Plugin *)handle, inputBuffers, sec, nsec); } VampFeatureList * @@ -628,26 +635,46 @@ void PluginAdapterBase::Impl::checkOutputMap(Plugin *plugin) { - if (m_pluginOutputs.find(plugin) == m_pluginOutputs.end() || - !m_pluginOutputs[plugin]) { + OutputMap::iterator i = m_pluginOutputs.find(plugin); + + if (i == m_pluginOutputs.end() || !i->second) { + m_pluginOutputs[plugin] = new Plugin::OutputList (plugin->getOutputDescriptors()); + // std::cerr << "PluginAdapterBase::Impl::checkOutputMap: Have " << m_pluginOutputs[plugin]->size() << " outputs for plugin " << plugin->getIdentifier() << std::endl; } } +void +PluginAdapterBase::Impl::markOutputsChanged(Plugin *plugin) +{ + OutputMap::iterator i = m_pluginOutputs.find(plugin); + +// std::cerr << "PluginAdapterBase::Impl::markOutputsChanged" << std::endl; + + if (i != m_pluginOutputs.end()) { + + Plugin::OutputList *list = i->second; + m_pluginOutputs.erase(i); + delete list; + } +} + unsigned int PluginAdapterBase::Impl::getOutputCount(Plugin *plugin) { checkOutputMap(plugin); + return m_pluginOutputs[plugin]->size(); } VampOutputDescriptor * PluginAdapterBase::Impl::getOutputDescriptor(Plugin *plugin, - unsigned int i) + unsigned int i) { checkOutputMap(plugin); + Plugin::OutputDescriptor &od = (*m_pluginOutputs[plugin])[i];