changeset 8938:fc21a94f98c6

do not discard cache content at seeking type=STREAMTYPE_STREAM (fixes quicktime streaming at low cache fill)
author arpi
date Mon, 13 Jan 2003 03:08:56 +0000
parents afca652cb0e5
children aaca5f177b99
files libmpdemux/cache2.c
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/cache2.c	Mon Jan 13 02:42:06 2003 +0000
+++ b/libmpdemux/cache2.c	Mon Jan 13 03:08:56 2003 +0000
@@ -113,11 +113,16 @@
   if(read<s->min_filepos || read>s->max_filepos){
       // seek...
       mp_msg(MSGT_CACHE,MSGL_DBG2,"Out of boundaries... seeking to 0x%X  \n",read);
-      s->offset= // FIXME!?
-      s->min_filepos=s->max_filepos=read; // drop cache content :(
-      if(s->stream->eof) stream_reset(s->stream);
-      stream_seek(s->stream,read);
-      mp_msg(MSGT_CACHE,MSGL_DBG2,"Seek done. new pos: 0x%X  \n",(int)stream_tell(s->stream));
+      // streaming: drop cache contents only if seeking backward or too much fwd:
+      if(s->stream->type!=STREAMTYPE_STREAM ||
+          read<s->min_filepos || read>=s->max_filepos+s->buffer_size)
+      {
+        s->offset= // FIXME!?
+        s->min_filepos=s->max_filepos=read; // drop cache content :(
+        if(s->stream->eof) stream_reset(s->stream);
+        stream_seek(s->stream,read);
+        mp_msg(MSGT_CACHE,MSGL_DBG2,"Seek done. new pos: 0x%X  \n",(int)stream_tell(s->stream));
+      }
   }
   
   // calc number of back-bytes: