Mercurial > hg > svcore
comparison data/model/WritableWaveFileModel.cpp @ 1337:3dcd83595bc8 3.0-integration
Make writable model updating explicit rather than essentially an arbitrary hidden accident
author | Chris Cannam |
---|---|
date | Wed, 04 Jan 2017 14:22:39 +0000 |
parents | dc56e8a13e44 |
children | 87ae75da6527 |
comparison
equal
deleted
inserted
replaced
1336:dc56e8a13e44 | 1337:3dcd83595bc8 |
---|---|
118 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL | 118 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL |
119 // SVDEBUG << "WritableWaveFileModel::addSamples(" << count << ")" << endl; | 119 // SVDEBUG << "WritableWaveFileModel::addSamples(" << count << ")" << endl; |
120 #endif | 120 #endif |
121 | 121 |
122 if (!m_writer->writeSamples(samples, count)) { | 122 if (!m_writer->writeSamples(samples, count)) { |
123 cerr << "ERROR: WritableWaveFileModel::addSamples: writer failed: " << m_writer->getError() << endl; | 123 SVCERR << "ERROR: WritableWaveFileModel::addSamples: writer failed: " << m_writer->getError() << endl; |
124 return false; | 124 return false; |
125 } | 125 } |
126 | 126 |
127 m_frameCount += count; | 127 m_frameCount += count; |
128 | 128 |
129 static int updateCounter = 0; | |
130 | |
131 if (m_reader && m_reader->getChannelCount() == 0) { | 129 if (m_reader && m_reader->getChannelCount() == 0) { |
132 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL | |
133 SVDEBUG << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (initial)" << endl; | |
134 #endif | |
135 m_reader->updateFrameCount(); | 130 m_reader->updateFrameCount(); |
136 } else if (++updateCounter == 100) { | |
137 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL | |
138 SVDEBUG << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (periodic)" << endl; | |
139 #endif | |
140 if (m_reader) m_reader->updateFrameCount(); | |
141 updateCounter = 0; | |
142 } | 131 } |
143 | 132 |
144 return true; | 133 return true; |
134 } | |
135 | |
136 void | |
137 WritableWaveFileModel::updateModel() | |
138 { | |
139 if (m_reader) { | |
140 m_reader->updateFrameCount(); | |
141 } | |
145 } | 142 } |
146 | 143 |
147 bool | 144 bool |
148 WritableWaveFileModel::isOK() const | 145 WritableWaveFileModel::isOK() const |
149 { | 146 { |