comparison data/fileio/AudioFileReaderFactory.cpp @ 1161:5b463c7727e5

Use float format for cached files in CodedAudioFileReader, to preserve internal representation (see comment)
author Chris Cannam
date Wed, 24 Feb 2016 10:28:47 +0000
parents a1cd5abcb38b
children 6877f4200912
comparison
equal deleted inserted replaced
1158:d9c766274c8b 1161:5b463c7727e5
24 24
25 #include <QString> 25 #include <QString>
26 #include <QFileInfo> 26 #include <QFileInfo>
27 #include <iostream> 27 #include <iostream>
28 28
29 //#define DEBUG_AUDIO_FILE_READER_FACTORY 1
30
29 QString 31 QString
30 AudioFileReaderFactory::getKnownExtensions() 32 AudioFileReaderFactory::getKnownExtensions()
31 { 33 {
32 std::set<QString> extensions; 34 std::set<QString> extensions;
33 35
82 bool threading, 84 bool threading,
83 ProgressReporter *reporter) 85 ProgressReporter *reporter)
84 { 86 {
85 QString err; 87 QString err;
86 88
87 SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << endl; 89 #ifdef DEBUG_AUDIO_FILE_READER_FACTORY
90 cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << endl;
91 #endif
88 92
89 if (!source.isOK()) { 93 if (!source.isOK()) {
90 cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << endl; 94 cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << endl;
91 return 0; 95 return 0;
92 } 96 }
93 97
94 if (!source.isAvailable()) { 98 if (!source.isAvailable()) {
95 SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Source not found" << endl; 99 cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Source not found" << endl;
96 return 0; 100 return 0;
97 } 101 }
98 102
99 AudioFileReader *reader = 0; 103 AudioFileReader *reader = 0;
100 104
110 if (reader->isOK() && 114 if (reader->isOK() &&
111 (!reader->isQuicklySeekable() || 115 (!reader->isQuicklySeekable() ||
112 normalised || 116 normalised ||
113 (targetRate != 0 && fileRate != targetRate))) { 117 (targetRate != 0 && fileRate != targetRate))) {
114 118
115 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; 119 #ifdef DEBUG_AUDIO_FILE_READER_FACTORY
116 120 cerr << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl;
121 #endif
122
117 delete reader; 123 delete reader;
118 reader = new DecodingWavFileReader 124 reader = new DecodingWavFileReader
119 (source, 125 (source,
120 threading ? 126 threading ?
121 DecodingWavFileReader::ResampleThreaded : 127 DecodingWavFileReader::ResampleThreaded :
229 if (reader->isOK() && 235 if (reader->isOK() &&
230 (!reader->isQuicklySeekable() || 236 (!reader->isQuicklySeekable() ||
231 normalised || 237 normalised ||
232 (targetRate != 0 && fileRate != targetRate))) { 238 (targetRate != 0 && fileRate != targetRate))) {
233 239
234 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; 240 #ifdef DEBUG_AUDIO_FILE_READER_FACTORY
241 cerr << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl;
242 #endif
235 243
236 delete reader; 244 delete reader;
237 reader = new DecodingWavFileReader 245 reader = new DecodingWavFileReader
238 (source, 246 (source,
239 threading ? 247 threading ?
325 } 333 }
326 #endif 334 #endif
327 335
328 if (reader) { 336 if (reader) {
329 if (reader->isOK()) { 337 if (reader->isOK()) {
330 SVDEBUG << "AudioFileReaderFactory: Reader is OK" << endl; 338 #ifdef DEBUG_AUDIO_FILE_READER_FACTORY
339 cerr << "AudioFileReaderFactory: Reader is OK" << endl;
340 #endif
331 return reader; 341 return reader;
332 } 342 }
333 cerr << "AudioFileReaderFactory: Preferred reader for " 343 cerr << "AudioFileReaderFactory: Preferred reader for "
334 << "url \"" << source.getLocation() 344 << "url \"" << source.getLocation()
335 << "\" (content type \"" 345 << "\" (content type \""