diff --git a/stream/stream.c b/stream/stream.c index 713d766d93..c964a7c447 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -355,18 +355,22 @@ if(newpos==0 || newpos!=s->pos){ // putchar('%');fflush(stdout); } -while(stream_fill_buffer(s) > 0 && pos >= 0) { +s->eof = 0; // EOF reset when seek succeeds. +while (stream_fill_buffer(s) > 0) { if(pos<=s->buf_len){ s->buf_pos=pos; // byte position in sector return 1; } pos -= s->buf_len; } +// Fill failed, but seek still is a success. +s->pos += pos; +s->buf_pos = 0; +s->buf_len = 0; -// if(pos==s->buf_len) printf("XXX Seek to last byte of file -> EOF\n"); - - mp_msg(MSGT_STREAM,MSGL_V,"stream_seek: WARNING! Can't seek to 0x%"PRIX64" !\n",(int64_t)(pos+newpos)); - return 0; +mp_msg(MSGT_STREAM,MSGL_V, + "stream_seek: Seek to/past EOF: no buffer preloaded.\n"); +return 1; } diff --git a/stream/stream.h b/stream/stream.h index 68d4937ad2..135be37b69 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -269,6 +269,7 @@ inline static int stream_seek(stream_t *s,off_t pos){ off_t x=pos-(s->pos-s->buf_len); if(x>=0){ s->buf_pos=x; + s->eof = 0; // putchar('*');fflush(stdout); return 1; }