Fix issue #0006806
authorfeandin <feandin@gmail.com>
Fri, 4 Mar 2016 19:07:15 +0000 (20:07 +0100)
committerRobin Gareus <robin@gareus.org>
Sat, 5 Mar 2016 14:54:47 +0000 (15:54 +0100)
libs/ardour/audioregion.cc

index ddd152bf0e89413dbfc8f9010d9e218752dc99fd..6b549b3d13fc9c7ff7926d9652fd47fc1cf91cc0 100644 (file)
@@ -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]));
                        }