stream: don't drop buffers on failed seeks

Might matter when libavformat tries to do tiny seekbacks in an
unseekable stream, and the seekback buffer isn't large enough. In this
case, seeking would fail, and would drop the current buffer. The
seekback would end up dropping future data.

This change probably doesn't have any observable effects. libavformat
normally has its own stream buffer, and demux_mkv.c tries carefully
never to seek back.
This commit is contained in:
wm4 2014-09-29 17:58:20 +02:00
parent 6b9aee20bd
commit b9e4eefdb1
1 changed files with 2 additions and 6 deletions

View File

@ -651,8 +651,9 @@ static int stream_seek_unbuffered(stream_t *s, int64_t newpos)
MP_ERR(s, "Seek failed\n");
return 0;
}
}
stream_drop_buffers(s);
s->pos = newpos;
}
s->eof = 0; // EOF reset when seek succeeds.
return -1;
}
@ -661,8 +662,6 @@ static int stream_seek_unbuffered(stream_t *s, int64_t newpos)
// Unlike stream_seek_unbuffered(), it still fills the local buffer.
static int stream_seek_long(stream_t *s, int64_t pos)
{
stream_drop_buffers(s);
if (s->mode == STREAM_WRITE) {
if (!s->seekable || !s->seek(s, pos))
return 0;
@ -686,8 +685,6 @@ static int stream_seek_long(stream_t *s, int64_t pos)
return 1; // success
// Fill failed, but seek still is a success (partially).
s->buf_pos = 0;
s->buf_len = 0;
s->eof = 0; // eof should be set only on read
MP_VERBOSE(s, "Seek to/past EOF: no buffer preloaded.\n");
@ -696,7 +693,6 @@ static int stream_seek_long(stream_t *s, int64_t pos)
int stream_seek(stream_t *s, int64_t pos)
{
MP_TRACE(s, "seek to 0x%llX\n", (long long)pos);
if (pos == stream_tell(s))