From a040a7282a760eb3ee8dd627cf9280a0e8f72117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Mon, 3 Jul 2006 10:55:37 +0000 Subject: Add a media.network.timeout configuration for a timeout while running select() on streams, to avoid getting frozen if trying to connect to an unreachable server (or if the connection is lost. CVS patchset: 8087 CVS date: 2006/07/03 10:55:37 --- src/xine-engine/io_helper.c | 12 +++++++++--- src/xine-engine/xine.c | 14 +++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/xine-engine/io_helper.c b/src/xine-engine/io_helper.c index ae57b6938..8f1a5ad70 100644 --- a/src/xine-engine/io_helper.c +++ b/src/xine-engine/io_helper.c @@ -315,18 +315,24 @@ static off_t xio_rw_abort(xine_stream_t *stream, int fd, int cmd, char *buf, off off_t total = 0; int sret; int state = 0; + xine_cfg_entry_t cfgentry; + unsigned int timeout; if ((cmd == XIO_TCP_READ) || (cmd == XIO_FILE_READ)) { state = XIO_READ_READY; } else { state = XIO_WRITE_READY; } + + if (xine_config_lookup_entry (stream->xine, "media.network.timeout", &cfgentry)) { + timeout = entry.num_value * 1000; + } else { + timeout = 30000; /* 30K msecs = 30 secs */ + } while (total < todo) { - do { - sret = _x_io_select(stream, fd, state, 500); /* 500 ms */ - } while (sret == XIO_TIMEOUT); + sret = _x_io_select(stream, fd, state, timeout); if (sret != XIO_READY) return -1; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 99c46d1e3..e6bf5f26d 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine.c,v 1.323 2006/04/08 16:42:37 valtri Exp $ + * $Id: xine.c,v 1.324 2006/07/03 10:55:37 dgp85 Exp $ */ /* @@ -1546,6 +1546,18 @@ void xine_init (xine_t *this) { "messed up xine."), XINE_CONFIG_SECURITY, NULL, this); + /* + * timeout for network I/O to avoid freezes + */ + this->config->register_num(this->config, + "media.network.timeout", 30, + _("Timeout for network stream reading (in seconds)"), + _("Specifies the timeout when reading from network streams, in seconds." + "Too low values might stop streaming when the source is slow or the" + "bandwidth is occupied, too high values will freeze the player if the" + "connection is lost."), + 0, NULL, this); + /* * keep track of all opened streams */ -- cgit v1.2.3