diff options
author | wm4 <wm4@nowhere> | 2014-05-24 14:04:09 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-05-24 16:17:51 +0200 |
commit | a4d487f5b2930611bf908243510d6f0351ebcf58 (patch) | |
tree | 000fc31412c31ea60ef0b7c59af087e6402b4541 /demux/demux_mkv.c | |
parent | e3c20bf3505679641f247471603ad298d04036bd (diff) | |
download | mpv-a4d487f5b2930611bf908243510d6f0351ebcf58.tar.bz2 mpv-a4d487f5b2930611bf908243510d6f0351ebcf58.tar.xz |
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.
Diffstat (limited to 'demux/demux_mkv.c')
-rw-r--r-- | demux/demux_mkv.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 20864aa297..4b08ce2a13 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1058,7 +1058,9 @@ static int demux_mkv_read_seekhead(demuxer_t *demuxer) (unsigned)seek->seek_id, pos); get_header_element(demuxer, seek->seek_id, pos); // This is nice to warn against incomplete files. - if (pos >= s->end_pos) + int64_t end = 0; + stream_control(s, STREAM_CTRL_GET_SIZE, &end); + if (pos >= end) MP_WARN(demuxer, "SeekHead position beyond " "end of file - incomplete file?\n"); } @@ -1723,7 +1725,9 @@ static int read_mkv_segment_header(demuxer_t *demuxer, int64_t *segment_end) MP_VERBOSE(demuxer, " (skipping)\n"); if (*segment_end <= 0) break; - if (*segment_end >= s->end_pos) + int64_t end = 0; + stream_control(s, STREAM_CTRL_GET_SIZE, &end); + if (*segment_end >= end) return 0; if (!stream_seek(s, *segment_end)) { MP_WARN(demuxer, "Failed to seek in file\n"); @@ -1794,7 +1798,9 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check) } MP_VERBOSE(demuxer, "Seeking to %"PRIu64" to read header element 0x%x.\n", elem->pos, (unsigned)elem->id); - if (elem->pos >= s->end_pos) { + int64_t end = 0; + stream_control(s, STREAM_CTRL_GET_SIZE, &end); + if (elem->pos >= end) { MP_WARN(demuxer, "SeekHead position beyond " "end of file - incomplete file?\n"); continue; @@ -2748,7 +2754,10 @@ static void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, int flags) return; } - target_filepos = (uint64_t) (s->end_pos * rel_seek_secs); + int64_t size = 0; + stream_control(s, STREAM_CTRL_GET_SIZE, &size); + + target_filepos = (uint64_t) (size * rel_seek_secs); for (i = 0; i < mkv_d->num_indexes; i++) if (mkv_d->indexes[i].tnum == v_tnum) if ((index == NULL) |