Mercurial > mplayer.hg
changeset 33721:1bb847d89fd5
Improve checks for when to try reconnecting to be more thorough and readable.
author | reimar |
---|---|
date | Mon, 04 Jul 2011 19:21:59 +0000 |
parents | 0cb1d3b6539d |
children | 5e80ff193bc2 |
files | stream/stream.c |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/stream.c Mon Jul 04 19:14:06 2011 +0000 +++ b/stream/stream.c Mon Jul 04 19:21:59 2011 +0000 @@ -308,22 +308,27 @@ len= s->fill_buffer ? s->fill_buffer(s, buf, len) : 0; } if(len<=0){ + off_t pos = s->pos; + // do not retry if this looks like proper eof + if (s->eof || (s->end_pos && pos == s->end_pos)) + goto eof_out; // dvdnav has some horrible hacks to "suspend" reads, // we need to skip this code or seeks will hang. - if (!s->eof && s->type != STREAMTYPE_DVDNAV) { + if (s->type == STREAMTYPE_DVDNAV) + goto eof_out; // just in case this is an error e.g. due to network // timeout reset and retry // Seeking is used as a hack to make network streams // reopen the connection, ideally they would implement // e.g. a STREAM_CTRL_RECONNECT to do this - off_t pos = s->pos; s->eof=1; stream_reset(s); - stream_seek_internal(s, pos); + if (stream_seek_internal(s, pos) >= 0 || s->pos != pos) // seek failed + goto eof_out; // make sure EOF is set to ensure no endless loops s->eof=1; return stream_read_internal(s, buf, orig_len); - } +eof_out: s->eof=1; return 0; }