summaryrefslogtreecommitdiff
path: root/libs/ardour/audiosource.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-07-13 17:42:34 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-07-13 17:42:34 -0400
commite5cc56a52303da563c98bae271ddcd9c07a5a22f (patch)
tree9beff0620a3ed686c4df07d89aaf77b7212f9a0c /libs/ardour/audiosource.cc
parentb84d032b3a25f6b3522ac179495e927ae886ca48 (diff)
Use boost::scoped_array for controlling scope of peak data in AudioSource::read_peaks
Diffstat (limited to 'libs/ardour/audiosource.cc')
-rw-r--r--libs/ardour/audiosource.cc7
1 files changed, 2 insertions, 5 deletions
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index 720cb481be..f3b6926c00 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -324,7 +324,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
uint32_t nread;
framecnt_t zero_fill = 0;
int ret = -1;
- PeakData* staging = 0;
boost::scoped_ptr<FdFileDescriptor> peakfile_descriptor(new FdFileDescriptor (peakpath, false, 0664));
int peakfile_fd = -1;
@@ -419,7 +418,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
const framecnt_t chunksize = (framecnt_t) min (expected_peaks, 65536.0);
- staging = new PeakData[chunksize];
+ boost::scoped_array<PeakData> staging(new PeakData[chunksize]);
/* compute the rounded up frame position */
@@ -440,7 +439,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
if ((peakfile_fd = peakfile_descriptor->allocate ()) < 0) {
error << string_compose(_("AudioSource: cannot open peakpath (b) \"%1\" (%2)"), peakpath, strerror (errno)) << endmsg;
- delete [] staging;
return 0;
}
@@ -456,7 +454,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
, sizeof (PeakData) * to_read, start_byte));
#ifndef WIN32
- if ((nread = ::pread (peakfile_fd, staging, sizeof (PeakData) * to_read, start_byte))
+ if ((nread = ::pread (peakfile_fd, staging.get(), sizeof (PeakData) * to_read, start_byte))
!= sizeof (PeakData) * to_read) {
off_t fend = lseek (peakfile_fd, 0, SEEK_END);
@@ -585,7 +583,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
}
out:
- delete [] staging;
DEBUG_TRACE (DEBUG::Peaks, "READPEAKS DONE\n");