# HG changeset patch # User Chris Cannam # Date 1171475526 0 # Node ID 03a24547cf3c0c91e3f0894f458589cf77c57e45 # Parent 0031495aba07c4579fba8ed0a9a0e33dbc96a337 * Fix crash in short spectrogram paint * Fix incorrect apparent end point for waveforms diff -r 0031495aba07 -r 03a24547cf3c data/fileio/WavFileReader.cpp --- a/data/fileio/WavFileReader.cpp Mon Feb 12 18:15:49 2007 +0000 +++ b/data/fileio/WavFileReader.cpp Wed Feb 14 17:52:06 2007 +0000 @@ -151,6 +151,9 @@ } for (size_t i = 0; i < count * m_fileInfo.channels; ++i) { + if (i >= m_bufsiz) { + std::cerr << "INTERNAL ERROR: WavFileReader::getInterleavedFrames: " << i << " >= " << m_bufsiz << std::endl; + } results.push_back(m_buffer[i]); } diff -r 0031495aba07 -r 03a24547cf3c data/model/WaveFileModel.cpp --- a/data/model/WaveFileModel.cpp Mon Feb 12 18:15:49 2007 +0000 +++ b/data/model/WaveFileModel.cpp Wed Feb 14 17:52:06 2007 +0000 @@ -300,7 +300,7 @@ float max = 0.0, min = 0.0, total = 0.0; size_t i = 0, count = 0; - //cerr << "blockSize is " << blockSize << ", cacheBlock " << cacheBlock << ", start " << start << ", end " << end << ", power is " << power << ", div is " << div << ", startIndex " << startIndex << ", endIndex " << endIndex << endl; + cerr << "blockSize is " << blockSize << ", cacheBlock " << cacheBlock << ", start " << start << ", end " << end << " (frame count " << getFrameCount() << "), power is " << power << ", div is " << div << ", startIndex " << startIndex << ", endIndex " << endIndex << endl; for (i = 0; i < endIndex - startIndex; ) { @@ -327,7 +327,7 @@ } } - //cerr << "returning " << ranges.size() << " ranges" << endl; + cerr << "returning " << ranges.size() << " ranges" << endl; return; } @@ -474,13 +474,14 @@ for (size_t i = 0; i < readBlockSize; ++i) { + if (channels * i + channels > block.size()) break; + for (size_t ch = 0; ch < size_t(channels); ++ch) { size_t index = channels * i + ch; - if (index >= block.size()) continue; float sample = block[index]; - for (size_t ct = 0; ct < 2; ++ct) { + for (size_t ct = 0; ct < 2; ++ct) { // cache type size_t rangeIndex = ch * 2 + ct; @@ -495,14 +496,18 @@ } QMutexLocker locker(&m_model.m_mutex); + for (size_t ct = 0; ct < 2; ++ct) { + if (++count[ct] == cacheBlockSize[ct]) { + for (size_t ch = 0; ch < size_t(channels); ++ch) { size_t rangeIndex = ch * 2 + ct; range[rangeIndex].absmean /= count[ct]; m_model.m_cache[ct].push_back(range[rangeIndex]); range[rangeIndex] = Range(); } + count[ct] = 0; } } @@ -525,14 +530,18 @@ if (!m_model.m_exiting) { QMutexLocker locker(&m_model.m_mutex); + for (size_t ct = 0; ct < 2; ++ct) { + if (count[ct] > 0) { + for (size_t ch = 0; ch < size_t(channels); ++ch) { size_t rangeIndex = ch * 2 + ct; range[rangeIndex].absmean /= count[ct]; m_model.m_cache[ct].push_back(range[rangeIndex]); range[rangeIndex] = Range(); } + count[ct] = 0; } diff -r 0031495aba07 -r 03a24547cf3c system/System.h --- a/system/System.h Mon Feb 12 18:15:49 2007 +0000 +++ b/system/System.h Wed Feb 14 17:52:06 2007 +0000 @@ -65,6 +65,9 @@ #define MLOCK(a,b) ::mlock((a),(b)) #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0) #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0); +//#define MLOCK(a,b) 1 +//#define MUNLOCK(a,b) 1 +//#define MUNLOCK_SAMPLEBLOCK(a) 1 #define DLOPEN(a,b) dlopen((a).toStdString().c_str(),(b)) #define DLSYM(a,b) dlsym((a),(b))