diff data/fileio/MP3FileReader.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 260032c26c4f
children 822bd7fd526c
line wrap: on
line diff
--- a/data/fileio/MP3FileReader.cpp	Fri Jun 01 13:56:35 2007 +0000
+++ b/data/fileio/MP3FileReader.cpp	Wed Jun 06 16:24:55 2007 +0000
@@ -42,6 +42,7 @@
     m_bitrateDenom = 0;
     m_frameCount = 0;
     m_cancelled = false;
+    m_completion = 0;
     m_done = false;
     m_progress = 0;
 
@@ -127,6 +128,7 @@
 MP3FileReader::~MP3FileReader()
 {
     if (m_decodeThread) {
+        m_cancelled = true;
         m_decodeThread->wait();
         delete m_decodeThread;
     }
@@ -145,6 +147,7 @@
     if (m_reader->isDecodeCacheInitialised()) m_reader->finishDecodeCache();
 
     m_reader->m_done = true;
+    m_reader->m_completion = 100;
 } 
 
 bool
@@ -210,10 +213,11 @@
         double duration = double(m_fileSize * 8) / bitrate;
         double elapsed = double(m_frameCount) / m_sampleRate;
         double percent = ((elapsed * 100.0) / duration);
+        int progress = int(percent);
+        if (progress < 1) progress = 1;
+        if (progress > 99) progress = 99;
+        m_completion = progress;
         if (m_progress) {
-            int progress = int(percent);
-            if (progress < 1) progress = 1;
-            if (progress > 99) progress = 99;
             if (progress > m_progress->value()) {
                 m_progress->setValue(progress);
                 m_progress->show();