comparison data/fileio/AudioFileReaderFactory.cpp @ 823:f0558e69a074

Rename Resampling- to DecodingWavFileReader, and use it whenever we have an audio file that is not quickly seekable using libsndfile. Avoids very slow performance when analysing ogg files.
author Chris Cannam
date Wed, 17 Jul 2013 15:40:01 +0100
parents babed5be1ae7
children e802e550a1f2
comparison
equal deleted inserted replaced
821:06c64a1c6785 823:f0558e69a074
14 */ 14 */
15 15
16 #include "AudioFileReaderFactory.h" 16 #include "AudioFileReaderFactory.h"
17 17
18 #include "WavFileReader.h" 18 #include "WavFileReader.h"
19 #include "ResamplingWavFileReader.h" 19 #include "DecodingWavFileReader.h"
20 #include "OggVorbisFileReader.h" 20 #include "OggVorbisFileReader.h"
21 #include "MP3FileReader.h" 21 #include "MP3FileReader.h"
22 #include "QuickTimeFileReader.h" 22 #include "QuickTimeFileReader.h"
23 #include "CoreAudioFileReader.h" 23 #include "CoreAudioFileReader.h"
24 24
96 96
97 if (WavFileReader::supports(source)) { 97 if (WavFileReader::supports(source)) {
98 98
99 reader = new WavFileReader(source); 99 reader = new WavFileReader(source);
100 100
101 if (targetRate != 0 && 101 int fileRate = reader->getSampleRate();
102 reader->isOK() && 102
103 reader->getSampleRate() != targetRate) { 103 if (reader->isOK() &&
104 104 (!reader->isQuicklySeekable() ||
105 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << endl; 105 (targetRate != 0 && fileRate != targetRate))) {
106 106
107 delete reader; 107 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl;
108 reader = new ResamplingWavFileReader 108
109 (source, 109 delete reader;
110 threading ? 110 reader = new DecodingWavFileReader
111 ResamplingWavFileReader::ResampleThreaded : 111 (source,
112 ResamplingWavFileReader::ResampleAtOnce, 112 threading ?
113 ResamplingWavFileReader::CacheInTemporaryFile, 113 DecodingWavFileReader::ResampleThreaded :
114 targetRate, 114 DecodingWavFileReader::ResampleAtOnce,
115 DecodingWavFileReader::CacheInTemporaryFile,
116 targetRate ? targetRate : fileRate,
115 reporter); 117 reporter);
116 if (!reader->isOK()) { 118 if (!reader->isOK()) {
117 delete reader; 119 delete reader;
118 reader = 0; 120 reader = 0;
119 } 121 }
207 209
208 if (!reader) { 210 if (!reader) {
209 211
210 reader = new WavFileReader(source); 212 reader = new WavFileReader(source);
211 213
212 if (targetRate != 0 && 214 int fileRate = reader->getSampleRate();
213 reader->isOK() && 215
214 reader->getSampleRate() != targetRate) { 216 if (reader->isOK() &&
215 217 (!reader->isQuicklySeekable() ||
216 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << endl; 218 (targetRate != 0 && fileRate != targetRate))) {
217 219
218 delete reader; 220 SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl;
219 reader = new ResamplingWavFileReader 221
220 (source, 222 delete reader;
221 threading ? 223 reader = new DecodingWavFileReader
222 ResamplingWavFileReader::ResampleThreaded : 224 (source,
223 ResamplingWavFileReader::ResampleAtOnce, 225 threading ?
224 ResamplingWavFileReader::CacheInTemporaryFile, 226 DecodingWavFileReader::ResampleThreaded :
225 targetRate, 227 DecodingWavFileReader::ResampleAtOnce,
228 DecodingWavFileReader::CacheInTemporaryFile,
229 targetRate ? targetRate : fileRate,
226 reporter); 230 reporter);
227 } 231 }
228 232
229 if (!reader->isOK()) { 233 if (!reader->isOK()) {
230 delete reader; 234 delete reader;