Mercurial > hg > svcore
changeset 1809:73447d746db3
Comments and debug-related bits
author | Chris Cannam |
---|---|
date | Tue, 29 Oct 2019 12:46:43 +0000 |
parents | 871a2050236b |
children | ee3b248bda25 07a8793a0388 |
files | data/fileio/AudioFileReader.h data/model/ReadOnlyWaveFileModel.cpp |
diffstat | 2 files changed, 62 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fileio/AudioFileReader.h Thu Oct 17 13:42:55 2019 +0100 +++ b/data/fileio/AudioFileReader.h Tue Oct 29 12:46:43 2019 +0000 @@ -70,9 +70,30 @@ /** * Return the location of the audio data in the reader (as passed - * in to the FileSource constructor, for example). + * in to the FileSource constructor, for example). This might be a + * remote URL. + * + * See also getLocalFilename(). */ - virtual QString getLocation() const { return ""; } + virtual QString getLocation() const = 0; + + /** + * Return the local file path of the audio data. This is the + * filesystem location most likely to contain readable audio data, + * but it may be in a different place or format from the + * originally specified location - for example, if the file has + * been retrieved and decoded, then it will be the (possibly + * temporary) decode target file. + * + * This returns a non-empty value only if there is some local + * filename that contains exactly the audio data being provided by + * this reader. In some cases this may not exist, for example when + * a file has been resampled or normalised directly into a memory + * buffer. In this case, return an empty string. + * + * See also getLocation(). + */ + virtual QString getLocalFilename() const = 0; /** * Return the title of the work in the audio file, if known. This @@ -89,15 +110,10 @@ virtual QString getMaker() const = 0; /** - * Return the local file path of the audio data. This is the - * location most likely to contain readable audio data: it may be - * in a different place or format from the originally specified - * location, for example if the file has been retrieved and - * decoded. In some cases there may be no local file path, and - * this will return "" if there is none. + * Return any tag pairs picked up from the audio file. See also + * getTitle and getMaker, and note that a reader which does not + * implement getTags may still return values from those. */ - virtual QString getLocalFilename() const { return ""; } - typedef std::map<QString, QString> TagMap; virtual TagMap getTags() const { return TagMap(); } @@ -108,6 +124,22 @@ */ virtual bool isQuicklySeekable() const = 0; + /** + * Return a percentage value indicating how far through decoding + * the audio file we are. This should be implemented by subclasses + * that will not know exactly how long the audio file is (in + * sample frames) until it has been completely decoded. A reader + * that initialises the frame count directly within its + * constructor should always return 100 from this. + */ + virtual int getDecodeCompletion() const { return 100; } + + /** + * Return true if decoding is still in progress and the frame + * count may change. + */ + virtual bool isUpdating() const { return false; } + /** * Return interleaved samples for count frames from index start. * The resulting vector will contain count * getChannelCount() @@ -130,12 +162,6 @@ virtual std::vector<floatvec_t> getDeInterleavedFrames(sv_frame_t start, sv_frame_t count) const; - // only subclasses that do not know exactly how long the audio - // file is until it's been completely decoded should implement this - virtual int getDecodeCompletion() const { return 100; } // % - - virtual bool isUpdating() const { return false; } - signals: void frameCountChanged();
--- a/data/model/ReadOnlyWaveFileModel.cpp Thu Oct 17 13:42:55 2019 +0100 +++ b/data/model/ReadOnlyWaveFileModel.cpp Tue Oct 29 12:46:43 2019 +0000 @@ -35,6 +35,7 @@ using namespace std; //#define DEBUG_WAVE_FILE_MODEL 1 +//#define DEBUG_WAVE_FILE_MODEL_READ 1 PowerOfSqrtTwoZoomConstraint ReadOnlyWaveFileModel::m_zoomConstraint; @@ -165,9 +166,9 @@ #ifdef DEBUG_WAVE_FILE_MODEL if (completion) { - SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::isReady(): ready = " << ready << ", m_fillThread = " << m_fillThread << ", m_lastFillExtent = " << m_lastFillExtent << ", end frame = " << getEndFrame() << ", start frame = " << getStartFrame() << ", c = " << c << ", completion = " << *completion << endl; + SVCERR << "ReadOnlyWaveFileModel(" << objectName() << ")::isReady(): ready = " << ready << ", m_fillThread = " << m_fillThread << ", m_lastFillExtent = " << m_lastFillExtent << ", end frame = " << getEndFrame() << ", start frame = " << getStartFrame() << ", c = " << c << ", completion = " << *completion << endl; } else { - SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::isReady(): ready = " << ready << ", m_fillThread = " << m_fillThread << ", m_lastFillExtent = " << m_lastFillExtent << ", end frame = " << getEndFrame() << ", start frame = " << getStartFrame() << ", c = " << c << ", completion not requested" << endl; + SVCERR << "ReadOnlyWaveFileModel(" << objectName() << ")::isReady(): ready = " << ready << ", m_fillThread = " << m_fillThread << ", m_lastFillExtent = " << m_lastFillExtent << ", end frame = " << getEndFrame() << ", start frame = " << getStartFrame() << ", c = " << c << ", completion not requested" << endl; } #endif return ready; @@ -229,6 +230,11 @@ QString ReadOnlyWaveFileModel::getLocalFilename() const { +#ifdef DEBUG_WAVE_FILE_MODEL + SVCERR << "ReadOnlyWaveFileModel::getLocalFilename: reader is " + << m_reader << ", returning " + << (m_reader ? m_reader->getLocalFilename() : "(none)") << endl; +#endif if (m_reader) return m_reader->getLocalFilename(); return ""; } @@ -245,7 +251,7 @@ Profiler profiler("ReadOnlyWaveFileModel::getData"); -#ifdef DEBUG_WAVE_FILE_MODEL +#ifdef DEBUG_WAVE_FILE_MODEL_READ cout << "ReadOnlyWaveFileModel::getData[" << this << "]: " << channel << ", " << start << ", " << count << endl; #endif @@ -306,7 +312,7 @@ Profiler profiler("ReadOnlyWaveFileModel::getMultiChannelData"); -#ifdef DEBUG_WAVE_FILE_MODEL +#ifdef DEBUG_WAVE_FILE_MODEL_READ cout << "ReadOnlyWaveFileModel::getData[" << this << "]: " << fromchannel << "," << tochannel << ", " << start << ", " << count << endl; #endif @@ -474,7 +480,7 @@ float max = 0.0, min = 0.0, total = 0.0; sv_frame_t i = 0, got = 0; -#ifdef DEBUG_WAVE_FILE_MODEL +#ifdef DEBUG_WAVE_FILE_MODEL_READ cerr << "blockSize is " << blockSize << ", cacheBlock " << cacheBlock << ", start " << start << ", count " << count << " (frame count " << getFrameCount() << "), power is " << power << ", div is " << div << ", startIndex " << startIndex << ", endIndex " << endIndex << endl; #endif @@ -503,7 +509,7 @@ } } -#ifdef DEBUG_WAVE_FILE_MODEL +#ifdef DEBUG_WAVE_FILE_MODEL_READ cerr << "returning " << ranges.size() << " ranges" << endl; #endif return; @@ -577,7 +583,7 @@ m_fillThread->start(); #ifdef DEBUG_WAVE_FILE_MODEL - SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::fillCache: started fill thread" << endl; + SVCERR << "ReadOnlyWaveFileModel(" << objectName() << ")::fillCache: started fill thread" << endl; #endif } @@ -587,7 +593,7 @@ if (m_fillThread) { sv_frame_t fillExtent = m_fillThread->getFillExtent(); #ifdef DEBUG_WAVE_FILE_MODEL - SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::fillTimerTimedOut: extent = " << fillExtent << endl; + SVCERR << "ReadOnlyWaveFileModel(" << objectName() << ")::fillTimerTimedOut: extent = " << fillExtent << endl; #endif if (fillExtent > m_lastFillExtent) { emit modelChangedWithin(getId(), m_lastFillExtent, fillExtent); @@ -595,7 +601,7 @@ } } else { #ifdef DEBUG_WAVE_FILE_MODEL - SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::fillTimerTimedOut: no thread" << endl; + SVCERR << "ReadOnlyWaveFileModel(" << objectName() << ")::fillTimerTimedOut: no thread" << endl; #endif emit modelChanged(getId()); } @@ -613,7 +619,7 @@ m_lastFillExtent = getEndFrame(); m_mutex.unlock(); #ifdef DEBUG_WAVE_FILE_MODEL - SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::cacheFilled, about to emit things" << endl; + SVCERR << "ReadOnlyWaveFileModel(" << objectName() << ")::cacheFilled, about to emit things" << endl; #endif if (getEndFrame() > prevFillExtent) { emit modelChangedWithin(getId(), prevFillExtent, getEndFrame()); @@ -642,7 +648,7 @@ if (updating) { while (channels == 0 && !m_model.m_exiting) { #ifdef DEBUG_WAVE_FILE_MODEL - cerr << "ReadOnlyWaveFileModel(" << objectName() << ")::fill: Waiting for channels..." << endl; + SVCERR << "ReadOnlyWaveFileModel(" << objectName() << ")::fill: Waiting for channels..." << endl; #endif sleep(1); channels = m_model.getChannelCount(); @@ -670,8 +676,8 @@ m_model.m_mutex.unlock(); -#ifdef DEBUG_WAVE_FILE_MODEL - SVDEBUG << "ReadOnlyWaveFileModel(" << m_model.objectName() << ")::fill inner loop: frame = " << frame << ", count = " << m_frameCount << ", blocksize " << readBlockSize << endl; +#ifdef DEBUG_WAVE_FILE_MODEL_READ + cout << "ReadOnlyWaveFileModel(" << m_model.objectName() << ")::fill inner loop: frame = " << frame << ", count = " << m_frameCount << ", blocksize " << readBlockSize << endl; #endif if (updating && (frame + readBlockSize > m_frameCount)) { @@ -764,7 +770,7 @@ #ifdef DEBUG_WAVE_FILE_MODEL for (int cacheType = 0; cacheType < 2; ++cacheType) { - SVDEBUG << "ReadOnlyWaveFileModel(" << m_model.objectName() << "): Cache type " << cacheType << " now contains " << m_model.m_cache[cacheType].size() << " ranges" << endl; + SVCERR << "ReadOnlyWaveFileModel(" << m_model.objectName() << "): Cache type " << cacheType << " now contains " << m_model.m_cache[cacheType].size() << " ranges" << endl; } #endif }