changeset 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 8ff1ad4e7a9c
children a867be73b638
files data/model/RangeSummarisableTimeValueModel.h data/model/WaveFileModel.cpp data/model/WaveFileModel.h data/model/WritableWaveFileModel.cpp data/model/WritableWaveFileModel.h
diffstat 5 files changed, 22 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/RangeSummarisableTimeValueModel.h	Thu Feb 01 14:31:28 2007 +0000
+++ b/data/model/RangeSummarisableTimeValueModel.h	Wed Feb 07 14:21:14 2007 +0000
@@ -58,8 +58,9 @@
      * parameter so as to return the block size that was actually
      * obtained.
      */
-    virtual RangeBlock getRanges(size_t channel, size_t start, size_t end,
-				 size_t &blockSize) const = 0;
+    virtual void getRanges(size_t channel, size_t start, size_t end,
+                           RangeBlock &ranges,
+                           size_t &blockSize) const = 0;
 
     /**
      * Return the range between the given start and end frames,
--- a/data/model/WaveFileModel.cpp	Thu Feb 01 14:31:28 2007 +0000
+++ b/data/model/WaveFileModel.cpp	Wed Feb 07 14:21:14 2007 +0000
@@ -218,16 +218,16 @@
     return i;
 }
 
-WaveFileModel::RangeBlock
+void
 WaveFileModel::getRanges(size_t channel, size_t start, size_t end,
-			 size_t &blockSize) const
+                         RangeBlock &ranges, size_t &blockSize) const
 {
-    RangeBlock ranges;
-    if (!isOK()) return ranges;
+    ranges.clear();
+    if (!isOK()) return;
 
     if (end <= start) {
 	std::cerr << "WARNING: Internal error: end <= start in WaveFileModel::getRanges (end = " << end << ", start = " << start << ", blocksize = " << blockSize << ")" << std::endl;
-	return ranges;
+	return;
     }
 
     int cacheType = 0;
@@ -276,7 +276,7 @@
             ranges.push_back(Range(min, max, total / count));
 	}
 
-	return ranges;
+	return;
 
     } else {
 
@@ -328,7 +328,7 @@
     }
 
     //cerr << "returning " << ranges.size() << " ranges" << endl;
-    return ranges;
+    return;
 }
 
 WaveFileModel::Range
@@ -354,7 +354,8 @@
     if (blockStart < start) blockStart += blockSize;
         
     if (blockEnd > blockStart) {
-        RangeBlock ranges = getRanges(channel, blockStart, blockEnd, blockSize);
+        RangeBlock ranges;
+        getRanges(channel, blockStart, blockEnd, ranges, blockSize);
         for (size_t i = 0; i < ranges.size(); ++i) {
             if (first || ranges[i].min < range.min) range.min = ranges[i].min;
             if (first || ranges[i].max > range.max) range.max = ranges[i].max;
--- a/data/model/WaveFileModel.h	Thu Feb 01 14:31:28 2007 +0000
+++ b/data/model/WaveFileModel.h	Wed Feb 07 14:21:14 2007 +0000
@@ -60,8 +60,9 @@
     virtual size_t getValues(int channel, size_t start, size_t end,
 			     double *buffer) const;
 
-    virtual RangeBlock getRanges(size_t channel, size_t start, size_t end,
-				 size_t &blockSize) const;
+    virtual void getRanges(size_t channel, size_t start, size_t end,
+                           RangeBlock &ranges,
+                           size_t &blockSize) const;
 
     virtual Range getRange(size_t channel, size_t start, size_t end) const;
 
--- a/data/model/WritableWaveFileModel.cpp	Thu Feb 01 14:31:28 2007 +0000
+++ b/data/model/WritableWaveFileModel.cpp	Wed Feb 07 14:21:14 2007 +0000
@@ -167,12 +167,14 @@
     return m_model->getValues(channel, start, end, buffer);
 }
 
-WritableWaveFileModel::RangeBlock
+void
 WritableWaveFileModel::getRanges(size_t channel, size_t start, size_t end,
+                                 RangeBlock &ranges,
                                  size_t &blockSize) const
 {
-    if (!m_model || m_model->getChannelCount() == 0) return RangeBlock();
-    return m_model->getRanges(channel, start, end, blockSize);
+    ranges.clear();
+    if (!m_model || m_model->getChannelCount() == 0) return;
+    m_model->getRanges(channel, start, end, ranges, blockSize);
 }
 
 WritableWaveFileModel::Range
--- a/data/model/WritableWaveFileModel.h	Thu Feb 01 14:31:28 2007 +0000
+++ b/data/model/WritableWaveFileModel.h	Wed Feb 07 14:21:14 2007 +0000
@@ -66,8 +66,8 @@
     virtual size_t getValues(int channel, size_t start, size_t end,
 			     double *buffer) const;
 
-    virtual RangeBlock getRanges(size_t channel, size_t start, size_t end,
-				 size_t &blockSize) const;
+    virtual void getRanges(size_t channel, size_t start, size_t end,
+                           RangeBlock &ranges, size_t &blockSize) const;
 
     virtual Range getRange(size_t channel, size_t start, size_t end) const;