changeset 8028:66ff451487a7 libavcodec

Add a flag to avoid calling vorbis_analysis_wrote twice with an empty buffer. Patch by Nicolas George: name surname normalesup org
author benoit
date Wed, 15 Oct 2008 07:29:37 +0000
parents 086563096ac5
children e50d7ac76945
files libvorbis.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libvorbis.c	Tue Oct 14 20:42:54 2008 +0000
+++ b/libvorbis.c	Wed Oct 15 07:29:37 2008 +0000
@@ -42,6 +42,7 @@
     vorbis_block vb ;
     uint8_t buffer[BUFFER_SIZE];
     int buffer_index;
+    int eof;
 
     /* decoder */
     vorbis_comment vc ;
@@ -136,10 +137,13 @@
                            int buf_size, void *data)
 {
     OggVorbisContext *context = avccontext->priv_data ;
-    float **buffer ;
     ogg_packet op ;
     signed short *audio = data ;
-    int l, samples = data ? OGGVORBIS_FRAME_SIZE : 0;
+    int l;
+
+    if(data) {
+        int samples = OGGVORBIS_FRAME_SIZE;
+        float **buffer ;
 
     buffer = vorbis_analysis_buffer(&context->vd, samples) ;
 
@@ -154,6 +158,11 @@
     }
 
     vorbis_analysis_wrote(&context->vd, samples) ;
+    } else {
+        if(!context->eof)
+            vorbis_analysis_wrote(&context->vd, 0) ;
+        context->eof = 1;
+    }
 
     while(vorbis_analysis_blockout(&context->vd, &context->vb) == 1) {
         vorbis_analysis(&context->vb, NULL);