[MPlayer-cvslog] r31226 - in trunk/stream: cache2.c stream.c
reimar
subversion at mplayerhq.hu
Wed May 26 20:23:43 CEST 2010
Author: reimar
Date: Wed May 26 20:23:43 2010
New Revision: 31226
Log:
Retry reading even if we hit eof before.
This allows playing growing files even with a large cache.
Modified:
trunk/stream/cache2.c
trunk/stream/stream.c
Modified: trunk/stream/cache2.c
==============================================================================
--- trunk/stream/cache2.c Wed May 26 20:01:38 2010 (r31225)
+++ trunk/stream/cache2.c Wed May 26 20:23:43 2010 (r31226)
@@ -225,7 +225,7 @@ static int cache_fill(cache_vars_t *s)
//memcpy(&s->buffer[pos],s->stream->buffer,len); // avoid this extra copy!
// ....
len=stream_read(s->stream,&s->buffer[pos],space);
- if(!len) s->eof=1;
+ s->eof= !len;
s->max_filepos+=len;
if(pos+len>=s->buffer_size){
@@ -477,7 +477,6 @@ static void *ThreadProc( void *s ){
int cache_stream_fill_buffer(stream_t *s){
int len;
- if(s->eof){ s->buf_pos=s->buf_len=0; return 0; }
if(!s->cache_pid) return stream_fill_buffer(s);
// cache_stats(s->cache_data);
@@ -488,6 +487,7 @@ int cache_stream_fill_buffer(stream_t *s
//printf("cache_stream_fill_buffer->read -> %d\n",len);
if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; }
+ s->eof=0;
s->buf_pos=0;
s->buf_len=len;
s->pos+=len;
Modified: trunk/stream/stream.c
==============================================================================
--- trunk/stream/stream.c Wed May 26 20:01:38 2010 (r31225)
+++ trunk/stream/stream.c Wed May 26 20:23:43 2010 (r31226)
@@ -263,7 +263,7 @@ stream_t* open_output_stream(const char*
int stream_fill_buffer(stream_t *s){
int len;
- if (/*s->fd == NULL ||*/ s->eof) { return 0; }
+ // we will retry even if we already reached EOF previously.
switch(s->type){
case STREAMTYPE_STREAM:
#ifdef CONFIG_NETWORK
@@ -285,6 +285,9 @@ int stream_fill_buffer(stream_t *s){
len= s->fill_buffer ? s->fill_buffer(s,s->buffer,STREAM_BUFFER_SIZE) : 0;
}
if(len<=0){ s->eof=1; return 0; }
+ // When reading succeeded we are obviously not at eof.
+ // This e.g. avoids issues with eof getting stuck when lavf seeks in MPEG-TS
+ s->eof=0;
s->buf_pos=0;
s->buf_len=len;
s->pos+=len;
More information about the MPlayer-cvslog
mailing list