shithub: sox

Download patch

ref: cb3ed7449799a52613bd433da94b3fca5cc43115
parent: 17a5049aee249b1704d50145dcf160733d03f179
author: robs <robs>
date: Sat Mar 8 17:32:28 EST 2008

Fix ungraceful handling of out of disc space and other writeerrors

--- a/src/example1.c
+++ b/src/example1.c
@@ -40,13 +40,11 @@
 static int output_flow(sox_effect_t *effp UNUSED, sox_sample_t const * ibuf,
     sox_sample_t * obuf UNUSED, sox_size_t * isamp, sox_size_t * osamp)
 {
-  size_t len;
-  for (*osamp = *isamp; *osamp; ibuf += len, *osamp -= len) {
-    len = sox_write(out, ibuf, *osamp);
-    if (!len || out->sox_errno) {
-      fprintf(stderr, "%s: %s\n", out->filename, out->sox_errstr);
-      return SOX_EOF;
-    }
+  size_t len = sox_write(out, ibuf, *osamp);
+
+  if (len != *isamp) {
+    fprintf(stderr, "%s: %s\n", out->filename, out->sox_errstr);
+    return SOX_EOF;
   }
   return SOX_SUCCESS;
 }