comparison data/model/WaveFileModel.cpp @ 225:185454896a76

* Return ranges from RangeSummarisableTimeValueModel::getRanges by references instead of by return value. Trying to isolate a Win32 problem.
author Chris Cannam
date Wed, 07 Feb 2007 14:21:14 +0000
parents e2bbb58e6df6
children 03a24547cf3c
comparison
equal deleted inserted replaced
224:8ff1ad4e7a9c 225:185454896a76
216 } 216 }
217 217
218 return i; 218 return i;
219 } 219 }
220 220
221 WaveFileModel::RangeBlock 221 void
222 WaveFileModel::getRanges(size_t channel, size_t start, size_t end, 222 WaveFileModel::getRanges(size_t channel, size_t start, size_t end,
223 size_t &blockSize) const 223 RangeBlock &ranges, size_t &blockSize) const
224 { 224 {
225 RangeBlock ranges; 225 ranges.clear();
226 if (!isOK()) return ranges; 226 if (!isOK()) return;
227 227
228 if (end <= start) { 228 if (end <= start) {
229 std::cerr << "WARNING: Internal error: end <= start in WaveFileModel::getRanges (end = " << end << ", start = " << start << ", blocksize = " << blockSize << ")" << std::endl; 229 std::cerr << "WARNING: Internal error: end <= start in WaveFileModel::getRanges (end = " << end << ", start = " << start << ", blocksize = " << blockSize << ")" << std::endl;
230 return ranges; 230 return;
231 } 231 }
232 232
233 int cacheType = 0; 233 int cacheType = 0;
234 int power = m_zoomConstraint.getMinCachePower(); 234 int power = m_zoomConstraint.getMinCachePower();
235 blockSize = m_zoomConstraint.getNearestBlockSize 235 blockSize = m_zoomConstraint.getNearestBlockSize
274 274
275 if (count > 0) { 275 if (count > 0) {
276 ranges.push_back(Range(min, max, total / count)); 276 ranges.push_back(Range(min, max, total / count));
277 } 277 }
278 278
279 return ranges; 279 return;
280 280
281 } else { 281 } else {
282 282
283 QMutexLocker locker(&m_mutex); 283 QMutexLocker locker(&m_mutex);
284 284
326 ranges.push_back(Range(min, max, total / count)); 326 ranges.push_back(Range(min, max, total / count));
327 } 327 }
328 } 328 }
329 329
330 //cerr << "returning " << ranges.size() << " ranges" << endl; 330 //cerr << "returning " << ranges.size() << " ranges" << endl;
331 return ranges; 331 return;
332 } 332 }
333 333
334 WaveFileModel::Range 334 WaveFileModel::Range
335 WaveFileModel::getRange(size_t channel, size_t start, size_t end) const 335 WaveFileModel::getRange(size_t channel, size_t start, size_t end) const
336 { 336 {
352 size_t blockEnd = (end / blockSize) * blockSize; 352 size_t blockEnd = (end / blockSize) * blockSize;
353 353
354 if (blockStart < start) blockStart += blockSize; 354 if (blockStart < start) blockStart += blockSize;
355 355
356 if (blockEnd > blockStart) { 356 if (blockEnd > blockStart) {
357 RangeBlock ranges = getRanges(channel, blockStart, blockEnd, blockSize); 357 RangeBlock ranges;
358 getRanges(channel, blockStart, blockEnd, ranges, blockSize);
358 for (size_t i = 0; i < ranges.size(); ++i) { 359 for (size_t i = 0; i < ranges.size(); ++i) {
359 if (first || ranges[i].min < range.min) range.min = ranges[i].min; 360 if (first || ranges[i].min < range.min) range.min = ranges[i].min;
360 if (first || ranges[i].max > range.max) range.max = ranges[i].max; 361 if (first || ranges[i].max > range.max) range.max = ranges[i].max;
361 if (first || ranges[i].absmean < range.absmean) range.absmean = ranges[i].absmean; 362 if (first || ranges[i].absmean < range.absmean) range.absmean = ranges[i].absmean;
362 first = false; 363 first = false;