comparison data/fileio/CodedAudioFileReader.cpp @ 1282:56c06dc0937c 3.0-integration

Avoid potentially trying to allocate negative-sized vector!
author Chris Cannam
date Wed, 23 Nov 2016 10:35:10 +0000
parents 0a9193dc136b
children 757a406dabc4 4704e834d0f9
comparison
equal deleted inserted replaced
1281:6463046bd21d 1282:56c06dc0937c
478 // its lock mechanism is significantly slower than QMutex so 478 // its lock mechanism is significantly slower than QMutex so
479 // it's not a good idea in cases like this where we don't 479 // it's not a good idea in cases like this where we don't
480 // really have threads taking a long time to read concurrently 480 // really have threads taking a long time to read concurrently
481 m_dataLock.lock(); 481 m_dataLock.lock();
482 sv_frame_t n = sv_frame_t(m_data.size()); 482 sv_frame_t n = sv_frame_t(m_data.size());
483 if (ix0 > n) ix0 = n;
483 if (ix1 > n) ix1 = n; 484 if (ix1 > n) ix1 = n;
484 frames = vector<float>(m_data.begin() + ix0, m_data.begin() + ix1); 485 frames = vector<float>(m_data.begin() + ix0, m_data.begin() + ix1);
485 m_dataLock.unlock(); 486 m_dataLock.unlock();
487 break;
486 } 488 }
487 } 489 }
488 490
489 if (m_normalised) { 491 if (m_normalised) {
490 for (auto &f: frames) f *= m_gain; 492 for (auto &f: frames) f *= m_gain;