[MPlayer-cvslog] r32616 - in trunk/stream: cache2.c stream.h stream_file.c

reimar subversion at mplayerhq.hu
Wed Nov 10 18:21:29 CET 2010


Author: reimar
Date: Wed Nov 10 18:21:28 2010
New Revision: 32616

Log:
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.

Modified:
   trunk/stream/cache2.c
   trunk/stream/stream.h
   trunk/stream/stream_file.c

Modified: trunk/stream/cache2.c
==============================================================================
--- trunk/stream/cache2.c	Wed Nov 10 16:18:03 2010	(r32615)
+++ trunk/stream/cache2.c	Wed Nov 10 18:21:28 2010	(r32616)
@@ -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 @@ static int cache_fill(cache_vars_t *s)
 {
   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 @@ static int cache_fill(cache_vars_t *s)
   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

Modified: trunk/stream/stream.h
==============================================================================
--- trunk/stream/stream.h	Wed Nov 10 16:18:03 2010	(r32615)
+++ trunk/stream/stream.h	Wed Nov 10 18:21:28 2010	(r32616)
@@ -154,6 +154,7 @@ typedef struct stream {
   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;

Modified: trunk/stream/stream_file.c
==============================================================================
--- trunk/stream/stream_file.c	Wed Nov 10 16:18:03 2010	(r32615)
+++ trunk/stream/stream_file.c	Wed Nov 10 18:21:28 2010	(r32616)
@@ -188,6 +188,7 @@ static int open_f(stream_t *stream,int m
   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;


More information about the MPlayer-cvslog mailing list