summaryrefslogtreecommitdiff
path: root/libs/ardour/audiosource.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-04-15 20:42:05 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-04-15 20:42:05 +0000
commitdc815ea8e84d28fc01a68225c2ece4399c4a9c7e (patch)
tree27954a7b74ea3df1ca87d0ece20ad15a6f46f6be /libs/ardour/audiosource.cc
parentd2beb38ea9fb39dbfb8667784bd248b32d171cbf (diff)
forward-port from 2.X commits 5827-6000 including
git-svn-id: svn://localhost/ardour2/branches/3.0@6914 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audiosource.cc')
-rw-r--r--libs/ardour/audiosource.cc38
1 files changed, 23 insertions, 15 deletions
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index 8a367f32a7..60bd5804b3 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -548,22 +548,30 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
to_read = min (chunksize, (framecnt_t)(_length - current_frame));
- if (to_read == 0) {
- /* XXX ARGH .. out by one error ... need to figure out why this happens
- and fix it rather than do this band-aid move.
- */
- zero_fill = npeaks - nvisual_peaks;
- npeaks -= zero_fill;
- break;
- }
-
- if ((frames_read = read_unlocked (raw_staging, current_frame, to_read)) == 0) {
- error << string_compose(_("AudioSource[%1]: peak read - cannot read %2 samples at offset %3 of %4 (%5)"),
- _name, to_read, current_frame, _length, strerror (errno))
- << endmsg;
- goto out;
- }
+ if (current_frame >= _length) {
+ /* hmm, error condition - we've reached the end of the file
+ without generating all the peak data. cook up a zero-filled
+ data buffer and then use it. this is simpler than
+ adjusting zero_fill and npeaks and then breaking out of
+ this loop early
+ */
+
+ memset (raw_staging, 0, sizeof (Sample) * chunksize);
+
+ } else {
+
+ to_read = min (chunksize, (_length - current_frame));
+
+
+ if ((frames_read = read_unlocked (raw_staging, current_frame, to_read)) == 0) {
+ error << string_compose(_("AudioSource[%1]: peak read - cannot read %2 samples at offset %3 of %4 (%5)"),
+ _name, to_read, current_frame, _length, strerror (errno))
+ << endmsg;
+ goto out;
+ }
+ }
+
i = 0;
}