Mercurial > mplayer.hg
changeset 7911:dd3f18c7b006
better error handling
based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
author | arpi |
---|---|
date | Fri, 25 Oct 2002 14:58:30 +0000 |
parents | 5a276890cec4 |
children | e15e76559bd5 |
files | input/input.c |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/input/input.c Fri Oct 25 14:33:51 2002 +0000 +++ b/input/input.c Fri Oct 25 14:58:30 2002 +0000 @@ -542,6 +542,8 @@ mp_input_read_cmd(mp_input_fd_t* mp_fd, char** ret) { char* end; (*ret) = NULL; + + if(mp_fd->flags & MP_FD_DEAD) return MP_INPUT_NOTHING; // Allocate the buffer if it dont exist if(!mp_fd->buffer) { @@ -554,18 +556,21 @@ while( !(mp_fd->flags & MP_FD_GOT_CMD) && !(mp_fd->flags & MP_FD_EOF) && (mp_fd->size - mp_fd->pos > 1) ) { int r = ((mp_cmd_func_t)mp_fd->read_func)(mp_fd->fd,mp_fd->buffer+mp_fd->pos,mp_fd->size - 1 - mp_fd->pos); // Error ? + if(r == MP_INPUT_NOTHING) break; if(r < 0) { if(errno == EINTR) continue; else if(errno == EAGAIN) break; - mp_msg(MSGT_INPUT,MSGL_ERR,"Error while reading cmd fd %d : %s\n",mp_fd->fd,strerror(errno)); - return MP_INPUT_ERROR; + mp_msg(MSGT_INPUT,MSGL_WARN,"Error while reading cmd fd %d : %s\n",mp_fd->fd,strerror(errno)); + return r; // MP_INPUT_ERROR or MP_INPUT_DEAD // EOF ? - } else if(r == 0) { + } + if(r == 0) { mp_fd->flags |= MP_FD_EOF; break; } + // r > 0 mp_fd->pos += r; break; }