comparison data/fileio/CodedAudioFileReader.cpp @ 1326:54af1e21705c 3.0-integration

Update to use bqvec allocator for float vectors
author Chris Cannam
date Tue, 13 Dec 2016 15:23:21 +0000
parents 4dbb7a7c9c28
children 5b04b8bc88ca
comparison
equal deleted inserted replaced
1325:3aea4f7617bb 1326:54af1e21705c
287 pushCacheWriteBufferMaybe(false); 287 pushCacheWriteBufferMaybe(false);
288 } 288 }
289 } 289 }
290 290
291 void 291 void
292 CodedAudioFileReader::addSamplesToDecodeCache(const vector<float> &samples) 292 CodedAudioFileReader::addSamplesToDecodeCache(const floatvec_t &samples)
293 { 293 {
294 QMutexLocker locker(&m_cacheMutex); 294 QMutexLocker locker(&m_cacheMutex);
295 295
296 if (!m_initialised) return; 296 if (!m_initialised) return;
297 297
524 pushBufferNonResampling(m_resampleBuffer, out); 524 pushBufferNonResampling(m_resampleBuffer, out);
525 delete[] padding; 525 delete[] padding;
526 } 526 }
527 } 527 }
528 528
529 vector<float> 529 floatvec_t
530 CodedAudioFileReader::getInterleavedFrames(sv_frame_t start, sv_frame_t count) const 530 CodedAudioFileReader::getInterleavedFrames(sv_frame_t start, sv_frame_t count) const
531 { 531 {
532 // Lock is only required in CacheInMemory mode (the cache file 532 // Lock is only required in CacheInMemory mode (the cache file
533 // reader is expected to be thread safe and manage its own 533 // reader is expected to be thread safe and manage its own
534 // locking) 534 // locking)
536 if (!m_initialised) { 536 if (!m_initialised) {
537 SVDEBUG << "CodedAudioFileReader::getInterleavedFrames: not initialised" << endl; 537 SVDEBUG << "CodedAudioFileReader::getInterleavedFrames: not initialised" << endl;
538 return {}; 538 return {};
539 } 539 }
540 540
541 vector<float> frames; 541 floatvec_t frames;
542 542
543 switch (m_cacheMode) { 543 switch (m_cacheMode) {
544 544
545 case CacheInTemporaryFile: 545 case CacheInTemporaryFile:
546 if (m_cacheFileReader) { 546 if (m_cacheFileReader) {
562 // really have threads taking a long time to read concurrently 562 // really have threads taking a long time to read concurrently
563 m_dataLock.lock(); 563 m_dataLock.lock();
564 sv_frame_t n = sv_frame_t(m_data.size()); 564 sv_frame_t n = sv_frame_t(m_data.size());
565 if (ix0 > n) ix0 = n; 565 if (ix0 > n) ix0 = n;
566 if (ix1 > n) ix1 = n; 566 if (ix1 > n) ix1 = n;
567 frames = vector<float>(m_data.begin() + ix0, m_data.begin() + ix1); 567 frames = floatvec_t(m_data.begin() + ix0, m_data.begin() + ix1);
568 m_dataLock.unlock(); 568 m_dataLock.unlock();
569 break; 569 break;
570 } 570 }
571 } 571 }
572 572