shithub: sox

Download patch

ref: 2a516c4218d5c3cd184698fab8e7269116127a9d
parent: c6ceb7f6ad6f535119c7f16cc7190bf532326448
author: robs <robs>
date: Thu Feb 5 03:37:22 EST 2009

Fix length in wav header with multi-channel output to pipe

--- a/ChangeLog
+++ b/ChangeLog
@@ -53,6 +53,7 @@
 
   o Slight improvement to A-law/u-law conversion accuracy: round LSB
     instead of truncating.  (robs)
+  o Fix length in wav header with multi-channel output to pipe.  (robs)
   o Fix [2028181] w64 float format incompatibility.  (Tim Munro)
   o Fix reading AIFF files with pad bytes in COMT chunks. (Joe Holt)
   o Fix AIFF file length bug to stop reading trash data on files that
--- a/src/wav.c
+++ b/src/wav.c
@@ -1344,7 +1344,8 @@
         dwDataLength = blocksWritten * wBlockAlign;
         dwSamplesWritten = blocksWritten * wSamplesPerBlock;
     } else {    /* fixup with real length */
-        dwSamplesWritten = second_header? wav->numSamples : ft->signal.length;
+        dwSamplesWritten = 
+            second_header? wav->numSamples : ft->signal.length / wChannels;
         blocksWritten = (dwSamplesWritten+wSamplesPerBlock-1)/wSamplesPerBlock;
         dwDataLength = blocksWritten * wBlockAlign;
     }