summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-04-30 18:45:45 +0000
committerCarl Hetherington <carl@carlh.net>2009-04-30 18:45:45 +0000
commitc724b85839d8869a7b08470e11e42e741db46322 (patch)
tree06a6fff00e4ed5b0c5286e0e8f0bc974a9799b72 /libs
parent62fe887e24db45573a1b290fa40af787c99aed2a (diff)
Fix a couple of valgrind-spotted out-of-bounds accesses that may have been causing segfaults, especially when opening the crossfade editor dialog. Some minor cleanups. Add some comments.
git-svn-id: svn://localhost/ardour2/branches/3.0@5020 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/audiosource.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index 25094389a0..17c20e05ee 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -283,6 +283,10 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, sframes_t start, nfr
return read_peaks_with_fpp (peaks, npeaks, start, cnt, samples_per_visual_peak, _FPP);
}
+/** @param peaks Buffer to write peak data.
+ * @param npeaks Number of peaks to write.
+ */
+
int
AudioSource::read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, sframes_t start, nframes_t cnt,
double samples_per_visual_peak, nframes_t samples_per_file_peak) const
@@ -325,9 +329,9 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, sframes_t s
npeaks = min ((nframes_t) floor (cnt / samples_per_visual_peak), npeaks);
zero_fill = old - npeaks;
}
-
- // cerr << "actual npeaks = " << npeaks << " zf = " << zero_fill << endl;
+ // cerr << "actual npeaks = " << npeaks << " zf = " << zero_fill << endl;
+
if (npeaks == cnt) {
#ifdef DEBUG_READ_PEAKS
@@ -536,7 +540,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, sframes_t s
while (nvisual_peaks < npeaks) {
if (i == frames_read) {
-
+
to_read = min (chunksize, nframes_t(_length - current_frame));
if (to_read == 0) {
@@ -544,6 +548,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, sframes_t s
and fix it rather than do this band-aid move.
*/
zero_fill = npeaks - nvisual_peaks;
+ npeaks -= zero_fill;
break;
}