Mercurial > hg > svcore
diff data/fileio/AudioFileReaderFactory.cpp @ 1527:710e6250a401 zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 17 Sep 2018 13:51:14 +0100 |
parents | 1c9bbbb6116a |
children | 70e172e6cc59 c8fad3c14a2b |
line wrap: on
line diff
--- a/data/fileio/AudioFileReaderFactory.cpp Mon Dec 12 15:18:52 2016 +0000 +++ b/data/fileio/AudioFileReaderFactory.cpp Mon Sep 17 13:51:14 2018 +0100 @@ -19,7 +19,6 @@ #include "DecodingWavFileReader.h" #include "OggVorbisFileReader.h" #include "MP3FileReader.h" -#include "QuickTimeFileReader.h" #include "CoreAudioFileReader.h" #include "AudioFileSizeEstimator.h" @@ -43,9 +42,6 @@ OggVorbisFileReader::getSupportedExtensions(extensions); #endif #endif -#ifdef HAVE_QUICKTIME - QuickTimeFileReader::getSupportedExtensions(extensions); -#endif #ifdef HAVE_COREAUDIO CoreAudioFileReader::getSupportedExtensions(extensions); #endif @@ -67,15 +63,16 @@ { QString err; - SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << params.targetRate << (params.targetRate == 0 ? " (use source rate)" : "") << endl; + SVDEBUG << "AudioFileReaderFactory: url \"" << source.getLocation() << "\": requested rate: " << params.targetRate << (params.targetRate == 0 ? " (use source rate)" : "") << endl; + SVDEBUG << "AudioFileReaderFactory: local filename \"" << source.getLocalFilename() << "\", content type \"" << source.getContentType() << "\"" << endl; if (!source.isOK()) { - SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << endl; + SVCERR << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << endl; return 0; } if (!source.isAvailable()) { - SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Source not found" << endl; + SVCERR << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Source not found" << endl; return 0; } @@ -92,11 +89,16 @@ if (estimatedSamples > 0) { size_t kb = (estimatedSamples * sizeof(float)) / 1024; + SVDEBUG << "AudioFileReaderFactory: checking where to potentially cache " + << kb << "K of sample data" << endl; StorageAdviser::Recommendation rec = StorageAdviser::recommend(StorageAdviser::SpeedCritical, kb, kb); if ((rec & StorageAdviser::UseMemory) || (rec & StorageAdviser::PreferMemory)) { + SVDEBUG << "AudioFileReaderFactory: cacheing (if at all) in memory" << endl; cacheMode = CodedAudioFileReader::CacheInMemory; + } else { + SVDEBUG << "AudioFileReaderFactory: cacheing (if at all) on disc" << endl; } } @@ -118,6 +120,34 @@ bool anyReader = (any > 0); + if (!anyReader) { + SVDEBUG << "AudioFileReaderFactory: Checking whether any reader officially handles this source" << endl; + } else { + SVDEBUG << "AudioFileReaderFactory: Source not officially handled by any reader, trying again with each reader in turn" + << endl; + } + +#ifdef HAVE_OGGZ +#ifdef HAVE_FISHSOUND + // If we have the "real" Ogg reader, use that first. Otherwise + // the WavFileReader will likely accept Ogg files (as + // libsndfile supports them) but it has no ability to return + // file metadata, so we get a slightly less useful result. + if (anyReader || OggVorbisFileReader::supports(source)) { + + reader = new OggVorbisFileReader + (source, decodeMode, cacheMode, targetRate, normalised, reporter); + + if (reader->isOK()) { + SVDEBUG << "AudioFileReaderFactory: Ogg file reader is OK, returning it" << endl; + return reader; + } else { + delete reader; + } + } +#endif +#endif + if (anyReader || WavFileReader::supports(source)) { reader = new WavFileReader(source); @@ -130,7 +160,7 @@ (cacheMode == CodedAudioFileReader::CacheInMemory) || (targetRate != 0 && fileRate != targetRate))) { - SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", in memory " << (cacheMode == CodedAudioFileReader::CacheInMemory) << ", creating decoding reader" << endl; + SVDEBUG << "AudioFileReaderFactory: WAV file reader rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", in memory " << (cacheMode == CodedAudioFileReader::CacheInMemory) << ", creating decoding reader" << endl; delete reader; reader = new DecodingWavFileReader @@ -142,27 +172,12 @@ } if (reader->isOK()) { + SVDEBUG << "AudioFileReaderFactory: WAV file reader is OK, returning it" << endl; return reader; } else { delete reader; } } - -#ifdef HAVE_OGGZ -#ifdef HAVE_FISHSOUND - if (anyReader || OggVorbisFileReader::supports(source)) { - - reader = new OggVorbisFileReader - (source, decodeMode, cacheMode, targetRate, normalised, reporter); - - if (reader->isOK()) { - return reader; - } else { - delete reader; - } - } -#endif -#endif #ifdef HAVE_MAD if (anyReader || MP3FileReader::supports(source)) { @@ -177,20 +192,7 @@ targetRate, normalised, reporter); if (reader->isOK()) { - return reader; - } else { - delete reader; - } - } -#endif - -#ifdef HAVE_QUICKTIME - if (anyReader || QuickTimeFileReader::supports(source)) { - - reader = new QuickTimeFileReader - (source, decodeMode, cacheMode, targetRate, normalised, reporter); - - if (reader->isOK()) { + SVDEBUG << "AudioFileReaderFactory: MP3 file reader is OK, returning it" << endl; return reader; } else { delete reader; @@ -205,6 +207,7 @@ (source, decodeMode, cacheMode, targetRate, normalised, reporter); if (reader->isOK()) { + SVDEBUG << "AudioFileReaderFactory: CoreAudio reader is OK, returning it" << endl; return reader; } else { delete reader; @@ -214,10 +217,11 @@ } - SVDEBUG << "AudioFileReaderFactory::Failed to create a reader for " - << "url \"" << source.getLocation() - << "\" (content type \"" - << source.getContentType() << "\")" << endl; + SVCERR << "AudioFileReaderFactory::Failed to create a reader for " + << "url \"" << source.getLocation() + << "\" (local filename \"" << source.getLocalFilename() + << "\", content type \"" + << source.getContentType() << "\")" << endl; return nullptr; }