comparison data/model/WritableWaveFileModel.cpp @ 1133:e994747fb9dd tony-2.0-integration

Adjust model update during recording or writing a new wave file. Formerly we were using the model's completion percentage to indicate write proportion and completion -- that's not a good idea because some layers will reasonably avoid rendering at all until a model reaches 100% completion (it's supposed to report only progress on the initial model generation, and the model shouldn't change during completion updates).
author Chris Cannam
date Tue, 13 Oct 2015 14:26:40 +0100
parents efea94b04d5a
children 3aea4f7617bb
comparison
equal deleted inserted replaced
1131:db946591a391 1133:e994747fb9dd
30 #include <iostream> 30 #include <iostream>
31 #include <stdint.h> 31 #include <stdint.h>
32 32
33 using namespace std; 33 using namespace std;
34 34
35 const int WritableWaveFileModel::PROPORTION_UNKNOWN = -1;
36
35 //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1 37 //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1
36 38
37 WritableWaveFileModel::WritableWaveFileModel(sv_samplerate_t sampleRate, 39 WritableWaveFileModel::WritableWaveFileModel(sv_samplerate_t sampleRate,
38 int channels, 40 int channels,
39 QString path) : 41 QString path) :
42 m_reader(0), 44 m_reader(0),
43 m_sampleRate(sampleRate), 45 m_sampleRate(sampleRate),
44 m_channels(channels), 46 m_channels(channels),
45 m_frameCount(0), 47 m_frameCount(0),
46 m_startFrame(0), 48 m_startFrame(0),
47 m_completion(0) 49 m_proportion(PROPORTION_UNKNOWN)
48 { 50 {
49 if (path.isEmpty()) { 51 if (path.isEmpty()) {
50 try { 52 try {
51 QDir dir(TempDirectory::getInstance()->getPath()); 53 QDir dir(TempDirectory::getInstance()->getPath());
52 path = dir.filePath(QString("written_%1.wav") 54 path = dir.filePath(QString("written_%1.wav")
151 } 153 }
152 154
153 bool 155 bool
154 WritableWaveFileModel::isReady(int *completion) const 156 WritableWaveFileModel::isReady(int *completion) const
155 { 157 {
156 if (completion) *completion = m_completion; 158 int c = getCompletion();
157 return (m_completion == 100); 159 if (completion) *completion = c;
158 } 160 if (!isOK()) return false;
159 161 return (c == 100);
160 void 162 }
161 WritableWaveFileModel::setCompletion(int completion) 163
162 { 164 void
163 m_completion = completion; 165 WritableWaveFileModel::setWriteProportion(int proportion)
164 if (completion == 100) { 166 {
165 if (m_reader) m_reader->updateDone(); 167 m_proportion = proportion;
166 } 168 }
169
170 int
171 WritableWaveFileModel::getWriteProportion() const
172 {
173 return m_proportion;
174 }
175
176 void
177 WritableWaveFileModel::writeComplete()
178 {
179 if (m_reader) m_reader->updateDone();
180 m_proportion = 100;
181 emit modelChanged();
167 } 182 }
168 183
169 sv_frame_t 184 sv_frame_t
170 WritableWaveFileModel::getFrameCount() const 185 WritableWaveFileModel::getFrameCount() const
171 { 186 {