From bf83093f43ac13bcadece6e451055d50c59e7787 Mon Sep 17 00:00:00 2001 From: feandin Date: Fri, 4 Mar 2016 20:07:15 +0100 Subject: [PATCH] Fix issue #0006806 --- libs/ardour/audioregion.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index ddd152bf0e..6b549b3d13 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -1817,11 +1817,13 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length, framecnt_t f while (pos < end && !itt.cancel) { framecnt_t cur_samples = 0; + framecnt_t const to_read = min (end - pos, block_size); /* fill `loudest' with the loudest absolute sample at each instant, across all channels */ memset (loudest.get(), 0, sizeof (Sample) * block_size); + for (uint32_t n = 0; n < n_channels(); ++n) { - cur_samples = read_raw_internal (buf.get(), pos, block_size, n); + cur_samples = read_raw_internal (buf.get(), pos, to_read, n); for (framecnt_t i = 0; i < cur_samples; ++i) { loudest[i] = max (loudest[i], abs (buf[i])); }