Mercurial > hg > svcore
diff data/fileio/MP3FileReader.cpp @ 357:b92513201610
* better progress reporting in FileSource
* fix set-to-default for audio dials with mappers
author | Chris Cannam |
---|---|
date | Fri, 04 Jan 2008 17:08:10 +0000 |
parents | edda24bb85fc |
children | f1ff248a793e |
line wrap: on
line diff
--- a/data/fileio/MP3FileReader.cpp Mon Dec 17 12:32:28 2007 +0000 +++ b/data/fileio/MP3FileReader.cpp Fri Jan 04 17:08:10 2008 +0000 @@ -17,6 +17,8 @@ #ifdef HAVE_MAD #include "MP3FileReader.h" +#include "ProgressPrinter.h" + #include "system/System.h" #include <sys/types.h> @@ -111,6 +113,9 @@ (QObject::tr("Decoding %1...").arg(QFileInfo(m_path).fileName()), QObject::tr("Stop"), 0, 100); m_progress->hide(); + } else { + ProgressPrinter *pp = new ProgressPrinter(tr("Decoding..."), this); + connect(this, SIGNAL(progress(int)), pp, SLOT(progress(int))); } if (!decode(m_filebuffer, m_fileSize)) { @@ -343,7 +348,7 @@ initialiseDecodeCache(); if (m_cacheMode == CacheInTemporaryFile) { - m_completion = 1; +// m_completion = 1; std::cerr << "MP3FileReader::accept: channel count " << m_channelCount << ", file rate " << m_fileRate << ", about to start serialised section" << std::endl; startSerialised("MP3FileReader::Decode"); } @@ -354,18 +359,21 @@ 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) { - if (progress > m_progress->value()) { - m_progress->setValue(progress); - m_progress->show(); - m_progress->raise(); - qApp->processEvents(); - if (m_progress->wasCanceled()) { - m_cancelled = true; + int p = int(percent); + if (p < 1) p = 1; + if (p > 99) p = 99; + if (m_completion != p || (m_progress && !m_progress->isVisible())) { + m_completion = p; + emit progress(m_completion); + if (m_progress) { + if (m_completion > m_progress->value()) { + m_progress->setValue(m_completion); + m_progress->show(); + m_progress->raise(); + qApp->processEvents(); + if (m_progress->wasCanceled()) { + m_cancelled = true; + } } } }