# HG changeset patch # User Chris Cannam # Date 1159887710 0 # Node ID 75c5951cf9d74b58bca416681dbbe2b0c4e169a2 # Parent f18093617b7872bd35c3df3cce32d60efe1653bc * Some fixes to updating of writable wave file models diff -r f18093617b78 -r 75c5951cf9d7 transform/RealTimePluginTransform.cpp --- a/transform/RealTimePluginTransform.cpp Tue Oct 03 14:17:37 2006 +0000 +++ b/transform/RealTimePluginTransform.cpp Tue Oct 03 15:01:50 2006 +0000 @@ -145,24 +145,28 @@ size_t got = 0; if (channelCount == 1) { - got = input->getValues - (m_context.channel, blockFrame, blockFrame + blockSize, buffers[0]); - while (got < blockSize) { - buffers[0][got++] = 0.0; - } - if (m_context.channel == -1 && channelCount > 1) { - // use mean instead of sum, as plugin input - for (size_t i = 0; i < got; ++i) { - buffers[0][i] /= channelCount; + if (buffers && buffers[0]) { + got = input->getValues + (m_context.channel, blockFrame, blockFrame + blockSize, buffers[0]); + while (got < blockSize) { + buffers[0][got++] = 0.0; } - } + if (m_context.channel == -1 && channelCount > 1) { + // use mean instead of sum, as plugin input + for (size_t i = 0; i < got; ++i) { + buffers[0][i] /= channelCount; + } + } + } } else { for (size_t ch = 0; ch < channelCount; ++ch) { - got = input->getValues - (ch, blockFrame, blockFrame + blockSize, buffers[ch]); - while (got < blockSize) { - buffers[ch][got++] = 0.0; - } + if (buffers && buffers[ch]) { + got = input->getValues + (ch, blockFrame, blockFrame + blockSize, buffers[ch]); + while (got < blockSize) { + buffers[ch][got++] = 0.0; + } + } } } @@ -183,17 +187,24 @@ float **buffers = m_plugin->getAudioOutputBuffers(); - if (blockFrame >= latency) { - wwfm->addSamples(buffers, blockSize); - } else if (blockFrame + blockSize >= latency) { - size_t offset = latency - blockFrame; - size_t count = blockSize - offset; - float **tmp = new float *[channelCount]; - for (size_t c = 0; c < channelCount; ++c) { - tmp[c] = buffers[c] + offset; + if (buffers) { + + //!!! This will fail if any buffers[c] is null or + //uninitialised. The plugin instance should ensure + //that that can't happen -- but it doesn't + + if (blockFrame >= latency) { + wwfm->addSamples(buffers, blockSize); + } else if (blockFrame + blockSize >= latency) { + size_t offset = latency - blockFrame; + size_t count = blockSize - offset; + float **tmp = new float *[channelCount]; + for (size_t c = 0; c < channelCount; ++c) { + tmp[c] = buffers[c] + offset; + } + wwfm->addSamples(tmp, count); + delete[] tmp; } - wwfm->addSamples(tmp, count); - delete[] tmp; } }