shithub: sox

Download patch

ref: 1badd3e9314eb33b7766614cb80d183cfbe6060a
parent: fc127d048ad38130f355de822dccd899fc4086dc
author: Ulrich Klauer <ulrich@chirlu.de>
date: Sun Oct 21 16:34:16 EDT 2012

splice: set output length to unknown, not 0

In the splice effect, the output length was only set (to unknown) when it
was not needed, immediately before returning with SOX_EFF_NULL. This
resulted in an incorrect output length of 0 when the effect had work to
do. Move the relevant line of code to a more appropriate place.

--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,7 @@
 
   o Restore 8 seconds default for spectrogram, if the input length is
     not known. (Ulrich Klauer)
+  o Set output length for splice to unknown instead of 0. (Ulrich Klauer)
 
 Other bug fixes:
 
--- a/src/splice.c
+++ b/src/splice.c
@@ -179,6 +179,7 @@
   p->buffer = lsx_calloc(p->max_buffer_size * effp->in_signal.channels, sizeof(*p->buffer));
   p->in_pos = p->buffer_pos = p->splices_pos = 0;
   p->state = p->splices_pos != p->nsplices && p->in_pos == p->splices[p->splices_pos].start;
+  effp->out_signal.length = SOX_UNKNOWN_LEN; /* depends on input data */
   for (i = 0; i < p->nsplices; ++i)
     if (p->splices[i].overlap) {
       if (p->fade_type == Cosine_4 && effp->in_signal.mult)
@@ -185,7 +186,6 @@
         *effp->in_signal.mult *= pow(.5, .5);
       return SOX_SUCCESS;
     }
-  effp->out_signal.length = SOX_UNKNOWN_LEN; /* depends on input data */
   return SOX_EFF_NULL;
 }