shithub: opus-tools

Download patch

ref: d3062c4f6ee0d9cd578b5ace22e3785e545f87e4
parent: 26ad437703a1edf92614ec44f3d7aa604c8e05b7
author: Gregory Maxwell <[email protected]>
date: Mon May 21 11:09:48 EDT 2012

Restore handling of data being a non-final hunk in wavs, removed in ca4927a9.

--- a/src/audio-in.c
+++ b/src/audio-in.c
@@ -629,6 +629,11 @@
     opus_int64 realsamples;
     int *ch_permute = f->channel_permute;
 
+    if(f->totalsamples && f->samplesread +
+            bytes_read/(sampbyte*f->channels) > f->totalsamples) {
+        bytes_read = sampbyte*f->channels*(f->totalsamples - f->samplesread);
+    }
+
     realsamples = bytes_read/(sampbyte*f->channels);
     f->samplesread += realsamples;
 
@@ -705,6 +710,10 @@
     long bytes_read = fread(buf,1,samples*4*f->channels, f->f);
     int i,j;
     opus_int64 realsamples;
+
+    if(f->totalsamples && f->samplesread +
+            bytes_read/(4*f->channels) > f->totalsamples)
+        bytes_read = 4*f->channels*(f->totalsamples - f->samplesread);
 
     realsamples = bytes_read/(4*f->channels);
     f->samplesread += realsamples;