13
0

Use boost::scoped_array in AudioSource::build_peaks_from_scratch

This commit is contained in:
Paul Davis 2013-07-13 17:43:36 -04:00
parent ebdf73a077
commit 90c2a1c69d

View File

@ -584,8 +584,6 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
int
AudioSource::build_peaks_from_scratch ()
{
Sample* buf = 0;
const framecnt_t bufsize = 65536; // 256kB per disk read for mono data is about ideal
DEBUG_TRACE (DEBUG::Peaks, "Building peaks from scratch\n");
@ -605,20 +603,20 @@ AudioSource::build_peaks_from_scratch ()
framecnt_t cnt = _length;
_peaks_built = false;
buf = new Sample[bufsize];
boost::scoped_array<Sample> buf(new Sample[bufsize]);
while (cnt) {
framecnt_t frames_to_read = min (bufsize, cnt);
framecnt_t frames_read;
if ((frames_read = read_unlocked (buf, current_frame, frames_to_read)) != frames_to_read) {
if ((frames_read = read_unlocked (buf.get(), current_frame, frames_to_read)) != frames_to_read) {
error << string_compose(_("%1: could not write read raw data for peak computation (%2)"), _name, strerror (errno)) << endmsg;
done_with_peakfile_writes (false);
goto out;
}
if (compute_and_write_peaks (buf, current_frame, frames_read, true, false, _FPP)) {
if (compute_and_write_peaks (buf.get(), current_frame, frames_read, true, false, _FPP)) {
break;
}
@ -643,8 +641,6 @@ AudioSource::build_peaks_from_scratch ()
unlink (peakpath.c_str());
}
delete [] buf;
return ret;
}