shithub: sox

Download patch

ref: cb22c2fa2c7711e009398fb6f8ddaccb2f5fa52e
parent: c33f3eb7efde0a2a201e57e4a6b9967e92c07b08
author: cbagwell <cbagwell>
date: Sun Mar 19 22:05:58 EST 2006

Make effects return EOF when no more samples.

--- a/src/earwax.c
+++ b/src/earwax.c
@@ -106,7 +106,7 @@
   earwax->tap = (st_sample_t*)malloc( sizeof(st_sample_t) * EARWAX_NUMTAPS );
   if( !earwax->tap ){
     st_fail("earwax: Cannot malloc %d bytes!\n", 
-	    sizeof(st_sample_t) * EARWAX_NUMTAPS );
+            sizeof(st_sample_t) * EARWAX_NUMTAPS );
     return (ST_EOF);
   }
 
@@ -170,7 +170,7 @@
   }
   *osamp = EARWAX_NUMTAPS-1;
 
-  return (ST_SUCCESS);
+  return (ST_EOF);
 }
 
 /*
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -592,7 +592,10 @@
     /* report... */
     *osamp = i;
 
-    return ST_SUCCESS;
+    if ((pitch->index - pitch->overlap) == 0)
+        return ST_EOF;
+    else
+        return ST_SUCCESS;
 }
     
 /*
--- a/src/speed.c
+++ b/src/speed.c
@@ -265,24 +265,27 @@
     {
         if (speed->state==sp_input)
         {
-          speed->ibuf[speed->index++] = ZERO;
-          i++;
-          if (speed->index==speed->compression)
-             speed->state = sp_transfer;
-      }
+            speed->ibuf[speed->index++] = ZERO;
+            i++;
+            if (speed->index==speed->compression)
+                speed->state = sp_transfer;
+        }
 
-      /* transfer to compute buffer. */
-      if (speed->state==sp_transfer)
-          transfer(speed);
+        /* transfer to compute buffer. */
+        if (speed->state==sp_transfer)
+            transfer(speed);
 
-      /* compute interpolation. */
-      if (speed->state==sp_compute)
-          oindex += compute(speed, obuf+oindex, *osamp-oindex);
+        /* compute interpolation. */
+        if (speed->state==sp_compute)
+            oindex += compute(speed, obuf+oindex, *osamp-oindex);
     }
 
     *osamp = oindex; /* report how much was generated. */
 
-    return ST_SUCCESS;
+    if (speed->state==sp_input)
+        return ST_EOF;
+    else
+        return ST_SUCCESS;
 }
 
 /* stop processing. report overflows. 
@@ -292,7 +295,7 @@
     speed_t speed = (speed_t) effp->priv;
 
     if (speed->clipped) 
-        st_warn("SPEED: %d values clipped...", speed->clipped);
+        st_report("SPEED: %d values clipped...", speed->clipped);
 
     free(speed->ibuf);
     
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -386,21 +386,21 @@
         stretch->state = output_state;
     }
 
-    if (stretch->state == output_state)
+    for (; oindex<*osamp && stretch->oindex<stretch->index;)
     {
-        for (; oindex<*osamp && stretch->oindex<stretch->index;)
-        {
-            float f;
+        float f;
 
-            f = stretch->obuf[stretch->oindex++];
-            ST_SAMPLE_CLIP_COUNT(f, stretch->clipped);
-            obuf[oindex++] = f;
-        }
+        f = stretch->obuf[stretch->oindex++];
+        ST_SAMPLE_CLIP_COUNT(f, stretch->clipped);
+        obuf[oindex++] = f;
     }
     
     *osamp = oindex;
 
-    return ST_SUCCESS;
+    if (stretch->oindex == stretch->index)
+        return ST_EOF;
+    else
+        return ST_SUCCESS;
 }