Vorbisfile was always reading very large chunks; a good idea for
authorMonty <xiphmont@xiph.org>
Wed, 24 Mar 2010 07:37:36 +0000 (07:37 +0000)
committerMonty <xiphmont@xiph.org>
Wed, 24 Mar 2010 07:37:36 +0000 (07:37 +0000)
seeking/local file playback, a very bad idea for low-rate streaming.

The large chunksize wasn't needed for read performance, just
seek-and-scrub performance.  So add a seperate smaller read size.

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

lib/vorbisfile.c

index b0d884a..c2ef280 100644 (file)
 
 /* read a little more data from the file/pipe into the ogg_sync framer
 */
-#define CHUNKSIZE 65536
+#define CHUNKSIZE 65536 /* greater-than-page-size granularity seeking */
+#define READSIZE 2048 /* a smaller read size is needed for low-rate streaming. */
 
 static long _get_data(OggVorbis_File *vf){
   errno=0;
   if(!(vf->callbacks.read_func))return(-1);
   if(vf->datasource){
-    char *buffer=ogg_sync_buffer(&vf->oy,CHUNKSIZE);
-    long bytes=(vf->callbacks.read_func)(buffer,1,CHUNKSIZE,vf->datasource);
+    char *buffer=ogg_sync_buffer(&vf->oy,READSIZE);
+    long bytes=(vf->callbacks.read_func)(buffer,1,READSIZE,vf->datasource);
     if(bytes>0)ogg_sync_wrote(&vf->oy,bytes);
     if(bytes==0 && errno)return(-1);
     return(bytes);