0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

stream: add assert, a cosmetic change

This shouldn't change anything.
This commit is contained in:
wm4 2020-04-10 12:23:10 +02:00
parent 8e74b08538
commit c3f40e513b

View File

@ -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);