comparison data/fileio/AudioFileReaderFactory.cpp @ 1279:0a9193dc136b 3.0-integration

Debug output updates
author Chris Cannam
date Tue, 22 Nov 2016 16:40:41 +0000
parents 13701ab9d2c7
children 9f9f55a8af92
comparison
equal deleted inserted replaced
1278:0be27c989c1d 1279:0a9193dc136b
27 27
28 #include <QString> 28 #include <QString>
29 #include <QFileInfo> 29 #include <QFileInfo>
30 #include <iostream> 30 #include <iostream>
31 31
32 //#define DEBUG_AUDIO_FILE_READER_FACTORY 1
33
34 QString 32 QString
35 AudioFileReaderFactory::getKnownExtensions() 33 AudioFileReaderFactory::getKnownExtensions()
36 { 34 {
37 std::set<QString> extensions; 35 std::set<QString> extensions;
38 36
87 bool threading, 85 bool threading,
88 ProgressReporter *reporter) 86 ProgressReporter *reporter)
89 { 87 {
90 QString err; 88 QString err;
91 89
92 #ifdef DEBUG_AUDIO_FILE_READER_FACTORY 90 SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << (targetRate == 0 ? " (use source rate)" : "") << endl;
93 cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << endl;
94 #endif
95 91
96 if (!source.isOK()) { 92 if (!source.isOK()) {
97 cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << endl; 93 SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << endl;
98 return 0; 94 return 0;
99 } 95 }
100 96
101 if (!source.isAvailable()) { 97 if (!source.isAvailable()) {
102 cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Source not found" << endl; 98 SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Source not found" << endl;
103 return 0; 99 return 0;
104 } 100 }
105 101
106 AudioFileReader *reader = 0; 102 AudioFileReader *reader = 0;
107 103
141 (!reader->isQuicklySeekable() || 137 (!reader->isQuicklySeekable() ||
142 normalised || 138 normalised ||
143 (cacheMode == CodedAudioFileReader::CacheInMemory) || 139 (cacheMode == CodedAudioFileReader::CacheInMemory) ||
144 (targetRate != 0 && fileRate != targetRate))) { 140 (targetRate != 0 && fileRate != targetRate))) {
145 141
146 #ifdef DEBUG_AUDIO_FILE_READER_FACTORY 142 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", in memory " << (cacheMode == CodedAudioFileReader::CacheInMemory) << ", creating decoding reader" << endl;
147 cerr << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", in memory " << (cacheMode == CodedAudioFileReader::CacheInMemory) << ", creating decoding reader" << endl;
148 #endif
149 143
150 delete reader; 144 delete reader;
151 reader = new DecodingWavFileReader 145 reader = new DecodingWavFileReader
152 (source, 146 (source,
153 decodeMode, cacheMode, 147 decodeMode, cacheMode,
212 (!reader->isQuicklySeekable() || 206 (!reader->isQuicklySeekable() ||
213 normalised || 207 normalised ||
214 (cacheMode == CodedAudioFileReader::CacheInMemory) || 208 (cacheMode == CodedAudioFileReader::CacheInMemory) ||
215 (targetRate != 0 && fileRate != targetRate))) { 209 (targetRate != 0 && fileRate != targetRate))) {
216 210
217 #ifdef DEBUG_AUDIO_FILE_READER_FACTORY 211 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", in memory " << (cacheMode == CodedAudioFileReader::CacheInMemory) << ", creating decoding reader" << endl;
218 cerr << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", in memory " << (cacheMode == CodedAudioFileReader::CacheInMemory) << ", creating decoding reader" << endl;
219 #endif
220 212
221 delete reader; 213 delete reader;
222 reader = new DecodingWavFileReader 214 reader = new DecodingWavFileReader
223 (source, 215 (source,
224 decodeMode, cacheMode, 216 decodeMode, cacheMode,
262 CHECK(reader); 254 CHECK(reader);
263 } 255 }
264 #endif 256 #endif
265 257
266 if (!reader) { 258 if (!reader) {
267 cerr << "AudioFileReaderFactory::Failed to create a reader for " 259 SVDEBUG << "AudioFileReaderFactory::Failed to create a reader for "
268 << "url \"" << source.getLocation() 260 << "url \"" << source.getLocation()
269 << "\" (content type \"" 261 << "\" (content type \""
270 << source.getContentType() << "\")" << endl; 262 << source.getContentType() << "\")" << endl;
271 return nullptr; 263 return nullptr;
272 } 264 }
273 265
274 return reader; 266 return reader;
275 } 267 }