Mercurial > mplayer.hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
32528:488660501547 | 32529:0624fa95a2aa |
---|---|
37 #include <signal.h> | 37 #include <signal.h> |
38 #include <sys/types.h> | 38 #include <sys/types.h> |
39 #include <unistd.h> | 39 #include <unistd.h> |
40 #include <errno.h> | 40 #include <errno.h> |
41 | 41 |
42 #include "libavutil/avutil.h" | |
42 #include "osdep/shmem.h" | 43 #include "osdep/shmem.h" |
43 #include "osdep/timer.h" | 44 #include "osdep/timer.h" |
44 #if defined(__MINGW32__) | 45 #if defined(__MINGW32__) |
45 #include <windows.h> | 46 #include <windows.h> |
46 static void ThreadProc( void *s ); | 47 static void ThreadProc( void *s ); |
167 | 168 |
168 static int cache_fill(cache_vars_t *s) | 169 static int cache_fill(cache_vars_t *s) |
169 { | 170 { |
170 int back,back2,newb,space,len,pos; | 171 int back,back2,newb,space,len,pos; |
171 off_t read=s->read_filepos; | 172 off_t read=s->read_filepos; |
173 int read_chunk; | |
172 | 174 |
173 if(read<s->min_filepos || read>s->max_filepos){ | 175 if(read<s->min_filepos || read>s->max_filepos){ |
174 // seek... | 176 // seek... |
175 mp_msg(MSGT_CACHE,MSGL_DBG2,"Out of boundaries... seeking to 0x%"PRIX64" \n",(int64_t)read); | 177 mp_msg(MSGT_CACHE,MSGL_DBG2,"Out of boundaries... seeking to 0x%"PRIX64" \n",(int64_t)read); |
176 // drop cache contents only if seeking backward or too much fwd. | 178 // drop cache contents only if seeking backward or too much fwd. |
212 | 214 |
213 // reduce space if needed: | 215 // reduce space if needed: |
214 if(space>s->buffer_size-pos) space=s->buffer_size-pos; | 216 if(space>s->buffer_size-pos) space=s->buffer_size-pos; |
215 | 217 |
216 // limit one-time block size | 218 // limit one-time block size |
217 if(space>4*s->sector_size) space=4*s->sector_size; | 219 read_chunk = s->stream->read_chunk; |
220 if (!read_chunk) read_chunk = 4*s->sector_size; | |
221 space = FFMIN(space, read_chunk); | |
218 | 222 |
219 #if 1 | 223 #if 1 |
220 // back+newb+space <= buffer_size | 224 // back+newb+space <= buffer_size |
221 back2=s->buffer_size-(space+newb); // max back size | 225 back2=s->buffer_size-(space+newb); // max back size |
222 if(s->min_filepos<(read-back2)) s->min_filepos=read-back2; | 226 if(s->min_filepos<(read-back2)) s->min_filepos=read-back2; |