comparison layer/SpectrogramLayer.cpp @ 178:05015e717a0d

* Somewhat better handling of running out of memory or disc space
author Chris Cannam
date Mon, 13 Nov 2006 14:48:57 +0000
parents ad7df5989d08
children 29f01de27db4
comparison
equal deleted inserted replaced
177:dbd34ff746c7 178:05015e717a0d
27 #include <QImage> 27 #include <QImage>
28 #include <QPixmap> 28 #include <QPixmap>
29 #include <QRect> 29 #include <QRect>
30 #include <QTimer> 30 #include <QTimer>
31 #include <QApplication> 31 #include <QApplication>
32 #include <QMessageBox>
32 33
33 #include <iostream> 34 #include <iostream>
34 35
35 #include <cassert> 36 #include <cassert>
36 #include <cmath> 37 #include <cmath>
1574 if (!m_model) return 0; 1575 if (!m_model) return 0;
1575 1576
1576 size_t fftSize = getFFTSize(v); 1577 size_t fftSize = getFFTSize(v);
1577 1578
1578 if (m_fftModels.find(v) != m_fftModels.end()) { 1579 if (m_fftModels.find(v) != m_fftModels.end()) {
1580 if (m_fftModels[v].first == 0) return 0;
1579 if (m_fftModels[v].first->getHeight() != fftSize / 2) { 1581 if (m_fftModels[v].first->getHeight() != fftSize / 2) {
1580 delete m_fftModels[v].first; 1582 delete m_fftModels[v].first;
1581 m_fftModels.erase(v); 1583 m_fftModels.erase(v);
1582 } 1584 }
1583 } 1585 }
1590 m_windowSize, 1592 m_windowSize,
1591 getWindowIncrement(), 1593 getWindowIncrement(),
1592 fftSize, 1594 fftSize,
1593 true, 1595 true,
1594 m_candidateFillStartFrame); 1596 m_candidateFillStartFrame);
1597
1598 if (!model->isOK()) {
1599 QMessageBox::critical
1600 (0, tr("FFT cache failed"),
1601 tr("Failed to create the FFT model for this spectrogram.\n"
1602 "There may be insufficient memory or disc space to continue."));
1603 delete model;
1604 m_fftModels[v] = FFTFillPair(0, 0);
1605 return 0;
1606 }
1595 1607
1596 m_fftModels[v] = FFTFillPair(model, 0); 1608 m_fftModels[v] = FFTFillPair(model, 0);
1597 1609
1598 model->resume(); 1610 model->resume();
1599 1611