shithub: opusfile

Download patch

ref: 9d825963310c744e8bd2c8ca03b7cdc99aae898e
parent: 1cea8f6bf1e3ffec1a408b3ead5e7ca2febf7419
author: Timothy B. Terriberry <tterribe@xiph.org>
date: Wed Jan 9 13:56:57 EST 2013

Make opusfile_example fwrites all-or-nothing.

This makes it more likely the WAV file header matches the amount of
 data actually written if we run out of space.
This is easier than making the accounting better.

--- a/examples/opusfile_example.c
+++ b/examples/opusfile_example.c
@@ -301,7 +301,7 @@
         out[2*si+0]=(unsigned char)(pcm[si]&0xFF);
         out[2*si+1]=(unsigned char)(pcm[si]>>8&0xFF);
       }
-      if(!fwrite(out,sizeof(*out)*4,ret,stdout)){
+      if(!fwrite(out,sizeof(*out)*4*ret,1,stdout)){
         fprintf(stderr,"\nError writing decoded audio data: %s\n",
          strerror(errno));
         ret=EXIT_FAILURE;