ov_read_float() was calling vorbis_synthesis_read() and moving pointers
authorJack Moffitt <jack@xiph.org>
Tue, 18 Dec 2001 22:02:25 +0000 (22:02 +0000)
committerJack Moffitt <jack@xiph.org>
Tue, 18 Dec 2001 22:02:25 +0000 (22:02 +0000)
before we had processed the buffer.  Instead of relying on ov_read_float
to process our data before we pack it into integer types, we reimplement
the small loop that it uses without the parts calling
vorbis_synthesis_read.

svn path=/trunk/vorbis/; revision=2658

lib/vorbisfile.c

index 42d8a27..6eb5cac 100644 (file)
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.53 2001/12/14 00:30:33 jack Exp $
+ last mod: $Id: vorbisfile.c,v 1.54 2001/12/18 22:02:25 jack Exp $
 
  ********************************************************************/
 
@@ -1407,7 +1407,25 @@ long ov_read(OggVorbis_File *vf,char *buffer,int length,
   int host_endian = host_is_big_endian();
 
   float **pcm;
-  long samples=ov_read_float(vf,&pcm,bitstream);
+  long samples;
+
+  if(vf->ready_state<OPENED)return(OV_EINVAL);
+
+  while(1){
+    if(vf->ready_state>=STREAMSET){
+      samples=vorbis_synthesis_pcmout(&vf->vd,&pcm);
+      if(samples)break;
+    }
+
+    /* suck in another packet */
+    {
+      int ret=_process_packet(vf,1);
+      if(ret==OV_EOF)return(0);
+      if(ret<=0)return(ret);
+    }
+
+  }
+
   if(samples>0){
   
     /* yay! proceed to pack data into the byte buffer */