diff options
author | wm4 <wm4@nowhere> | 2017-01-27 09:03:14 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-01-27 09:03:14 +0100 |
commit | 70411f2709ed792df2fc66cd428e8253abfdc390 (patch) | |
tree | cd89d95b360a18ad8d1df3066602e38945eaadca /stream/stream.c | |
parent | 4e53f9e5b20efb121bdd19464f1e1af14c981227 (diff) | |
download | mpv-70411f2709ed792df2fc66cd428e8253abfdc390.tar.bz2 mpv-70411f2709ed792df2fc66cd428e8253abfdc390.tar.xz |
stream: minor cleanup to previous commit
This is almost cosmetic, but removes the duplicated EOF-setting.
Somewhat oddly, this will enter the reconnect path and exit it
immediately again - should be fine.
Diffstat (limited to 'stream/stream.c')
-rw-r--r-- | stream/stream.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/stream/stream.c b/stream/stream.c index 6fc8e95b08..61201add05 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -359,24 +359,19 @@ static bool stream_reconnect(stream_t *s) // Partial reads are possible, even if EOF is not reached. static int stream_read_unbuffered(stream_t *s, void *buf, int len) { - int orig_len = len; + int res = 0; s->buf_pos = s->buf_len = 0; - if (mp_cancel_test(s->cancel)) { - s->eof = 1; - return 0; - } // we will retry even if we already reached EOF previously. - len = s->fill_buffer ? s->fill_buffer(s, buf, len) : -1; - if (len < 0) - len = 0; - if (len == 0) { + if (s->fill_buffer && !mp_cancel_test(s->cancel)) + res = s->fill_buffer(s, buf, len); + if (res <= 0) { // just in case this is an error e.g. due to network // timeout reset and retry // do not retry if this looks like proper eof int64_t size = stream_get_size(s); if (!s->eof && s->pos != size && stream_reconnect(s)) { s->eof = 1; // make sure EOF is set to ensure no endless recursion - return stream_read_unbuffered(s, buf, orig_len); + return stream_read_unbuffered(s, buf, len); } s->eof = 1; @@ -384,8 +379,8 @@ static int stream_read_unbuffered(stream_t *s, void *buf, int len) } // When reading succeeded we are obviously not at eof. s->eof = 0; - s->pos += len; - return len; + s->pos += res; + return res; } static int stream_fill_buffer_by(stream_t *s, int64_t len) |