summaryrefslogtreecommitdiffstats
path: root/demux/demux_mkv.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-14 12:59:14 +0100
committerwm4 <wm4@nowhere>2019-11-14 12:59:14 +0100
commitac7f67b3f23a63e463fb881d960bc8f31a230292 (patch)
tree5d40b4c6a9df371dde1317b2a758b50f7df68439 /demux/demux_mkv.c
parentdcc3c2eb3877f9876cc218b1e5f1187b81036c49 (diff)
downloadmpv-ac7f67b3f23a63e463fb881d960bc8f31a230292.tar.bz2
mpv-ac7f67b3f23a63e463fb881d960bc8f31a230292.tar.xz
demux_mkv, stream: attempt to improve behavior in unseekable streams
stream_skip() semantics were kind of bad, especially after the recent change to the stream code. Forward stream_skip() calls could still trigger a seek and fail, even if it was supposed to actually skip data. (Maybe the idea that stream_skip() should try to seek is worthless in the first place.) Rename it to stream_seek_skip() (takes absolute position now because I think that's better), and make it always skip if the stream is marked as forward. While we're at it, make EOF detection more robust. I guess s->eof shouldn't exist at all, since it's valid only "sometimes". It should be removed... but not today. A 1-byte stream_read_peek() call is good to get the s->eof flag set to a correct value.
Diffstat (limited to 'demux/demux_mkv.c')
-rw-r--r--demux/demux_mkv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index bd36edb784..4c5f376137 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -1954,7 +1954,7 @@ static int read_mkv_segment_header(demuxer_t *demuxer, int64_t *segment_end)
if (demuxer->params)
num_skip = demuxer->params->matroska_wanted_segment;
- while (!s->eof) {
+ while (stream_read_peek(s, &(char){0}, 1)) {
if (ebml_read_id(s) != MATROSKA_ID_SEGMENT) {
MP_VERBOSE(demuxer, "segment not found\n");
return 0;
@@ -2580,7 +2580,7 @@ static int read_block(demuxer_t *demuxer, int64_t end, struct block_info *block)
exit:
if (res <= 0)
free_block(block);
- stream_seek(s, endpos);
+ stream_seek_skip(s, endpos);
return res;
}