Mercurial > hg > svcore
diff data/fileio/CodedAudioFileReader.cpp @ 1096:4d9816ba0ebe simple-fft-model
Rework audio file reader API to prefer using std containers
author | Chris Cannam |
---|---|
date | Mon, 15 Jun 2015 12:19:47 +0100 |
parents | e603b44510c3 |
children | 329ddaf7415d |
line wrap: on
line diff
--- a/data/fileio/CodedAudioFileReader.cpp Sat Jun 13 08:47:05 2015 +0100 +++ b/data/fileio/CodedAudioFileReader.cpp Mon Jun 15 12:19:47 2015 +0100 @@ -27,6 +27,8 @@ #include <QDir> #include <QMutexLocker> +using namespace std; + CodedAudioFileReader::CodedAudioFileReader(CacheMode cacheMode, sv_samplerate_t targetRate, bool normalised) : @@ -242,7 +244,7 @@ } void -CodedAudioFileReader::addSamplesToDecodeCache(const SampleBlock &samples) +CodedAudioFileReader::addSamplesToDecodeCache(const vector<float> &samples) { QMutexLocker locker(&m_cacheMutex); @@ -352,9 +354,7 @@ case CacheInMemory: m_dataLock.lockForWrite(); - for (sv_frame_t s = 0; s < count; ++s) { - m_data.push_back(buffer[s]); - } + m_data.insert(m_data.end(), buffer, buffer + count); m_dataLock.unlock(); break; } @@ -408,7 +408,7 @@ } } -SampleBlock +vector<float> CodedAudioFileReader::getInterleavedFrames(sv_frame_t start, sv_frame_t count) const { // Lock is only required in CacheInMemory mode (the cache file @@ -417,10 +417,10 @@ if (!m_initialised) { SVDEBUG << "CodedAudioFileReader::getInterleavedFrames: not initialised" << endl; - return SampleBlock(); + return {}; } - SampleBlock frames; + vector<float> frames; switch (m_cacheMode) { @@ -432,8 +432,8 @@ case CacheInMemory: { - if (!isOK()) return SampleBlock(); - if (count == 0) return SampleBlock(); + if (!isOK()) return {}; + if (count == 0) return {}; sv_frame_t idx = start * m_channelCount; sv_frame_t i = 0;