diff data/model/WaveFileModel.cpp @ 265:e08f486e8d8c

* Enable threaded decoding for Ogg and MP3 files. Needs some work on reducing updates to the overview widget
author Chris Cannam
date Wed, 06 Jun 2007 16:24:55 +0000
parents 96a6dd889c68
children 2268963dabd1
line wrap: on
line diff
--- a/data/model/WaveFileModel.cpp	Fri Jun 01 13:56:35 2007 +0000
+++ b/data/model/WaveFileModel.cpp	Wed Jun 06 16:24:55 2007 +0000
@@ -96,7 +96,15 @@
 {
     bool ready = (isOK() && (m_fillThread == 0));
     double c = double(m_lastFillExtent) / double(getEndFrame() - getStartFrame());
-    if (completion) *completion = int(c * 100.0 + 0.01);
+    if (completion) {
+        *completion = int(c * 100.0 + 0.01);
+        if (m_reader) {
+            int decodeCompletion = m_reader->getDecodeCompletion();
+//            std::cerr << "decodeCompletion " << decodeCompletion << ", completion " << *completion << std::endl;
+//            if (decodeCompletion < *completion) *completion = decodeCompletion;
+            if (decodeCompletion < 100) *completion = decodeCompletion;
+        }
+    }
 #ifdef DEBUG_WAVE_FILE_MODEL
     std::cerr << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << std::endl;
 #endif
@@ -486,10 +494,14 @@
 
         while (frame < m_frameCount) {
 
+//            std::cerr << "WaveFileModel::fill inner loop: frame = " << frame << ", count = " << m_frameCount << ", blocksize " << readBlockSize << std::endl;
+
             if (updating && (frame + readBlockSize > m_frameCount)) break;
 
             m_model.m_reader->getInterleavedFrames(frame, readBlockSize, block);
 
+//            std::cerr << "block is " << block.size() << std::endl;
+
             for (size_t i = 0; i < readBlockSize; ++i) {
 		
                 if (channels * i + channels > block.size()) break;
@@ -538,9 +550,12 @@
             m_fillExtent = frame;
         }
 
+//        std::cerr << "WaveFileModel: inner loop ended" << std::endl;
+
         first = false;
         if (m_model.m_exiting) break;
         if (updating) {
+//            std::cerr << "sleeping..." << std::endl;
             sleep(1);
         }
     }