From a4d487f5b2930611bf908243510d6f0351ebcf58 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 24 May 2014 14:04:09 +0200 Subject: stream: don't use end_pos Stop using it in most places, and prefer STREAM_CTRL_GET_SIZE. The advantage is that always the correct size will be used. There can be no doubt anymore whether the end_pos value is outdated (as it happens often with files that are being downloaded). Some streams still use end_pos. They don't change size, and it's easier to emulate STREAM_CTRL_GET_SIZE using end_pos, instead of adding a STREAM_CTRL_GET_SIZE implementation to these streams. Make sure int64_t is always used for STREAM_CTRL_GET_SIZE (it was uint64_t before). Remove the seek flags mess, and replace them with a seekable flag. Every stream must set it consistently now, and an assertion in stream.c checks this. Don't distinguish between streams that can only be forward or backwards seeked, since we have no such stream types. --- stream/stream_file.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'stream/stream_file.c') diff --git a/stream/stream_file.c b/stream/stream_file.c index c714f5739d..528cf1a6e3 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -96,9 +96,10 @@ static int control(stream_t *s, int cmd, void *arg) size = lseek(p->fd, 0, SEEK_END); lseek(p->fd, s->pos, SEEK_SET); if (size != (off_t)-1) { - *(uint64_t *)arg = size; + *(int64_t *)arg = size; return 1; } + break; } } return STREAM_UNSUPPORTED; @@ -276,10 +277,10 @@ static int open_f(stream_t *stream, int mode) len = -1; #endif stream->type = STREAMTYPE_FILE; - stream->flags = MP_STREAM_FAST_SKIPPING; + stream->fast_skip = true; if (len >= 0) { stream->seek = seek; - stream->end_pos = len; + stream->seekable = true; } MP_VERBOSE(stream, "File size is %" PRId64 " bytes\n", len); -- cgit v1.2.3