From ac7f67b3f23a63e463fb881d960bc8f31a230292 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 14 Nov 2019 12:59:14 +0100 Subject: 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. --- stream/stream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stream/stream.h') diff --git a/stream/stream.h b/stream/stream.h index 4a38d28109..d054e54914 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -121,7 +121,7 @@ typedef struct stream { void (*close)(struct stream *s); int64_t pos; - int eof; + int eof; // valid only after read calls that returned a short result int mode; //STREAM_READ or STREAM_WRITE void *priv; // used for DVD, TV, RTSP etc char *url; // filename/url (possibly including protocol prefix) @@ -194,7 +194,7 @@ inline static int64_t stream_tell(stream_t *s) return s->pos + s->buf_cur - s->buf_end; } -bool stream_skip(stream_t *s, int64_t len); +bool stream_seek_skip(stream_t *s, int64_t pos); bool stream_seek(stream_t *s, int64_t pos); int stream_read(stream_t *s, void *mem, int total); int stream_read_partial(stream_t *s, void *buf, int buf_size); -- cgit v1.2.3