diff stream/cache2.c @ 32529:0624fa95a2aa

Make the file protocol read up to 64 kB at once when the cache is used, assuming that files will generally be readable with high bandwidth. This should improve performance when playing e.g. from high-latency network shares.
author reimar
date Wed, 10 Nov 2010 17:21:28 +0000
parents 5d1d67cf8718
children ce80aa247b4b
line wrap: on
line diff
--- a/stream/cache2.c	Wed Nov 10 15:18:03 2010 +0000
+++ b/stream/cache2.c	Wed Nov 10 17:21:28 2010 +0000
@@ -39,6 +39,7 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include "libavutil/avutil.h"
 #include "osdep/shmem.h"
 #include "osdep/timer.h"
 #if defined(__MINGW32__)
@@ -169,6 +170,7 @@
 {
   int back,back2,newb,space,len,pos;
   off_t read=s->read_filepos;
+  int read_chunk;
 
   if(read<s->min_filepos || read>s->max_filepos){
       // seek...
@@ -214,7 +216,9 @@
   if(space>s->buffer_size-pos) space=s->buffer_size-pos;
 
   // limit one-time block size
-  if(space>4*s->sector_size) space=4*s->sector_size;
+  read_chunk = s->stream->read_chunk;
+  if (!read_chunk) read_chunk = 4*s->sector_size;
+  space = FFMIN(space, read_chunk);
 
 #if 1
   // back+newb+space <= buffer_size