shithub: sox

Download patch

ref: 17513b0c9f08df3209cff8a06bbd1e67687e5499
parent: ed218d25d6e01167f8c3485d44b9d33e98a129c8
author: Ulrich Klauer <ulrich@chirlu.de>
date: Sat Jan 21 06:10:09 EST 2012

trim: fix default behaviour

trim without parameters should discard all audio for consistency. Might
be used when SoX commands are generated by a program.

--- a/src/trim.c
+++ b/src/trim.c
@@ -123,7 +123,7 @@
     return SOX_EOF;
   }
 
-  if (!p->num_pos || (p->num_pos == 1 && !p->pos[0].sample))
+  if (p->num_pos == 1 && !p->pos[0].sample)
     return SOX_EFF_NULL;
 
   /* calculate output length */
@@ -160,9 +160,10 @@
         p->samples_read == p->pos[p->current_pos].sample) {
       p->copying = !p->copying;
       p->current_pos++;
-      if (p->current_pos >= p->num_pos && !p->copying)
-        return SOX_EOF;
     }
+
+    if (p->current_pos >= p->num_pos && !p->copying)
+      return SOX_EOF;
 
     chunk = p->current_pos < p->num_pos ?
       min(len, p->pos[p->current_pos].sample - p->samples_read) : len;