summaryrefslogtreecommitdiffstats
path: root/stream/stream.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-03 17:46:36 +0100
committerwm4 <wm4@nowhere>2013-11-03 17:46:36 +0100
commit22274f7982e01784a27daac371fe2a1607433425 (patch)
treed9a9637caf56506a0cbb704352836a8dc145fbf7 /stream/stream.c
parent84f7e213ab6ae1736c7e4ad5b2ff6d002c554361 (diff)
downloadmpv-22274f7982e01784a27daac371fe2a1607433425.tar.bz2
mpv-22274f7982e01784a27daac371fe2a1607433425.tar.xz
stream: more consistent checks for whether stream is seekable
Never check s->seek (except in init), because it'd have to check s->flags anyway. Also, for fast skippable streams (like pipes), don't set the bit that indicates support for seek forward. Make sure s->end_pos is always 0 for unseekable streams. Lots of code outside of stream.c uses this to check seeking support.
Diffstat (limited to 'stream/stream.c')
-rw-r--r--stream/stream.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/stream/stream.c b/stream/stream.c
index 01c1819dbb..bf2adeb564 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -318,8 +318,8 @@ static int open_internal(const stream_info_t *sinfo, struct stream *underlying,
if (s->seek && !(s->flags & MP_STREAM_SEEK))
s->flags |= MP_STREAM_SEEK;
- if (s->flags & MP_STREAM_FAST_SKIPPING)
- s->flags |= MP_STREAM_SEEK_FW;
+ if (!(s->flags & MP_STREAM_SEEK))
+ s->end_pos = 0;
s->uncached_type = s->type;
@@ -387,7 +387,7 @@ static int stream_reconnect(stream_t *s)
#define RECONNECT_SLEEP_MS 1000
if (!s->streaming)
return 0;
- if (!s->end_pos || !s->seek || !(s->flags & MP_STREAM_SEEK))
+ if (!(s->flags & MP_STREAM_SEEK_FW))
return 0;
int64_t pos = s->pos;
for (int retry = 0; retry < MAX_RECONNECT_RETRIES; retry++) {
@@ -603,7 +603,7 @@ static int stream_skip_read(struct stream *s, int64_t len)
static int stream_seek_unbuffered(stream_t *s, int64_t newpos)
{
if (newpos != s->pos) {
- if (!s->seek || !(s->flags & MP_STREAM_SEEK)) {
+ if (newpos > s->pos && !(s->flags & MP_STREAM_SEEK_FW)) {
mp_tmsg(MSGT_STREAM, MSGL_ERR, "Can not seek in this stream\n");
return 0;
}
@@ -630,7 +630,7 @@ static int stream_seek_long(stream_t *s, int64_t pos)
s->eof = 0;
if (s->mode == STREAM_WRITE) {
- if (!s->seek || !s->seek(s, pos))
+ if (!(s->flags & MP_STREAM_SEEK) || !s->seek(s, pos))
return 0;
return 1;
}
@@ -642,7 +642,9 @@ static int stream_seek_long(stream_t *s, int64_t pos)
mp_msg(MSGT_STREAM, MSGL_DBG3, "Seek from %" PRId64 " to %" PRId64
" (with offset %d)\n", s->pos, pos, (int)(pos - newpos));
- if (!s->seek && (s->flags & MP_STREAM_FAST_SKIPPING) && pos >= s->pos) {
+ if (pos >= s->pos && !(s->flags & MP_STREAM_SEEK) &&
+ (s->flags & MP_STREAM_FAST_SKIPPING))
+ {
// skipping is handled by generic code below
} else if (stream_seek_unbuffered(s, newpos) >= 0) {
return 0;
@@ -711,6 +713,8 @@ int stream_control(stream_t *s, int cmd, void *arg)
void stream_update_size(stream_t *s)
{
+ if (!(s->flags & MP_STREAM_SEEK))
+ return;
uint64_t size;
if (stream_control(s, STREAM_CTRL_GET_SIZE, &size) == STREAM_OK) {
if (size > s->end_pos)