diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-01-18 14:38:56 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-01-18 14:38:56 +0200 |
commit | a0f08fbebbdf211ce2a69f1c3ab891a5a1ca9b8c (patch) | |
tree | 581f32ae817df7a390f721c7a74cad389e502d13 /stream/stream.c | |
parent | 1f126fc60cdfb7eef4d42c1593aaaddda4935a37 (diff) | |
download | mpv-a0f08fbebbdf211ce2a69f1c3ab891a5a1ca9b8c.tar.bz2 mpv-a0f08fbebbdf211ce2a69f1c3ab891a5a1ca9b8c.tar.xz |
stream: improve EOF handling in seeks
Reset stream 'eof' flag when a seek succeeds, and allow seeking to a
position at or past EOF (in the sense that the seek succeeds and
stream_tell() then returns that position).
This fixes at least some demuxer problems where an attempt to read
the index from the end of an incomplete file would set the 'eof' flag
and cause subsequent reads to fail, even if failure to read the index
would otherwise be nonfatal and demuxing could continue after seeking
back.
Partially based on a patch from Laurent <laurent.aml@gmail.com>.
Diffstat (limited to 'stream/stream.c')
-rw-r--r-- | stream/stream.c | 16 |
1 files changed, 10 insertions, 6 deletions
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; } - -// 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; +// Fill failed, but seek still is a success. +s->pos += pos; +s->buf_pos = 0; +s->buf_len = 0; + +mp_msg(MSGT_STREAM,MSGL_V, + "stream_seek: Seek to/past EOF: no buffer preloaded.\n"); +return 1; } |