changeset 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
files data/fft/FFTDataServer.cpp data/fft/FFTDataServer.h data/fileio/MatrixFile.cpp data/model/FFTModel.h
diffstat 4 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/data/fft/FFTDataServer.cpp	Wed Aug 02 16:42:17 2006 +0000
+++ b/data/fft/FFTDataServer.cpp	Thu Aug 03 12:42:15 2006 +0000
@@ -22,7 +22,7 @@
 #include "system/System.h"
 
 #define DEBUG_FFT_SERVER 1
-#define DEBUG_FFT_SERVER_FILL 1
+//#define DEBUG_FFT_SERVER_FILL 1
 
 #ifdef DEBUG_FFT_SERVER_FILL
 #ifndef DEBUG_FFT_SERVER
@@ -413,6 +413,9 @@
 void
 FFTDataServer::resume()
 {
+#ifdef DEBUG_FFT_SERVER
+    std::cerr << "FFTDataServer(" << this << "): resume" << std::endl;
+#endif
     m_suspended = false;
     m_condition.wakeAll();
 }
@@ -553,6 +556,7 @@
 {
     if (!haveCache(x)) {
         if (m_lastUsedCache == -1) {
+            if (m_suspended) resume();
             m_fillThread->start();
         }
         return false;
@@ -646,6 +650,8 @@
                        m_workbuffer,
                        m_workbuffer + m_fftSize/2,
                        factor);
+
+    if (m_suspended) resume();
 }    
 
 size_t
--- a/data/fft/FFTDataServer.h	Wed Aug 02 16:42:17 2006 +0000
+++ b/data/fft/FFTDataServer.h	Thu Aug 03 12:42:15 2006 +0000
@@ -74,6 +74,7 @@
     bool       isColumnReady(size_t x);
 
     void       suspend();
+    void       resume(); // also happens automatically if new data needed
 
     // Convenience functions:
 
@@ -131,7 +132,6 @@
 
     int m_lastUsedCache;
     FFTCache *getCache(size_t x, size_t &col) {
-        if (m_suspended) resume();
         col   = x % m_cacheWidth;
         int c = x / m_cacheWidth;
         // The only use of m_lastUsedCache without a lock is to
@@ -179,7 +179,6 @@
 
     void deleteProcessingData();
     void fillColumn(size_t x);
-    void resume();
 
     QString generateFileBasename() const;
     static QString generateFileBasename(const DenseTimeValueModel *model,
--- a/data/fileio/MatrixFile.cpp	Wed Aug 02 16:42:17 2006 +0000
+++ b/data/fileio/MatrixFile.cpp	Thu Aug 03 12:42:15 2006 +0000
@@ -32,8 +32,8 @@
 #include <QFileInfo>
 #include <QDir>
 
-#define DEBUG_MATRIX_FILE 1
-#define DEBUG_MATRIX_FILE_READ_SET 1
+//#define DEBUG_MATRIX_FILE 1
+//#define DEBUG_MATRIX_FILE_READ_SET 1
 
 #ifdef DEBUG_MATRIX_FILE_READ_SET
 #ifndef DEBUG_MATRIX_FILE
--- a/data/model/FFTModel.h	Wed Aug 02 16:42:17 2006 +0000
+++ b/data/model/FFTModel.h	Thu Aug 03 12:42:15 2006 +0000
@@ -100,6 +100,9 @@
 
     virtual Model *clone() const;
 
+    virtual void suspend() { m_server->suspend(); }
+    virtual void resume() { m_server->resume(); }
+
 private:
     FFTModel(const FFTModel &);
     FFTModel &operator=(const FFTModel &); // not implemented