shithub: opusfile

Download patch

ref: e7661191c6da41f61d9a1ada1c30d676e83dc227
parent: 9391feca516a2a0bc12180578ffa23b8ce9dea20
author: Timothy B. Terriberry <[email protected]>
date: Sat Sep 29 08:43:06 EDT 2012

Fix handling of holes.

We have to call op_collect_audio_packets() again to drain any
 buffered packets from the page.

--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -1801,8 +1801,13 @@
       int        durations[255];
       int        op_count;
       total_duration=op_collect_audio_packets(_of,durations);
-      /*Report holes to the caller.*/
-      if(OP_UNLIKELY(total_duration<0)&&!_ignore_holes)return OP_HOLE;
+      if(OP_UNLIKELY(total_duration<0)){
+        /*Drain the packets from the page anyway.*/
+        total_duration=op_collect_audio_packets(_of,durations);
+        OP_ASSERT(total_duration>=0);
+        /*Report holes to the caller.*/
+        if(!_ignore_holes)return OP_HOLE;
+      }
       op_count=_of->op_count;
       /*If we found at least one audio data packet, compute per-packet granule
          positions for them.*/