# HG changeset patch # User reimar # Date 1289409688 0 # Node ID 0624fa95a2aa139af429d808d296a9d2622cf720 # Parent 48866050154759f7f0f9e81d55f2623ae8670270 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. diff -r 488660501547 -r 0624fa95a2aa stream/cache2.c --- 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 #include +#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(readmin_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 diff -r 488660501547 -r 0624fa95a2aa stream/stream.h --- a/stream/stream.h Wed Nov 10 15:18:03 2010 +0000 +++ b/stream/stream.h Wed Nov 10 17:21:28 2010 +0000 @@ -154,6 +154,7 @@ int type; // see STREAMTYPE_* int flags; int sector_size; // sector size (seek will be aligned on this size if non 0) + int read_chunk; // maximum amount of data to read at once to limit latency (0 for default) unsigned int buf_pos,buf_len; off_t pos,start_pos,end_pos; int eof; diff -r 488660501547 -r 0624fa95a2aa stream/stream_file.c --- a/stream/stream_file.c Wed Nov 10 15:18:03 2010 +0000 +++ b/stream/stream_file.c Wed Nov 10 17:21:28 2010 +0000 @@ -188,6 +188,7 @@ stream->fill_buffer = fill_buffer; stream->write_buffer = write_buffer; stream->control = control; + stream->read_chunk = 64*1024; m_struct_free(&stream_opts,opts); return STREAM_OK;