shithub: sox

Download patch

ref: b3574439c0f95623ddcc9329ba35c43001bb0569
parent: c6059aab8534feeaeee7bd5504524bc1c74c8462
author: cbagwell <cbagwell>
date: Sun Sep 18 20:47:44 EDT 2005

Make sure all effects data buffers are looked at or lost data
can occur, especially with resample effects.

--- a/src/alsa.c
+++ b/src/alsa.c
@@ -90,7 +90,7 @@
     }
 
     /* set hardware resampling */
-    rate = 1;
+    rate = 0;
     err = snd_pcm_hw_params_set_rate_resample(alsa->pcm_handle, hw_params, 
                                               rate);
     if (err < 0) {
@@ -132,7 +132,6 @@
     }
 
     rate = ft->info.rate;
-#if 0
     snd_pcm_hw_params_get_rate_min(hw_params, &min_rate, &dir);
     snd_pcm_hw_params_get_rate_max(hw_params, &max_rate, &dir);
 
@@ -146,7 +145,6 @@
         st_report("alsa: Hardware does not support %d.  Forcing sample rate to %d.", ft->info.rate, rate);
         ft->info.rate = rate;
     }
-#endif
     dir = 0;
     if ((err = snd_pcm_hw_params_set_rate_near(alsa->pcm_handle, 
                                                hw_params, 
--- a/src/sox.c
+++ b/src/sox.c
@@ -1026,7 +1026,7 @@
     do {
       /* run entire chain BACKWARDS: pull, don't push.*/
       /* this is because buffering system isn't a nice queueing system */
-      for(e = neffects - 1; e > input_eff; e--)
+      for(e = neffects - 1; e >= input_eff; e--)
       {
           /* flow_effect returns ST_EOF when it will not process
            * any more samples.  This is used to bail out early.
@@ -1103,7 +1103,7 @@
        * show no more data.
        */
       havedata = 0;
-      for(e = neffects - 1; e > input_eff; e--)
+      for(e = neffects - 1; e >= input_eff; e--)
       {
           /* If odone and olen are the same then this buffer
            * can be reused.