changes to help strp silence
[ardour.git] / libs / ardour / audioregion.cc
index abddffc12e887dce54a7f7fbbf9b11469817a839..2cdb0dfbd12095e5745ed033446086b4f2ecdb5c 100644 (file)
@@ -1458,7 +1458,7 @@ then quit ardour and restart."));
  */
 
 std::list<std::pair<frameoffset_t, framecnt_t> >
-AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
+AudioRegion::find_silence (Sample threshold, framecnt_t min_length, InterThreadInfo& itt) const
 {
        framecnt_t const block_size = 64 * 1024;
        Sample loudest[block_size];
@@ -1473,7 +1473,7 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
        frameoffset_t silence_start = 0;
        bool silence;
 
-       while (pos < end) {
+       while (pos < end && !itt.cancel) {
 
                /* fill `loudest' with the loudest absolute sample at each instant, across all channels */
                memset (loudest, 0, sizeof (Sample) * block_size);
@@ -1502,6 +1502,7 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
                }
 
                pos += block_size;
+                itt.progress = (end-pos)/(double)_length;
        }
 
        if (in_silence && end - 1 - silence_start >= min_length) {
@@ -1509,6 +1510,8 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
                silent_periods.push_back (std::make_pair (silence_start, end));
        }
 
+        itt.done = true;
+
        return silent_periods;
 }