Mercurial > hg > svcore
comparison data/model/WaveFileModel.cpp @ 265:e08f486e8d8c
* Enable threaded decoding for Ogg and MP3 files.
Needs some work on reducing updates to the overview widget
author | Chris Cannam |
---|---|
date | Wed, 06 Jun 2007 16:24:55 +0000 |
parents | 96a6dd889c68 |
children | 2268963dabd1 |
comparison
equal
deleted
inserted
replaced
264:260032c26c4f | 265:e08f486e8d8c |
---|---|
94 bool | 94 bool |
95 WaveFileModel::isReady(int *completion) const | 95 WaveFileModel::isReady(int *completion) const |
96 { | 96 { |
97 bool ready = (isOK() && (m_fillThread == 0)); | 97 bool ready = (isOK() && (m_fillThread == 0)); |
98 double c = double(m_lastFillExtent) / double(getEndFrame() - getStartFrame()); | 98 double c = double(m_lastFillExtent) / double(getEndFrame() - getStartFrame()); |
99 if (completion) *completion = int(c * 100.0 + 0.01); | 99 if (completion) { |
100 *completion = int(c * 100.0 + 0.01); | |
101 if (m_reader) { | |
102 int decodeCompletion = m_reader->getDecodeCompletion(); | |
103 // std::cerr << "decodeCompletion " << decodeCompletion << ", completion " << *completion << std::endl; | |
104 // if (decodeCompletion < *completion) *completion = decodeCompletion; | |
105 if (decodeCompletion < 100) *completion = decodeCompletion; | |
106 } | |
107 } | |
100 #ifdef DEBUG_WAVE_FILE_MODEL | 108 #ifdef DEBUG_WAVE_FILE_MODEL |
101 std::cerr << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << std::endl; | 109 std::cerr << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << std::endl; |
102 #endif | 110 #endif |
103 return ready; | 111 return ready; |
104 } | 112 } |
484 | 492 |
485 // std::cerr << "WaveFileModel::fill: frame = " << frame << ", count = " << m_frameCount << std::endl; | 493 // std::cerr << "WaveFileModel::fill: frame = " << frame << ", count = " << m_frameCount << std::endl; |
486 | 494 |
487 while (frame < m_frameCount) { | 495 while (frame < m_frameCount) { |
488 | 496 |
497 // std::cerr << "WaveFileModel::fill inner loop: frame = " << frame << ", count = " << m_frameCount << ", blocksize " << readBlockSize << std::endl; | |
498 | |
489 if (updating && (frame + readBlockSize > m_frameCount)) break; | 499 if (updating && (frame + readBlockSize > m_frameCount)) break; |
490 | 500 |
491 m_model.m_reader->getInterleavedFrames(frame, readBlockSize, block); | 501 m_model.m_reader->getInterleavedFrames(frame, readBlockSize, block); |
502 | |
503 // std::cerr << "block is " << block.size() << std::endl; | |
492 | 504 |
493 for (size_t i = 0; i < readBlockSize; ++i) { | 505 for (size_t i = 0; i < readBlockSize; ++i) { |
494 | 506 |
495 if (channels * i + channels > block.size()) break; | 507 if (channels * i + channels > block.size()) break; |
496 | 508 |
536 if (m_model.m_exiting) break; | 548 if (m_model.m_exiting) break; |
537 | 549 |
538 m_fillExtent = frame; | 550 m_fillExtent = frame; |
539 } | 551 } |
540 | 552 |
553 // std::cerr << "WaveFileModel: inner loop ended" << std::endl; | |
554 | |
541 first = false; | 555 first = false; |
542 if (m_model.m_exiting) break; | 556 if (m_model.m_exiting) break; |
543 if (updating) { | 557 if (updating) { |
558 // std::cerr << "sleeping..." << std::endl; | |
544 sleep(1); | 559 sleep(1); |
545 } | 560 } |
546 } | 561 } |
547 | 562 |
548 if (!m_model.m_exiting) { | 563 if (!m_model.m_exiting) { |