Mercurial > hg > svcore
diff data/fileio/CodedAudioFileReader.cpp @ 1098:329ddaf7415d simple-fft-model
Store temporary audio files in memory if we have plenty of it
author | Chris Cannam |
---|---|
date | Mon, 15 Jun 2015 14:35:37 +0100 |
parents | 4d9816ba0ebe |
children | 5cbf71022679 |
line wrap: on
line diff
--- a/data/fileio/CodedAudioFileReader.cpp Mon Jun 15 12:38:50 2015 +0100 +++ b/data/fileio/CodedAudioFileReader.cpp Mon Jun 15 14:35:37 2015 +0100 @@ -21,6 +21,7 @@ #include "base/Profiler.h" #include "base/Serialiser.h" #include "base/Resampler.h" +#include "base/StorageAdviser.h" #include <stdint.h> #include <iostream> @@ -59,7 +60,7 @@ QMutexLocker locker(&m_cacheMutex); endSerialised(); - + if (m_cacheFileWritePtr) sf_close(m_cacheFileWritePtr); SVDEBUG << "CodedAudioFileReader::~CodedAudioFileReader: deleting cache file reader" << endl; @@ -75,6 +76,12 @@ delete m_resampler; delete[] m_resampleBuffer; + + if (!m_data.empty()) { + StorageAdviser::notifyDoneAllocation + (StorageAdviser::MemoryAllocation, + (m_data.size() * sizeof(float)) / 1024); + } } void @@ -294,9 +301,16 @@ m_resampler = 0; if (m_cacheMode == CacheInTemporaryFile) { + sf_close(m_cacheFileWritePtr); m_cacheFileWritePtr = 0; if (m_cacheFileReader) m_cacheFileReader->updateFrameCount(); + + } else { + // I know, I know, we already allocated it... + StorageAdviser::notifyPlannedAllocation + (StorageAdviser::MemoryAllocation, + (m_data.size() * sizeof(float)) / 1024); } }