summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-18 21:23:17 +0100
committerwm4 <wm4@nowhere>2012-11-20 18:00:15 +0100
commitefaa73cc7333cee40555a61f7bd829c6deb64e63 (patch)
treea81198f14a30988d782201200737d969a29dd865
parentddffcce67810fbde5508a353f85760da7a1b4a95 (diff)
downloadmpv-efaa73cc7333cee40555a61f7bd829c6deb64e63.tar.bz2
mpv-efaa73cc7333cee40555a61f7bd829c6deb64e63.tar.xz
stream, demux_lavf: minor cleanup for stream size code
-rw-r--r--demux/demux_lavf.c4
-rw-r--r--stream/stream.c9
-rw-r--r--stream/stream.h1
3 files changed, 11 insertions, 3 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index dd8af7cb47..85fa2a9be1 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -112,9 +112,7 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
else if (whence == SEEK_SET)
pos += stream->start_pos;
else if (whence == AVSEEK_SIZE && stream->end_pos > 0) {
- uint64_t size;
- if (stream_control(stream, STREAM_CTRL_GET_SIZE, &size) == STREAM_OK)
- return size;
+ stream_update_size(stream);
return stream->end_pos - stream->start_pos;
} else
return -1;
diff --git a/stream/stream.c b/stream/stream.c
index a94939ffda..722a21e57c 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -476,6 +476,15 @@ int stream_control(stream_t *s, int cmd, void *arg){
return s->control(s, cmd, arg);
}
+void stream_update_size(stream_t *s)
+{
+ uint64_t size;
+ if (stream_control(s, STREAM_CTRL_GET_SIZE, &size) == STREAM_OK) {
+ if (size > s->end_pos)
+ s->end_pos = size;
+ }
+}
+
stream_t* new_memory_stream(unsigned char* data,int len){
stream_t *s;
diff --git a/stream/stream.h b/stream/stream.h
index 9023c95933..9bb6da749b 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -349,6 +349,7 @@ struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
int max_size, int padding_bytes);
void stream_reset(stream_t *s);
int stream_control(stream_t *s, int cmd, void *arg);
+void stream_update_size(stream_t *s);
stream_t* new_stream(int fd,int type);
void free_stream(stream_t *s);
stream_t* new_memory_stream(unsigned char* data,int len);