comparison data/fileio/OggVorbisFileReader.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 1afaf98dbf11
children e6d11871e4c9
comparison
equal deleted inserted replaced
356:ca3b91119482 357:b92513201610
15 15
16 #ifdef HAVE_OGGZ 16 #ifdef HAVE_OGGZ
17 #ifdef HAVE_FISHSOUND 17 #ifdef HAVE_FISHSOUND
18 18
19 #include "OggVorbisFileReader.h" 19 #include "OggVorbisFileReader.h"
20 #include "ProgressPrinter.h"
21
20 #include "base/Profiler.h" 22 #include "base/Profiler.h"
21 #include "system/System.h" 23 #include "system/System.h"
22 24
23 #include <sys/types.h> 25 #include <sys/types.h>
24 #include <sys/stat.h> 26 #include <sys/stat.h>
73 if (dynamic_cast<QApplication *>(QCoreApplication::instance())) { 75 if (dynamic_cast<QApplication *>(QCoreApplication::instance())) {
74 m_progress = new QProgressDialog 76 m_progress = new QProgressDialog
75 (QObject::tr("Decoding %1...").arg(QFileInfo(m_path).fileName()), 77 (QObject::tr("Decoding %1...").arg(QFileInfo(m_path).fileName()),
76 QObject::tr("Stop"), 0, 100); 78 QObject::tr("Stop"), 0, 100);
77 m_progress->hide(); 79 m_progress->hide();
80 } else {
81 ProgressPrinter *pp = new ProgressPrinter(tr("Decoding..."), this);
82 connect(this, SIGNAL(progress(int)), pp, SLOT(progress(int)));
78 } 83 }
79 84
80 while (oggz_read(m_oggz, 1024) > 0); 85 while (oggz_read(m_oggz, 1024) > 0);
81 86
82 fish_sound_delete(m_fishSound); 87 fish_sound_delete(m_fishSound);
143 148
144 reader->m_bytesRead += packet->bytes; 149 reader->m_bytesRead += packet->bytes;
145 150
146 // The number of bytes read by this function is smaller than 151 // The number of bytes read by this function is smaller than
147 // the file size because of the packet headers 152 // the file size because of the packet headers
148 int progress = lrint(double(reader->m_bytesRead) * 114 / 153 int p = lrint(double(reader->m_bytesRead) * 114 /
149 double(reader->m_fileSize)); 154 double(reader->m_fileSize));
150 if (progress > 99) progress = 99; 155 if (p > 99) p = 99;
151 reader->m_completion = progress; 156 reader->m_completion = p;
152 157 reader->progress(p);
158
153 if (reader->m_fileSize > 0 && reader->m_progress) { 159 if (reader->m_fileSize > 0 && reader->m_progress) {
154 if (progress > reader->m_progress->value()) { 160 if (p > reader->m_progress->value()) {
155 reader->m_progress->setValue(progress); 161 reader->m_progress->setValue(p);
156 reader->m_progress->show(); 162 reader->m_progress->show();
157 reader->m_progress->raise(); 163 reader->m_progress->raise();
158 qApp->processEvents(); 164 qApp->processEvents();
159 if (reader->m_progress->wasCanceled()) { 165 if (reader->m_progress->wasCanceled()) {
160 reader->m_cancelled = true; 166 reader->m_cancelled = true;