changeset 21404:896a8210ed9f

Make sure we do not hang if no streams are available
author reimar
date Fri, 01 Dec 2006 18:51:44 +0000
parents c91294804a0b
children a120cda87e3e
files libmpdemux/demux_avi.c
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_avi.c	Fri Dec 01 17:57:29 2006 +0000
+++ b/libmpdemux/demux_avi.c	Fri Dec 01 18:51:44 2006 +0000
@@ -775,9 +775,13 @@
 	    if (*(int *)arg >= 0)
 	      ds->id = *(int *)arg;
 	    else {
+	      int id = ds->id;
 	      do {
-	        if (++ds->id >= maxid) ds->id = 0;
-	      } while (!streams[ds->id]);
+	        if (++id >= maxid) id = 0;
+	        if (id == ds->id) // no streams available
+	          return DEMUXER_CTRL_NOTIMPL;
+	      } while (!streams[id]);
+	      ds->id = id;
 	    }
 
 	    chunkid = (ds->id / 10 + '0') | (ds->id % 10 + '0') << 8;