summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-10 12:23:10 +0200
committerwm4 <wm4@nowhere>2020-04-10 12:23:10 +0200
commitc3f40e513b63bd484e431984135208106d13c2d3 (patch)
tree1f8f97a29f8db4799ffee7fb05200afb355761fe
parent8e74b085389fe0a7d998dac253a7965e253999bf (diff)
downloadmpv-c3f40e513b63bd484e431984135208106d13c2d3.tar.bz2
mpv-c3f40e513b63bd484e431984135208106d13c2d3.tar.xz
stream: add assert, a cosmetic change
This shouldn't change anything.
-rw-r--r--stream/stream.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/stream/stream.c b/stream/stream.c
index d12ae93338..0a026713f6 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -479,6 +479,7 @@ static int stream_read_unbuffered(stream_t *s, void *buf, int len)
s->eof = 1;
return 0;
}
+ assert(res <= len);
// When reading succeeded we are obviously not at eof.
s->eof = 0;
s->pos += res;
@@ -500,6 +501,7 @@ static bool stream_read_more(struct stream *s, int forward)
// Avoid that many small reads will lead to many low-level read calls.
forward = MPMAX(forward, s->requested_buffer_size / 2);
+ assert(forward_avail < forward);
// Keep guaranteed seek-back.
int buf_old = MPMIN(s->buf_cur - s->buf_start, s->requested_buffer_size / 2);
@@ -518,7 +520,7 @@ static bool stream_read_more(struct stream *s, int forward)
// Note: read as much as possible, even if forward is much smaller. Do
// this because the stream buffer is supposed to set an approx. minimum
// read size on it.
- int read = buf_alloc - buf_old - forward_avail; // free buffer past end
+ int read = buf_alloc - (buf_old + forward_avail); // free buffer past end
int pos = s->buf_end & s->buffer_mask;
read = MPMIN(read, buf_alloc - pos);