comparison data/fileio/ResamplingWavFileReader.cpp @ 316:3a6725f285d6

* Make RemoteFile far more pervasive, and use it for local files as well so that we can handle both transparently. Make it shallow copy with reference counting, so it can be used by value without having to worry about the cache file lifetime. Use RemoteFile for MainWindow file-open functions, etc
author Chris Cannam
date Thu, 18 Oct 2007 15:31:20 +0000
parents c022976d18e8
children c324d410b096
comparison
equal deleted inserted replaced
315:96ef9746c560 316:3a6725f285d6
20 20
21 #include <QProgressDialog> 21 #include <QProgressDialog>
22 #include <QFileInfo> 22 #include <QFileInfo>
23 #include <QApplication> 23 #include <QApplication>
24 24
25 ResamplingWavFileReader::ResamplingWavFileReader(QString path, 25 ResamplingWavFileReader::ResamplingWavFileReader(RemoteFile source,
26 ResampleMode resampleMode, 26 ResampleMode resampleMode,
27 CacheMode mode, 27 CacheMode mode,
28 size_t targetRate) : 28 size_t targetRate) :
29 CodedAudioFileReader(mode, targetRate), 29 CodedAudioFileReader(mode, targetRate),
30 m_path(path), 30 m_source(source),
31 m_path(source.getLocalFilename()),
31 m_cancelled(false), 32 m_cancelled(false),
32 m_processed(0), 33 m_processed(0),
33 m_completion(0), 34 m_completion(0),
34 m_original(0), 35 m_original(0),
35 m_progress(0), 36 m_progress(0),
37 { 38 {
38 m_channelCount = 0; 39 m_channelCount = 0;
39 m_fileRate = 0; 40 m_fileRate = 0;
40 41
41 std::cerr << "ResamplingWavFileReader::ResamplingWavFileReader(\"" 42 std::cerr << "ResamplingWavFileReader::ResamplingWavFileReader(\""
42 << path.toStdString() << "\"): rate " << targetRate << std::endl; 43 << m_path.toStdString() << "\"): rate " << targetRate << std::endl;
43 44
44 Profiler profiler("ResamplingWavFileReader::ResamplingWavFileReader", true); 45 Profiler profiler("ResamplingWavFileReader::ResamplingWavFileReader", true);
45 46
46 m_original = new WavFileReader(path); 47 m_original = new WavFileReader(m_path);
47 if (!m_original->isOK()) { 48 if (!m_original->isOK()) {
48 m_error = m_original->getError(); 49 m_error = m_original->getError();
49 return; 50 return;
50 } 51 }
51 52
55 initialiseDecodeCache(); 56 initialiseDecodeCache();
56 57
57 if (resampleMode == ResampleAtOnce) { 58 if (resampleMode == ResampleAtOnce) {
58 59
59 m_progress = new QProgressDialog 60 m_progress = new QProgressDialog
60 (QObject::tr("Resampling %1...").arg(QFileInfo(path).fileName()), 61 (QObject::tr("Resampling %1...").arg(QFileInfo(m_path).fileName()),
61 QObject::tr("Stop"), 0, 100); 62 QObject::tr("Stop"), 0, 100);
62 m_progress->hide(); 63 m_progress->hide();
63 64
64 size_t blockSize = 16384; 65 size_t blockSize = 16384;
65 size_t total = m_original->getFrameCount(); 66 size_t total = m_original->getFrameCount();
165 ResamplingWavFileReader::getSupportedExtensions(std::set<QString> &extensions) 166 ResamplingWavFileReader::getSupportedExtensions(std::set<QString> &extensions)
166 { 167 {
167 WavFileReader::getSupportedExtensions(extensions); 168 WavFileReader::getSupportedExtensions(extensions);
168 } 169 }
169 170
171 bool
172 ResamplingWavFileReader::supportsExtension(QString extension)
173 {
174 return WavFileReader::supportsExtension(extension);
175 }
170 176
177 bool
178 ResamplingWavFileReader::supportsContentType(QString type)
179 {
180 return WavFileReader::supportsContentType(type);
181 }
182
183 bool
184 ResamplingWavFileReader::supports(RemoteFile &source)
185 {
186 return WavFileReader::supports(source);
187 }
188
189