shithub: sox

Download patch

ref: 298391c15ce518d8aeb60d71d8675ee0c6c11e1b
parent: 88c96437a0457c65e51340b429307e7259ee4764
author: Ulrich Klauer <ulrich@chirlu.de>
date: Fri Jan 27 07:55:32 EST 2012

trim: reword warnings again

Again change the warning messages about positions after end-of-audio
to make more sense.

--- a/src/trim.c
+++ b/src/trim.c
@@ -116,8 +116,8 @@
   if (p->num_pos && in_length != SOX_UNKNOWN_LEN)
     if (p->pos[0].sample > in_length ||
         p->pos[p->num_pos-1].sample > in_length)
-      lsx_warn("%s position after expected end of audio.",
-          p->pos[0].sample > in_length? "Start" : "End");
+      lsx_warn("%s position is after expected end of audio.",
+          p->pos[0].sample > in_length ? "Start" : "End");
 
   if (p->num_pos == 1 && !p->pos[0].sample)
     return SOX_EFF_NULL;
@@ -177,13 +177,20 @@
 static int drain(sox_effect_t *effp, sox_sample_t *obuf UNUSED, size_t *osamp)
 {
   priv_t *p = (priv_t*) effp->priv;
-  *osamp = 0;
-  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);
+  *osamp = 0; /* only checking for errors */
+
+  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++;
+  if (p->current_pos < p->num_pos)
+    lsx_warn("Last %u position(s) not reached%s.",
+      p->num_pos - p->current_pos,
+      (effp->in_signal.length == SOX_UNKNOWN_LEN ||
+       effp->in_signal.length/effp->in_signal.channels == p->samples_read) ?
+      "" /* unknown length, or did already warn during start() */ :
+      " (audio shorter than expected)"
+      );
   return SOX_EOF;
 }