comparison layer/SpectrogramLayer.cpp @ 48:97b0643bd799

* A bit more work on main window / document / commands stuff. This is still pretty unstable. * Enable CSV file reader also to read files with other separators (e.g. .lab files with space separators) * Show "(R)" on waveform display when resampling during playback * Add ability to import additional audio files (can't process them yet) * Fixes to spectrogram cache for multiple views * Fix to avoid floating-point exception in sparse model when resolution not set yet
author Chris Cannam
date Mon, 06 Mar 2006 17:20:25 +0000
parents 2e2ad8510e52
children 128ebfeeebee
comparison
equal deleted inserted replaced
47:2e2ad8510e52 48:97b0643bd799
1268 1268
1269 bool interrupted = false; 1269 bool interrupted = false;
1270 1270
1271 // std::cerr << "SpectrogramLayer::CacheFillThread::run in loop" << std::endl; 1271 // std::cerr << "SpectrogramLayer::CacheFillThread::run in loop" << std::endl;
1272 1272
1273 /*!!! Need a way of finding out whether this layer is dormant in 1273 bool haveUndormantViews = false;
1274 all the views that are currently visible... or not 1274
1275 1275 for (std::map<const void *, bool>::iterator i =
1276 if (m_layer.m_dormancy[) { 1276 m_layer.m_dormancy.begin();
1277 */ 1277 i != m_layer.m_dormancy.end(); ++i) {
1278 if (0) { //!!! 1278
1279 if (!i->second) {
1280 haveUndormantViews = true;
1281 break;
1282 }
1283 }
1284
1285 if (!haveUndormantViews) {
1286
1287 if (m_layer.m_cacheInvalid && m_layer.m_cache) {
1288 std::cerr << "All views dormant, freeing spectrogram cache"
1289 << std::endl;
1279 1290
1280 if (m_layer.m_cacheInvalid) {
1281 delete m_layer.m_cache; 1291 delete m_layer.m_cache;
1282 m_layer.m_cache = 0; 1292 m_layer.m_cache = 0;
1283 } 1293 }
1284 1294
1285 } else if (m_layer.m_model && m_layer.m_cacheInvalid) { 1295 } else if (m_layer.m_model && m_layer.m_cacheInvalid) {
1286 1296
1287 // std::cerr << "SpectrogramLayer::CacheFillThread::run: something to do" << std::endl; 1297 // std::cerr << "SpectrogramLayer::CacheFillThread::run: something to do" << std::endl;
1288 1298
1289 while (!m_layer.m_model->isReady()) { 1299 while (!m_layer.m_model->isReady()) {
1290 m_layer.m_condition.wait(&m_layer.m_mutex, 100); 1300 m_layer.m_condition.wait(&m_layer.m_mutex, 100);
1301 if (m_layer.m_exiting) break;
1291 } 1302 }
1303
1304 if (m_layer.m_exiting) break;
1292 1305
1293 m_layer.m_cacheInvalid = false; 1306 m_layer.m_cacheInvalid = false;
1294 m_fillExtent = 0; 1307 m_fillExtent = 0;
1295 m_fillCompletion = 0; 1308 m_fillCompletion = 0;
1296 1309
1697 if (!m_model || !m_model->isOK() || !m_model->isReady()) { 1710 if (!m_model || !m_model->isOK() || !m_model->isReady()) {
1698 return; 1711 return;
1699 } 1712 }
1700 1713
1701 if (isLayerDormant(v)) { 1714 if (isLayerDormant(v)) {
1702 std::cerr << "SpectrogramLayer::paint(): Layer is dormant" << std::endl; 1715 std::cerr << "SpectrogramLayer::paint(): Layer is dormant, making it undormant again" << std::endl;
1703 return; 1716 }
1704 } 1717
1718 // Need to do this even if !isLayerDormant, as that could mean v
1719 // is not in the dormancy map at all -- we need it to be present
1720 // and accountable for when determining whether we need the cache
1721 // in the cache-fill thread above.
1722 m_dormancy[v] = false;
1705 1723
1706 #ifdef DEBUG_SPECTROGRAM_REPAINT 1724 #ifdef DEBUG_SPECTROGRAM_REPAINT
1707 std::cerr << "SpectrogramLayer::paint(): About to lock" << std::endl; 1725 std::cerr << "SpectrogramLayer::paint(): About to lock" << std::endl;
1708 #endif 1726 #endif
1709 1727