Mercurial > hg > svcore
comparison data/model/WaveFileModel.cpp @ 687:06f13a3b9e9e debug-output
Convert many cerrs to DEBUGs
author | Chris Cannam |
---|---|
date | Mon, 16 May 2011 17:19:09 +0100 |
parents | d7f3dfe6f9a4 |
children | 1424aa29ae95 |
comparison
equal
deleted
inserted
replaced
686:b4a8d8221eaf | 687:06f13a3b9e9e |
---|---|
51 m_source.waitForData(); | 51 m_source.waitForData(); |
52 if (m_source.isOK()) { | 52 if (m_source.isOK()) { |
53 m_reader = AudioFileReaderFactory::createThreadingReader | 53 m_reader = AudioFileReaderFactory::createThreadingReader |
54 (m_source, targetRate); | 54 (m_source, targetRate); |
55 if (m_reader) { | 55 if (m_reader) { |
56 std::cerr << "WaveFileModel::WaveFileModel: reader rate: " | 56 DEBUG << "WaveFileModel::WaveFileModel: reader rate: " |
57 << m_reader->getSampleRate() << std::endl; | 57 << m_reader->getSampleRate() << endl; |
58 } | 58 } |
59 } | 59 } |
60 if (m_reader) setObjectName(m_reader->getTitle()); | 60 if (m_reader) setObjectName(m_reader->getTitle()); |
61 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); | 61 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); |
62 if (isOK()) fillCache(); | 62 if (isOK()) fillCache(); |
113 *completion = prevCompletion; | 113 *completion = prevCompletion; |
114 } | 114 } |
115 prevCompletion = *completion; | 115 prevCompletion = *completion; |
116 } | 116 } |
117 #ifdef DEBUG_WAVE_FILE_MODEL | 117 #ifdef DEBUG_WAVE_FILE_MODEL |
118 std::cerr << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << std::endl; | 118 DEBUG << "WaveFileModel::isReady(): ready = " << ready << ", completion = " << (completion ? *completion : -1) << endl; |
119 #endif | 119 #endif |
120 return ready; | 120 return ready; |
121 } | 121 } |
122 | 122 |
123 Model * | 123 Model * |
208 for (size_t i = 0; i < count; ++i) buffer[i] = 0.f; | 208 for (size_t i = 0; i < count; ++i) buffer[i] = 0.f; |
209 return 0; | 209 return 0; |
210 } | 210 } |
211 | 211 |
212 #ifdef DEBUG_WAVE_FILE_MODEL | 212 #ifdef DEBUG_WAVE_FILE_MODEL |
213 // std::cerr << "WaveFileModel::getValues(" << channel << ", " | 213 // DEBUG << "WaveFileModel::getValues(" << channel << ", " |
214 // << start << ", " << end << "): calling reader" << std::endl; | 214 // << start << ", " << end << "): calling reader" << endl; |
215 #endif | 215 #endif |
216 | 216 |
217 int channels = getChannelCount(); | 217 int channels = getChannelCount(); |
218 | 218 |
219 SampleBlock frames(count * channels); | 219 SampleBlock frames(count * channels); |
532 ranges.push_back(Range(min, max, total / got)); | 532 ranges.push_back(Range(min, max, total / got)); |
533 } | 533 } |
534 } | 534 } |
535 | 535 |
536 #ifdef DEBUG_WAVE_FILE_MODEL | 536 #ifdef DEBUG_WAVE_FILE_MODEL |
537 cerr << "returning " << ranges.size() << " ranges" << endl; | 537 DEBUG << "returning " << ranges.size() << " ranges" << endl; |
538 #endif | 538 #endif |
539 return; | 539 return; |
540 } | 540 } |
541 | 541 |
542 WaveFileModel::Range | 542 WaveFileModel::Range |
605 | 605 |
606 m_mutex.unlock(); | 606 m_mutex.unlock(); |
607 m_fillThread->start(); | 607 m_fillThread->start(); |
608 | 608 |
609 #ifdef DEBUG_WAVE_FILE_MODEL | 609 #ifdef DEBUG_WAVE_FILE_MODEL |
610 std::cerr << "WaveFileModel::fillCache: started fill thread" << std::endl; | 610 DEBUG << "WaveFileModel::fillCache: started fill thread" << endl; |
611 #endif | 611 #endif |
612 } | 612 } |
613 | 613 |
614 void | 614 void |
615 WaveFileModel::fillTimerTimedOut() | 615 WaveFileModel::fillTimerTimedOut() |
616 { | 616 { |
617 if (m_fillThread) { | 617 if (m_fillThread) { |
618 size_t fillExtent = m_fillThread->getFillExtent(); | 618 size_t fillExtent = m_fillThread->getFillExtent(); |
619 #ifdef DEBUG_WAVE_FILE_MODEL | 619 #ifdef DEBUG_WAVE_FILE_MODEL |
620 cerr << "WaveFileModel::fillTimerTimedOut: extent = " << fillExtent << endl; | 620 DEBUG << "WaveFileModel::fillTimerTimedOut: extent = " << fillExtent << endl; |
621 #endif | 621 #endif |
622 if (fillExtent > m_lastFillExtent) { | 622 if (fillExtent > m_lastFillExtent) { |
623 emit modelChanged(m_lastFillExtent, fillExtent); | 623 emit modelChanged(m_lastFillExtent, fillExtent); |
624 m_lastFillExtent = fillExtent; | 624 m_lastFillExtent = fillExtent; |
625 } | 625 } |
626 } else { | 626 } else { |
627 #ifdef DEBUG_WAVE_FILE_MODEL | 627 #ifdef DEBUG_WAVE_FILE_MODEL |
628 cerr << "WaveFileModel::fillTimerTimedOut: no thread" << std::endl; | 628 DEBUG << "WaveFileModel::fillTimerTimedOut: no thread" << endl; |
629 #endif | 629 #endif |
630 emit modelChanged(); | 630 emit modelChanged(); |
631 } | 631 } |
632 } | 632 } |
633 | 633 |
644 emit modelChanged(m_lastFillExtent, getEndFrame()); | 644 emit modelChanged(m_lastFillExtent, getEndFrame()); |
645 } | 645 } |
646 emit modelChanged(); | 646 emit modelChanged(); |
647 emit ready(); | 647 emit ready(); |
648 #ifdef DEBUG_WAVE_FILE_MODEL | 648 #ifdef DEBUG_WAVE_FILE_MODEL |
649 cerr << "WaveFileModel::cacheFilled" << endl; | 649 DEBUG << "WaveFileModel::cacheFilled" << endl; |
650 #endif | 650 #endif |
651 } | 651 } |
652 | 652 |
653 void | 653 void |
654 WaveFileModel::RangeCacheFillThread::run() | 654 WaveFileModel::RangeCacheFillThread::run() |
667 size_t channels = m_model.getChannelCount(); | 667 size_t channels = m_model.getChannelCount(); |
668 bool updating = m_model.m_reader->isUpdating(); | 668 bool updating = m_model.m_reader->isUpdating(); |
669 | 669 |
670 if (updating) { | 670 if (updating) { |
671 while (channels == 0 && !m_model.m_exiting) { | 671 while (channels == 0 && !m_model.m_exiting) { |
672 // std::cerr << "WaveFileModel::fill: Waiting for channels..." << std::endl; | 672 // DEBUG << "WaveFileModel::fill: Waiting for channels..." << endl; |
673 sleep(1); | 673 sleep(1); |
674 channels = m_model.getChannelCount(); | 674 channels = m_model.getChannelCount(); |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
688 while (first || updating) { | 688 while (first || updating) { |
689 | 689 |
690 updating = m_model.m_reader->isUpdating(); | 690 updating = m_model.m_reader->isUpdating(); |
691 m_frameCount = m_model.getFrameCount(); | 691 m_frameCount = m_model.getFrameCount(); |
692 | 692 |
693 // std::cerr << "WaveFileModel::fill: frame = " << frame << ", count = " << m_frameCount << std::endl; | 693 // DEBUG << "WaveFileModel::fill: frame = " << frame << ", count = " << m_frameCount << endl; |
694 | 694 |
695 while (frame < m_frameCount) { | 695 while (frame < m_frameCount) { |
696 | 696 |
697 // std::cerr << "WaveFileModel::fill inner loop: frame = " << frame << ", count = " << m_frameCount << ", blocksize " << readBlockSize << std::endl; | 697 // DEBUG << "WaveFileModel::fill inner loop: frame = " << frame << ", count = " << m_frameCount << ", blocksize " << readBlockSize << endl; |
698 | 698 |
699 if (updating && (frame + readBlockSize > m_frameCount)) break; | 699 if (updating && (frame + readBlockSize > m_frameCount)) break; |
700 | 700 |
701 m_model.m_reader->getInterleavedFrames(frame, readBlockSize, block); | 701 m_model.m_reader->getInterleavedFrames(frame, readBlockSize, block); |
702 | 702 |