# HG changeset patch # User Chris Cannam # Date 1172763327 0 # Node ID 2f7d27648806032dc95de4383f57b7d95f4d803e # Parent 2b40f83e762775eb075a858c5ee28af823527ac8 * Fix real-time plugin corruption when getLatency is called for some plugins * Other minor changes diff -r 2b40f83e7627 -r 2f7d27648806 plugin/DSSIPluginInstance.cpp --- a/plugin/DSSIPluginInstance.cpp Thu Mar 01 12:15:08 2007 +0000 +++ b/plugin/DSSIPluginInstance.cpp Thu Mar 01 15:35:27 2007 +0000 @@ -268,7 +268,14 @@ #endif if (m_latencyPort) { - if (!m_run) run(Vamp::RealTime::zeroTime); + if (!m_run) { + for (int i = 0; i < getAudioInputCount(); ++i) { + for (int j = 0; j < m_blockSize; ++j) { + m_inputBuffers[i][j] = 0.f; + } + } + run(Vamp::RealTime::zeroTime); + } latency = (size_t)(*m_latencyPort + 0.1); } diff -r 2b40f83e7627 -r 2f7d27648806 plugin/LADSPAPluginInstance.cpp --- a/plugin/LADSPAPluginInstance.cpp Thu Mar 01 12:15:08 2007 +0000 +++ b/plugin/LADSPAPluginInstance.cpp Thu Mar 01 15:35:27 2007 +0000 @@ -204,8 +204,10 @@ { for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { if (id == m_descriptor->PortNames[m_controlPortsIn[i].first]) { +#ifdef DEBUG_LADSPA std::cerr << "LADSPAPluginInstance::setParameter: Found id " << id << " at control port " << i << std::endl; +#endif setParameterValue(i, value); break; } @@ -222,10 +224,10 @@ // Discover ports numbers and identities // - for (unsigned long i = 0; i < m_descriptor->PortCount; ++i) - { - if (LADSPA_IS_PORT_AUDIO(m_descriptor->PortDescriptors[i])) - { + for (unsigned long i = 0; i < m_descriptor->PortCount; ++i) { + + if (LADSPA_IS_PORT_AUDIO(m_descriptor->PortDescriptors[i])) { + if (LADSPA_IS_PORT_INPUT(m_descriptor->PortDescriptors[i])) { #ifdef DEBUG_LADSPA std::cerr << "LADSPAPluginInstance::init: port " << i << " is audio in" << std::endl; @@ -237,18 +239,20 @@ #endif m_audioPortsOut.push_back(i); } - } - else - if (LADSPA_IS_PORT_CONTROL(m_descriptor->PortDescriptors[i])) - { + + } else if (LADSPA_IS_PORT_CONTROL(m_descriptor->PortDescriptors[i])) { + if (LADSPA_IS_PORT_INPUT(m_descriptor->PortDescriptors[i])) { + #ifdef DEBUG_LADSPA std::cerr << "LADSPAPluginInstance::init: port " << i << " is control in" << std::endl; #endif LADSPA_Data *data = new LADSPA_Data(0.0); m_controlPortsIn.push_back( std::pair(i, data)); + } else { + #ifdef DEBUG_LADSPA std::cerr << "LADSPAPluginInstance::init: port " << i << " is control out" << std::endl; #endif @@ -262,6 +266,7 @@ #endif m_latencyPort = data; } + } } #ifdef DEBUG_LADSPA @@ -285,7 +290,14 @@ LADSPAPluginInstance::getLatency() { if (m_latencyPort) { - if (!m_run) run(Vamp::RealTime::zeroTime); + if (!m_run) { + for (int i = 0; i < getAudioInputCount(); ++i) { + for (int j = 0; j < m_blockSize; ++j) { + m_inputBuffers[i][j] = 0.f; + } + } + run(Vamp::RealTime::zeroTime); + } if (*m_latencyPort > 0) return (size_t)*m_latencyPort; } return 0; @@ -506,8 +518,11 @@ { if (!m_descriptor || !m_descriptor->run) return; + int inbuf = 0, outbuf = 0; + for (std::vector::iterator hi = m_instanceHandles.begin(); hi != m_instanceHandles.end(); ++hi) { + m_descriptor->run(*hi, m_blockSize); }