Mercurial > hg > svcore
diff 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 |
line wrap: on
line diff
--- a/data/model/WritableWaveFileModel.cpp Mon Oct 12 15:06:15 2015 +0100 +++ b/data/model/WritableWaveFileModel.cpp Tue Oct 13 14:26:40 2015 +0100 @@ -32,6 +32,8 @@ using namespace std; +const int WritableWaveFileModel::PROPORTION_UNKNOWN = -1; + //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1 WritableWaveFileModel::WritableWaveFileModel(sv_samplerate_t sampleRate, @@ -44,7 +46,7 @@ m_channels(channels), m_frameCount(0), m_startFrame(0), - m_completion(0) + m_proportion(PROPORTION_UNKNOWN) { if (path.isEmpty()) { try { @@ -153,17 +155,30 @@ bool WritableWaveFileModel::isReady(int *completion) const { - if (completion) *completion = m_completion; - return (m_completion == 100); + int c = getCompletion(); + if (completion) *completion = c; + if (!isOK()) return false; + return (c == 100); } void -WritableWaveFileModel::setCompletion(int completion) +WritableWaveFileModel::setWriteProportion(int proportion) { - m_completion = completion; - if (completion == 100) { - if (m_reader) m_reader->updateDone(); - } + m_proportion = proportion; +} + +int +WritableWaveFileModel::getWriteProportion() const +{ + return m_proportion; +} + +void +WritableWaveFileModel::writeComplete() +{ + if (m_reader) m_reader->updateDone(); + m_proportion = 100; + emit modelChanged(); } sv_frame_t