comparison data/fft/FFTDataServer.cpp @ 154:6ec58bb8f729

* Suspend/resume fft data server write activity while reading from a server to repaint the spectrogram display. Makes a significant improvement to the otherwise dreadful responsiveness of spectrogram display.
author Chris Cannam
date Thu, 03 Aug 2006 12:42:15 +0000
parents 8d92611901d3
children ae9be6b6b522
comparison
equal deleted inserted replaced
153:8d92611901d3 154:6ec58bb8f729
20 #include "model/DenseTimeValueModel.h" 20 #include "model/DenseTimeValueModel.h"
21 21
22 #include "system/System.h" 22 #include "system/System.h"
23 23
24 #define DEBUG_FFT_SERVER 1 24 #define DEBUG_FFT_SERVER 1
25 #define DEBUG_FFT_SERVER_FILL 1 25 //#define DEBUG_FFT_SERVER_FILL 1
26 26
27 #ifdef DEBUG_FFT_SERVER_FILL 27 #ifdef DEBUG_FFT_SERVER_FILL
28 #ifndef DEBUG_FFT_SERVER 28 #ifndef DEBUG_FFT_SERVER
29 #define DEBUG_FFT_SERVER 1 29 #define DEBUG_FFT_SERVER 1
30 #endif 30 #endif
411 } 411 }
412 412
413 void 413 void
414 FFTDataServer::resume() 414 FFTDataServer::resume()
415 { 415 {
416 #ifdef DEBUG_FFT_SERVER
417 std::cerr << "FFTDataServer(" << this << "): resume" << std::endl;
418 #endif
416 m_suspended = false; 419 m_suspended = false;
417 m_condition.wakeAll(); 420 m_condition.wakeAll();
418 } 421 }
419 422
420 FFTCache * 423 FFTCache *
551 bool 554 bool
552 FFTDataServer::isColumnReady(size_t x) 555 FFTDataServer::isColumnReady(size_t x)
553 { 556 {
554 if (!haveCache(x)) { 557 if (!haveCache(x)) {
555 if (m_lastUsedCache == -1) { 558 if (m_lastUsedCache == -1) {
559 if (m_suspended) resume();
556 m_fillThread->start(); 560 m_fillThread->start();
557 } 561 }
558 return false; 562 return false;
559 } 563 }
560 564
644 648
645 cache->setColumnAt(col, 649 cache->setColumnAt(col,
646 m_workbuffer, 650 m_workbuffer,
647 m_workbuffer + m_fftSize/2, 651 m_workbuffer + m_fftSize/2,
648 factor); 652 factor);
653
654 if (m_suspended) resume();
649 } 655 }
650 656
651 size_t 657 size_t
652 FFTDataServer::getFillCompletion() const 658 FFTDataServer::getFillCompletion() const
653 { 659 {