shithub: sox

Download patch

ref: 27ea352ac4bb1955378d29e9f2fdbe9a8c589a31
parent: 7d7087645e49a02c8cd3b3a45ab1d71451e26284
author: Ulrich Klauer <ulrich@chirlu.de>
date: Mon Jan 23 04:26:27 EST 2012

trim: don't issue unnecessary warning

trim would warn about not reaching the final position if the specified
end coincided with the actual end of audio, as in "trim -10 -0" (last
ten seconds of the input). This is of course unnecessary and
confusing, so don't do it.

--- a/src/trim.c
+++ b/src/trim.c
@@ -182,7 +182,10 @@
 {
   priv_t *p = (priv_t*) effp->priv;
   *osamp = 0;
-  if (p->current_pos < p->num_pos)
+  if (! (p->current_pos + 1 == p->num_pos &&
+         p->pos[p->current_pos].sample == p->samples_read &&
+         p->copying) /* would stop here anyway */
+      && p->current_pos < p->num_pos)
     lsx_warn("Audio shorter than expected; last %u positions not reached.",
       p->num_pos - p->current_pos);
   return SOX_EOF;