Mercurial > hg > svcore
diff data/fileio/AudioFileReaderFactory.cpp @ 829:f63051833723 tonioni
Merge
author | Chris Cannam <chris.cannam@eecs.qmul.ac.uk> |
---|---|
date | Wed, 17 Jul 2013 16:01:28 +0100 |
parents | f0558e69a074 |
children | e802e550a1f2 |
line wrap: on
line diff
--- a/data/fileio/AudioFileReaderFactory.cpp Wed Jul 17 15:59:17 2013 +0100 +++ b/data/fileio/AudioFileReaderFactory.cpp Wed Jul 17 16:01:28 2013 +0100 @@ -16,7 +16,7 @@ #include "AudioFileReaderFactory.h" #include "WavFileReader.h" -#include "ResamplingWavFileReader.h" +#include "DecodingWavFileReader.h" #include "OggVorbisFileReader.h" #include "MP3FileReader.h" #include "QuickTimeFileReader.h" @@ -98,20 +98,22 @@ reader = new WavFileReader(source); - if (targetRate != 0 && - reader->isOK() && - reader->getSampleRate() != targetRate) { + int fileRate = reader->getSampleRate(); - SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << endl; + if (reader->isOK() && + (!reader->isQuicklySeekable() || + (targetRate != 0 && fileRate != targetRate))) { + + SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; delete reader; - reader = new ResamplingWavFileReader + reader = new DecodingWavFileReader (source, threading ? - ResamplingWavFileReader::ResampleThreaded : - ResamplingWavFileReader::ResampleAtOnce, - ResamplingWavFileReader::CacheInTemporaryFile, - targetRate, + DecodingWavFileReader::ResampleThreaded : + DecodingWavFileReader::ResampleAtOnce, + DecodingWavFileReader::CacheInTemporaryFile, + targetRate ? targetRate : fileRate, reporter); if (!reader->isOK()) { delete reader; @@ -209,20 +211,22 @@ reader = new WavFileReader(source); - if (targetRate != 0 && - reader->isOK() && - reader->getSampleRate() != targetRate) { + int fileRate = reader->getSampleRate(); - SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << endl; + if (reader->isOK() && + (!reader->isQuicklySeekable() || + (targetRate != 0 && fileRate != targetRate))) { + + SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; delete reader; - reader = new ResamplingWavFileReader + reader = new DecodingWavFileReader (source, threading ? - ResamplingWavFileReader::ResampleThreaded : - ResamplingWavFileReader::ResampleAtOnce, - ResamplingWavFileReader::CacheInTemporaryFile, - targetRate, + DecodingWavFileReader::ResampleThreaded : + DecodingWavFileReader::ResampleAtOnce, + DecodingWavFileReader::CacheInTemporaryFile, + targetRate ? targetRate : fileRate, reporter); }