Mercurial > hg > svcore
comparison data/model/ReadOnlyWaveFileModel.cpp @ 1766:85b9b466a59f
Merge from branch by-id
author | Chris Cannam |
---|---|
date | Wed, 17 Jul 2019 14:24:51 +0100 |
parents | 6d09d68165a4 |
children | 73447d746db3 |
comparison
equal
deleted
inserted
replaced
1730:649ac57c5a2d | 1766:85b9b466a59f |
---|---|
19 #include "fileio/AudioFileReaderFactory.h" | 19 #include "fileio/AudioFileReaderFactory.h" |
20 | 20 |
21 #include "system/System.h" | 21 #include "system/System.h" |
22 | 22 |
23 #include "base/Preferences.h" | 23 #include "base/Preferences.h" |
24 #include "base/PlayParameterRepository.h" | |
24 | 25 |
25 #include <QFileInfo> | 26 #include <QFileInfo> |
26 #include <QTextStream> | 27 #include <QTextStream> |
27 | 28 |
28 #include <iostream> | 29 #include <iostream> |
29 //#include <unistd.h> | |
30 #include <cmath> | 30 #include <cmath> |
31 #include <sndfile.h> | 31 #include <sndfile.h> |
32 | 32 |
33 #include <cassert> | 33 #include <cassert> |
34 | 34 |
83 } | 83 } |
84 | 84 |
85 if (m_reader) setObjectName(m_reader->getTitle()); | 85 if (m_reader) setObjectName(m_reader->getTitle()); |
86 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); | 86 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); |
87 if (isOK()) fillCache(); | 87 if (isOK()) fillCache(); |
88 | |
89 PlayParameterRepository::getInstance()->addPlayable | |
90 (getId().untyped, this); | |
88 } | 91 } |
89 | 92 |
90 ReadOnlyWaveFileModel::ReadOnlyWaveFileModel(FileSource source, AudioFileReader *reader) : | 93 ReadOnlyWaveFileModel::ReadOnlyWaveFileModel(FileSource source, AudioFileReader *reader) : |
91 m_source(source), | 94 m_source(source), |
92 m_path(source.getLocation()), | 95 m_path(source.getLocation()), |
104 | 107 |
105 m_reader = reader; | 108 m_reader = reader; |
106 if (m_reader) setObjectName(m_reader->getTitle()); | 109 if (m_reader) setObjectName(m_reader->getTitle()); |
107 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); | 110 if (objectName() == "") setObjectName(QFileInfo(m_path).fileName()); |
108 fillCache(); | 111 fillCache(); |
112 | |
113 PlayParameterRepository::getInstance()->addPlayable | |
114 (getId().untyped, this); | |
109 } | 115 } |
110 | 116 |
111 ReadOnlyWaveFileModel::~ReadOnlyWaveFileModel() | 117 ReadOnlyWaveFileModel::~ReadOnlyWaveFileModel() |
112 { | 118 { |
119 PlayParameterRepository::getInstance()->removePlayable | |
120 (getId().untyped); | |
121 | |
113 m_exiting = true; | 122 m_exiting = true; |
114 if (m_fillThread) m_fillThread->wait(); | 123 if (m_fillThread) m_fillThread->wait(); |
115 if (m_myReader) delete m_reader; | 124 if (m_myReader) delete m_reader; |
116 m_reader = nullptr; | 125 m_reader = nullptr; |
117 | 126 |
579 sv_frame_t fillExtent = m_fillThread->getFillExtent(); | 588 sv_frame_t fillExtent = m_fillThread->getFillExtent(); |
580 #ifdef DEBUG_WAVE_FILE_MODEL | 589 #ifdef DEBUG_WAVE_FILE_MODEL |
581 SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::fillTimerTimedOut: extent = " << fillExtent << endl; | 590 SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::fillTimerTimedOut: extent = " << fillExtent << endl; |
582 #endif | 591 #endif |
583 if (fillExtent > m_lastFillExtent) { | 592 if (fillExtent > m_lastFillExtent) { |
584 emit modelChangedWithin(m_lastFillExtent, fillExtent); | 593 emit modelChangedWithin(getId(), m_lastFillExtent, fillExtent); |
585 m_lastFillExtent = fillExtent; | 594 m_lastFillExtent = fillExtent; |
586 } | 595 } |
587 } else { | 596 } else { |
588 #ifdef DEBUG_WAVE_FILE_MODEL | 597 #ifdef DEBUG_WAVE_FILE_MODEL |
589 SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::fillTimerTimedOut: no thread" << endl; | 598 SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::fillTimerTimedOut: no thread" << endl; |
590 #endif | 599 #endif |
591 emit modelChanged(); | 600 emit modelChanged(getId()); |
592 } | 601 } |
593 } | 602 } |
594 | 603 |
595 void | 604 void |
596 ReadOnlyWaveFileModel::cacheFilled() | 605 ReadOnlyWaveFileModel::cacheFilled() |
605 m_mutex.unlock(); | 614 m_mutex.unlock(); |
606 #ifdef DEBUG_WAVE_FILE_MODEL | 615 #ifdef DEBUG_WAVE_FILE_MODEL |
607 SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::cacheFilled, about to emit things" << endl; | 616 SVDEBUG << "ReadOnlyWaveFileModel(" << objectName() << ")::cacheFilled, about to emit things" << endl; |
608 #endif | 617 #endif |
609 if (getEndFrame() > prevFillExtent) { | 618 if (getEndFrame() > prevFillExtent) { |
610 emit modelChangedWithin(prevFillExtent, getEndFrame()); | 619 emit modelChangedWithin(getId(), prevFillExtent, getEndFrame()); |
611 } | 620 } |
612 emit modelChanged(); | 621 emit modelChanged(getId()); |
613 emit ready(); | 622 emit ready(getId()); |
614 } | 623 } |
615 | 624 |
616 void | 625 void |
617 ReadOnlyWaveFileModel::RangeCacheFillThread::run() | 626 ReadOnlyWaveFileModel::RangeCacheFillThread::run() |
618 { | 627 { |