# HG changeset patch # User Chris Cannam # Date 1233779951 0 # Node ID 3f9fddc890e0701718921e77bdb11f9288c03d7d # Parent a926fca1f280690fb2d92fecb1f68c21c3f9afa3 * fix deadlock in fft memory cache usage diff -r a926fca1f280 -r 3f9fddc890e0 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Wed Feb 04 15:03:42 2009 +0000 +++ b/layer/SpectrogramLayer.cpp Wed Feb 04 20:39:11 2009 +0000 @@ -45,7 +45,7 @@ #include #include -#define DEBUG_SPECTROGRAM_REPAINT 1 +//#define DEBUG_SPECTROGRAM_REPAINT 1 SpectrogramLayer::SpectrogramLayer(Configuration config) : m_model(0), @@ -2216,8 +2216,10 @@ else if (x > x0 + w + 2) { rightBoundaryFrame = f; break; } } } +#ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "Left: crop: " << leftCropFrame << " (bin " << leftCropFrame/increment << "); boundary: " << leftBoundaryFrame << " (bin " << leftBoundaryFrame/increment << ")" << endl; cerr << "Right: crop: " << rightCropFrame << " (bin " << rightCropFrame/increment << "); boundary: " << rightBoundaryFrame << " (bin " << rightBoundaryFrame/increment << ")" << endl; +#endif bufwid = (rightBoundaryFrame - leftBoundaryFrame) / increment; @@ -2329,17 +2331,21 @@ if (bufferBinResolution) { int scaledLeft = v->getXForFrame(leftBoundaryFrame); int scaledRight = v->getXForFrame(rightBoundaryFrame); +#ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "Rescaling image from " << bufwid << "x" << h << " to " << scaledRight-scaledLeft << "x" << h << endl; +#endif QImage scaled = m_drawBuffer.scaled (scaledRight - scaledLeft, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); // cachePainter.setRenderHint(QPainter::SmoothPixmapTransform, true); int scaledLeftCrop = v->getXForFrame(leftCropFrame); int scaledRightCrop = v->getXForFrame(rightCropFrame); +#ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "Drawing image region of width " << scaledRightCrop - scaledLeftCrop << " to " << scaledLeftCrop << " from " << scaledLeftCrop - scaledLeft << endl; +#endif cachePainter.drawImage (QRect(scaledLeftCrop, 0, scaledRightCrop - scaledLeftCrop, h), @@ -2436,14 +2442,18 @@ int minbin = binfory[0]; int maxbin = binfory[h-1]; +#ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "minbin " << minbin << ", maxbin " << maxbin << "; w " << w << ", h " << h << endl; +#endif if (minbin < 0) minbin = 0; if (maxbin < 0) maxbin = minbin+1; DenseThreeDimensionalModel *sourceModel = 0; FFTModel *fft = 0; int divisor = 1; +#ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "Note: bin display = " << m_binDisplay << ", w = " << w << ", binforx[" << w-1 << "] = " << binforx[w-1] << ", binforx[0] = " << binforx[0] << endl; +#endif if (usePeaksCache) { //!!! sourceModel = getPeakCache(v); divisor = 8;//!!! @@ -2488,10 +2498,14 @@ if (sx != psx) { if (fft) { +#ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "Retrieving column " << sx << " from fft directly" << endl; +#endif fft->getMagnitudesAt(sx, values, minbin, maxbin - minbin + 1); } else { +#ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "Retrieving column " << sx << " from peaks cache" << endl; +#endif c = sourceModel->getColumn(sx); } psx = sx;