summaryrefslogtreecommitdiff
path: root/src/input/mmsh.c
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2003-02-05 00:08:55 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2003-02-05 00:08:55 +0000
commit4e0331fac2b197b5d6b20a987f2e54cff2f67ad4 (patch)
tree78ab654be8f591eb92f8cefa60bbaefdf306b678 /src/input/mmsh.c
parent9cb0f1dd7c89891c6c80614ad13f4643ba00d566 (diff)
downloadxine-lib-4e0331fac2b197b5d6b20a987f2e54cff2f67ad4.tar.gz
xine-lib-4e0331fac2b197b5d6b20a987f2e54cff2f67ad4.tar.bz2
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
Diffstat (limited to 'src/input/mmsh.c')
-rw-r--r--src/input/mmsh.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/input/mmsh.c b/src/input/mmsh.c
index db3a256c2..d75a7154e 100644
--- a/src/input/mmsh.c
+++ b/src/input/mmsh.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: mmsh.c,v 1.10 2003/01/31 14:06:17 miguelfreitas Exp $
+ * $Id: mmsh.c,v 1.11 2003/02/05 00:10:30 miguelfreitas Exp $
*
* based on mms.c and specs from avifile
* (http://avifile.sourceforge.net/asf-1.0.htm)
@@ -180,28 +180,34 @@ static ssize_t read_timeout(int fd, void *buf, size_t count) {
while (total < count) {
- fd_set rset;
- struct timeval timeout;
+ ret=read (fd, ((uint8_t*)buf)+total, count-total);
- FD_ZERO (&rset);
- FD_SET (fd, &rset);
-
- timeout.tv_sec = 30;
- timeout.tv_usec = 0;
+ if (ret<0) {
+ if(errno == EAGAIN) {
+ fd_set rset;
+ struct timeval timeout;
- if (select (fd+1, &rset, NULL, NULL, &timeout) <= 0) {
- return -1;
- }
-
- ret=read (fd, ((uint8_t*)buf)+total, count-total);
+ FD_ZERO (&rset);
+ FD_SET (fd, &rset);
+
+ timeout.tv_sec = 30;
+ timeout.tv_usec = 0;
+
+ if (select (fd+1, &rset, NULL, NULL, &timeout) <= 0) {
+ return -1;
+ }
+ continue;
+ }
- if (ret<=0) {
#ifdef LOG
printf ("libmmsh: read error.\n");
#endif
return ret;
} else
total += ret;
+
+ /* end of stream */
+ if (!ret) break;
}
#ifdef LOG