Mercurial > hg > svcore
comparison data/model/WritableWaveFileModel.cpp @ 689:573d45e9487b
Merge from debug-output branch
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 14:47:59 +0100 |
parents | bcca512445f3 06f13a3b9e9e |
children | 1424aa29ae95 |
comparison
equal
deleted
inserted
replaced
688:be43b2fe68e8 | 689:573d45e9487b |
---|---|
55 // Write directly to the target file, so that we can do | 55 // Write directly to the target file, so that we can do |
56 // incremental writes and concurrent reads | 56 // incremental writes and concurrent reads |
57 m_writer = new WavFileWriter(path, sampleRate, channels, | 57 m_writer = new WavFileWriter(path, sampleRate, channels, |
58 WavFileWriter::WriteToTarget); | 58 WavFileWriter::WriteToTarget); |
59 if (!m_writer->isOK()) { | 59 if (!m_writer->isOK()) { |
60 std::cerr << "WritableWaveFileModel: Error in creating WAV file writer: " << m_writer->getError().toStdString() << std::endl; | 60 std::cerr << "WritableWaveFileModel: Error in creating WAV file writer: " << m_writer->getError() << std::endl; |
61 delete m_writer; | 61 delete m_writer; |
62 m_writer = 0; | 62 m_writer = 0; |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
107 WritableWaveFileModel::addSamples(float **samples, size_t count) | 107 WritableWaveFileModel::addSamples(float **samples, size_t count) |
108 { | 108 { |
109 if (!m_writer) return false; | 109 if (!m_writer) return false; |
110 | 110 |
111 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL | 111 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL |
112 // std::cerr << "WritableWaveFileModel::addSamples(" << count << ")" << std::endl; | 112 // DEBUG << "WritableWaveFileModel::addSamples(" << count << ")" << endl; |
113 #endif | 113 #endif |
114 | 114 |
115 if (!m_writer->writeSamples(samples, count)) { | 115 if (!m_writer->writeSamples(samples, count)) { |
116 std::cerr << "ERROR: WritableWaveFileModel::addSamples: writer failed: " << m_writer->getError().toStdString() << std::endl; | 116 std::cerr << "ERROR: WritableWaveFileModel::addSamples: writer failed: " << m_writer->getError() << std::endl; |
117 return false; | 117 return false; |
118 } | 118 } |
119 | 119 |
120 m_frameCount += count; | 120 m_frameCount += count; |
121 | 121 |
122 static int updateCounter = 0; | 122 static int updateCounter = 0; |
123 | 123 |
124 if (m_reader && m_reader->getChannelCount() == 0) { | 124 if (m_reader && m_reader->getChannelCount() == 0) { |
125 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL | 125 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL |
126 std::cerr << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (initial)" << std::endl; | 126 DEBUG << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (initial)" << endl; |
127 #endif | 127 #endif |
128 m_reader->updateFrameCount(); | 128 m_reader->updateFrameCount(); |
129 } else if (++updateCounter == 100) { | 129 } else if (++updateCounter == 100) { |
130 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL | 130 #ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL |
131 std::cerr << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (periodic)" << std::endl; | 131 DEBUG << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (periodic)" << endl; |
132 #endif | 132 #endif |
133 if (m_reader) m_reader->updateFrameCount(); | 133 if (m_reader) m_reader->updateFrameCount(); |
134 updateCounter = 0; | 134 updateCounter = 0; |
135 } | 135 } |
136 | 136 |
139 | 139 |
140 bool | 140 bool |
141 WritableWaveFileModel::isOK() const | 141 WritableWaveFileModel::isOK() const |
142 { | 142 { |
143 bool ok = (m_writer && m_writer->isOK()); | 143 bool ok = (m_writer && m_writer->isOK()); |
144 // std::cerr << "WritableWaveFileModel::isOK(): ok = " << ok << std::endl; | 144 // DEBUG << "WritableWaveFileModel::isOK(): ok = " << ok << endl; |
145 return ok; | 145 return ok; |
146 } | 146 } |
147 | 147 |
148 bool | 148 bool |
149 WritableWaveFileModel::isReady(int *completion) const | 149 WritableWaveFileModel::isReady(int *completion) const |
162 } | 162 } |
163 | 163 |
164 size_t | 164 size_t |
165 WritableWaveFileModel::getFrameCount() const | 165 WritableWaveFileModel::getFrameCount() const |
166 { | 166 { |
167 // std::cerr << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << std::endl; | 167 // DEBUG << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << endl; |
168 return m_frameCount; | 168 return m_frameCount; |
169 } | 169 } |
170 | 170 |
171 Model * | 171 Model * |
172 WritableWaveFileModel::clone() const | 172 WritableWaveFileModel::clone() const |