Make opusfile_example fwrites all-or-nothing.
authorTimothy B. Terriberry <tterribe@xiph.org>
Thu, 10 Jan 2013 02:56:57 +0000 (18:56 -0800)
committerTimothy B. Terriberry <tterribe@xiph.org>
Thu, 10 Jan 2013 02:56:57 +0000 (18:56 -0800)
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.

examples/opusfile_example.c

index bb15f14..22a13d6 100644 (file)
@@ -301,7 +301,7 @@ int main(int _argc,const char **_argv){
         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;