summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-29 17:58:20 +0200
committerwm4 <wm4@nowhere>2014-09-29 18:06:44 +0200
commitb9e4eefdb1706c6a091fbf9cd04d89ab41370115 (patch)
tree5b31956533e3ae29c13642f8df1c9ccdc66d0655 /stream
parent6b9aee20bd02b572faac95ffab82214076a6fa7f (diff)
downloadmpv-b9e4eefdb1706c6a091fbf9cd04d89ab41370115.tar.bz2
mpv-b9e4eefdb1706c6a091fbf9cd04d89ab41370115.tar.xz
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.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/stream/stream.c b/stream/stream.c
index c664173f4e..3b8915c8ac 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -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->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))