Mercurial > hg > svcore
diff data/fileio/CodedAudioFileReader.cpp @ 929:59e7fe1b1003 warnfix_no_size_t
Unsigned removals and warning fixes in data/
author | Chris Cannam |
---|---|
date | Tue, 17 Jun 2014 14:33:42 +0100 |
parents | f5cd33909744 |
children | d03b3d956358 |
line wrap: on
line diff
--- a/data/fileio/CodedAudioFileReader.cpp Tue Jun 17 13:52:07 2014 +0100 +++ b/data/fileio/CodedAudioFileReader.cpp Tue Jun 17 14:33:42 2014 +0100 @@ -28,7 +28,7 @@ #include <QMutexLocker> CodedAudioFileReader::CodedAudioFileReader(CacheMode cacheMode, - size_t targetRate) : + int targetRate) : m_cacheMode(cacheMode), m_initialised(false), m_serialiser(0), @@ -172,15 +172,15 @@ } void -CodedAudioFileReader::addSamplesToDecodeCache(float **samples, size_t nframes) +CodedAudioFileReader::addSamplesToDecodeCache(float **samples, int nframes) { QMutexLocker locker(&m_cacheMutex); if (!m_initialised) return; - for (size_t i = 0; i < nframes; ++i) { + for (int i = 0; i < nframes; ++i) { - for (size_t c = 0; c < m_channelCount; ++c) { + for (int c = 0; c < m_channelCount; ++c) { float sample = samples[c][i]; @@ -202,15 +202,15 @@ } void -CodedAudioFileReader::addSamplesToDecodeCache(float *samples, size_t nframes) +CodedAudioFileReader::addSamplesToDecodeCache(float *samples, int nframes) { QMutexLocker locker(&m_cacheMutex); if (!m_initialised) return; - for (size_t i = 0; i < nframes; ++i) { + for (int i = 0; i < nframes; ++i) { - for (size_t c = 0; c < m_channelCount; ++c) { + for (int c = 0; c < m_channelCount; ++c) { float sample = samples[i * m_channelCount + c]; @@ -238,7 +238,7 @@ if (!m_initialised) return; - for (size_t i = 0; i < samples.size(); ++i) { + for (int i = 0; i < (int)samples.size(); ++i) { float sample = samples[i]; @@ -293,7 +293,7 @@ } void -CodedAudioFileReader::pushBuffer(float *buffer, size_t sz, bool final) +CodedAudioFileReader::pushBuffer(float *buffer, int sz, bool final) { m_fileFrameCount += sz; @@ -310,15 +310,15 @@ } void -CodedAudioFileReader::pushBufferNonResampling(float *buffer, size_t sz) +CodedAudioFileReader::pushBufferNonResampling(float *buffer, int sz) { float max = 1.0; - size_t count = sz * m_channelCount; + int count = sz * m_channelCount; - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { if (buffer[i] > max) buffer[i] = max; } - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { if (buffer[i] < -max) buffer[i] = -max; } @@ -327,7 +327,7 @@ switch (m_cacheMode) { case CacheInTemporaryFile: - if (sf_writef_float(m_cacheFileWritePtr, buffer, sz) < sz) { + if (sf_writef_float(m_cacheFileWritePtr, buffer, sz) < (int)sz) { sf_close(m_cacheFileWritePtr); m_cacheFileWritePtr = 0; throw InsufficientDiscSpace(TempDirectory::getInstance()->getPath()); @@ -336,7 +336,7 @@ case CacheInMemory: m_dataLock.lockForWrite(); - for (size_t s = 0; s < count; ++s) { + for (int s = 0; s < count; ++s) { m_data.push_back(buffer[s]); } MUNLOCK_SAMPLEBLOCK(m_data); @@ -346,14 +346,14 @@ } void -CodedAudioFileReader::pushBufferResampling(float *buffer, size_t sz, +CodedAudioFileReader::pushBufferResampling(float *buffer, int sz, float ratio, bool final) { SVDEBUG << "pushBufferResampling: ratio = " << ratio << ", sz = " << sz << ", final = " << final << endl; if (sz > 0) { - size_t out = m_resampler->resampleInterleaved + int out = m_resampler->resampleInterleaved (buffer, m_resampleBuffer, sz, @@ -365,27 +365,27 @@ if (final) { - size_t padFrames = 1; + int padFrames = 1; if (m_frameCount / ratio < m_fileFrameCount) { padFrames = m_fileFrameCount - (m_frameCount / ratio) + 1; } - size_t padSamples = padFrames * m_channelCount; + int padSamples = padFrames * m_channelCount; SVDEBUG << "frameCount = " << m_frameCount << ", equivFileFrames = " << m_frameCount / ratio << ", m_fileFrameCount = " << m_fileFrameCount << ", padFrames= " << padFrames << ", padSamples = " << padSamples << endl; float *padding = new float[padSamples]; for (int i = 0; i < padSamples; ++i) padding[i] = 0.f; - size_t out = m_resampler->resampleInterleaved + int out = m_resampler->resampleInterleaved (padding, m_resampleBuffer, padFrames, ratio, true); - if (m_frameCount + out > int(m_fileFrameCount * ratio)) { - out = int(m_fileFrameCount * ratio) - m_frameCount; + if (int(m_frameCount + out) > int(m_fileFrameCount * ratio)) { + out = int(m_fileFrameCount * ratio) - int(m_frameCount); } pushBufferNonResampling(m_resampleBuffer, out); @@ -394,7 +394,7 @@ } void -CodedAudioFileReader::getInterleavedFrames(size_t start, size_t count, +CodedAudioFileReader::getInterleavedFrames(int start, int count, SampleBlock &frames) const { // Lock is only required in CacheInMemory mode (the cache file @@ -421,11 +421,11 @@ if (count == 0) return; frames.reserve(count * m_channelCount); - size_t idx = start * m_channelCount; - size_t i = 0; + int idx = start * m_channelCount; + int i = 0; m_dataLock.lockForRead(); - while (i < count * m_channelCount && idx < m_data.size()) { + while (i < count * m_channelCount && idx < (int)m_data.size()) { frames.push_back(m_data[idx]); ++idx; }