Mercurial > hg > svcore
changeset 1342:c0fece5e7755 3.0-integration
Improved debug output for file open troubleshooting
author | Chris Cannam |
---|---|
date | Fri, 06 Jan 2017 09:43:40 +0000 |
parents | 513e4d67d8df |
children | c380e56c95f5 |
files | data/fileio/AudioFileReaderFactory.cpp data/fileio/AudioFileSizeEstimator.cpp data/fileio/MP3FileReader.cpp |
diffstat | 3 files changed, 49 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fileio/AudioFileReaderFactory.cpp Fri Jan 06 09:15:36 2017 +0000 +++ b/data/fileio/AudioFileReaderFactory.cpp Fri Jan 06 09:43:40 2017 +0000 @@ -63,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; } @@ -88,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; } } @@ -114,6 +120,13 @@ 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; + } + if (anyReader || WavFileReader::supports(source)) { reader = new WavFileReader(source); @@ -126,7 +139,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 @@ -138,6 +151,7 @@ } if (reader->isOK()) { + SVDEBUG << "AudioFileReaderFactory: WAV file reader is OK, returning it" << endl; return reader; } else { delete reader; @@ -152,6 +166,7 @@ (source, decodeMode, cacheMode, targetRate, normalised, reporter); if (reader->isOK()) { + SVDEBUG << "AudioFileReaderFactory: Ogg file reader is OK, returning it" << endl; return reader; } else { delete reader; @@ -173,6 +188,7 @@ targetRate, normalised, reporter); if (reader->isOK()) { + SVDEBUG << "AudioFileReaderFactory: MP3 file reader is OK, returning it" << endl; return reader; } else { delete reader; @@ -187,6 +203,7 @@ (source, decodeMode, cacheMode, targetRate, normalised, reporter); if (reader->isOK()) { + SVDEBUG << "AudioFileReaderFactory: CoreAudio reader is OK, returning it" << endl; return reader; } else { delete reader; @@ -196,10 +213,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; }
--- a/data/fileio/AudioFileSizeEstimator.cpp Fri Jan 06 09:15:36 2017 +0000 +++ b/data/fileio/AudioFileSizeEstimator.cpp Fri Jan 06 09:43:40 2017 +0000 @@ -18,7 +18,7 @@ #include <QFile> -//#define DEBUG_AUDIO_FILE_SIZE_ESTIMATOR 1 +#include "base/Debug.h" sv_frame_t AudioFileSizeEstimator::estimate(FileSource source, @@ -26,6 +26,9 @@ { sv_frame_t estimate = 0; + SVDEBUG << "AudioFileSizeEstimator: Sample count estimate requested for file \"" + << source.getLocalFilename() << "\"" << endl; + // Most of our file readers don't know the sample count until // after they've finished decoding. This is an exception: @@ -40,7 +43,12 @@ samples = sv_frame_t(double(samples) * targetRate / rate); } delete reader; + SVDEBUG << "AudioFileSizeEstimator: WAV file reader accepts this file, reports " + << samples << " samples" << endl; estimate = samples; + } else { + SVDEBUG << "AudioFileSizeEstimator: WAV file reader doesn't like this file, " + << "estimating from file size and extension instead" << endl; } if (estimate == 0) { @@ -60,12 +68,12 @@ if (!source.isOK()) return 0; sv_frame_t sz = 0; + { QFile f(source.getLocalFilename()); if (f.open(QFile::ReadOnly)) { -#ifdef DEBUG_AUDIO_FILE_SIZE_ESTIMATOR - cerr << "opened file, size is " << f.size() << endl; -#endif + SVDEBUG << "AudioFileSizeEstimator: opened file, size is " + << f.size() << endl; sz = f.size(); f.close(); } @@ -94,14 +102,9 @@ estimate = sv_frame_t(double(sz) * 1.2 * rateRatio); } -#ifdef DEBUG_AUDIO_FILE_SIZE_ESTIMATOR - cerr << "AudioFileSizeEstimator: for extension " << extension << ", estimate = " << estimate << endl; -#endif + SVDEBUG << "AudioFileSizeEstimator: for extension \"" + << extension << "\", estimate = " << estimate << " samples" << endl; } - -#ifdef DEBUG_AUDIO_FILE_SIZE_ESTIMATOR - cerr << "estimate = " << estimate << endl; -#endif return estimate; }
--- a/data/fileio/MP3FileReader.cpp Fri Jan 06 09:15:36 2017 +0000 +++ b/data/fileio/MP3FileReader.cpp Fri Jan 06 09:43:40 2017 +0000 @@ -77,8 +77,9 @@ struct stat stat; if (::stat(m_path.toLocal8Bit().data(), &stat) == -1 || stat.st_size == 0) { - m_error = QString("File %1 does not exist.").arg(m_path); - return; + m_error = QString("File %1 does not exist.").arg(m_path); + SVDEBUG << "MP3FileReader: " << m_error << endl; + return; } m_fileSize = stat.st_size; @@ -95,8 +96,9 @@ | O_BINARY #endif , 0)) < 0) { - m_error = QString("Failed to open file %1 for reading.").arg(m_path); - return; + m_error = QString("Failed to open file %1 for reading.").arg(m_path); + SVDEBUG << "MP3FileReader: " << m_error << endl; + return; } try { @@ -108,8 +110,9 @@ memset(m_fileBuffer + m_fileSize, 0, MAD_BUFFER_GUARD); } catch (...) { m_error = QString("Out of memory"); + SVDEBUG << "MP3FileReader: " << m_error << endl; ::close(fd); - return; + return; } ssize_t sz = 0; @@ -121,6 +124,7 @@ .arg(m_path).arg(offset); delete[] m_fileBuffer; ::close(fd); + SVDEBUG << "MP3FileReader: " << m_error << endl; return; } else if (sz == 0) { SVCERR << QString("MP3FileReader::MP3FileReader: Warning: reached EOF after only %1 of %2 bytes")