From 4e0331fac2b197b5d6b20a987f2e54cff2f67ad4 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Wed, 5 Feb 2003 00:08:55 +0000 Subject: try to have the same behaviour reading from network on http/mms/pnm/rtsp. select() is useful to avoid burning cpu cicles, otoh, we should not call it after end of stream since it will hang xine for 30sec. idea: do select() only on EAGAIN. todo: unify these functions (?) CVS patchset: 4105 CVS date: 2003/02/05 00:08:55 --- src/input/input_http.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/input/input_http.c') diff --git a/src/input/input_http.c b/src/input/input_http.c index 9b21dde3d..05919863d 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -437,14 +437,24 @@ static off_t http_plugin_read (input_plugin_t *this_gen, /* read errors */ if (n < 0) { - switch (errno) { - case EAGAIN: - xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: EAGAIN\n")); - continue; - default: - xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: read error %d\n"), errno); - return 0; + if(errno == EAGAIN) { + fd_set rset; + struct timeval timeout; + + FD_ZERO (&rset); + FD_SET (this->fh, &rset); + + timeout.tv_sec = 30; + timeout.tv_usec = 0; + + if (select (this->fh+1, &rset, NULL, NULL, &timeout) <= 0) { + xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: timeout\n")); + return 0; + } + continue; } + xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: read error %d\n"), errno); + return 0; } num_bytes += n; -- cgit v1.2.3