changeset 21405:a120cda87e3e

Proper fix for last demux_avi commit, stream switching now really should not hang anymore
author reimar
date Fri, 01 Dec 2006 19:24:42 +0000
parents 896a8210ed9f
children 3acff79cdd9f
files libmpdemux/demux_avi.c
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_avi.c	Fri Dec 01 18:51:44 2006 +0000
+++ b/libmpdemux/demux_avi.c	Fri Dec 01 19:24:42 2006 +0000
@@ -775,18 +775,19 @@
 	    if (*(int *)arg >= 0)
 	      ds->id = *(int *)arg;
 	    else {
-	      int id = ds->id;
-	      do {
-	        if (++id >= maxid) id = 0;
-	        if (id == ds->id) // no streams available
-	          return DEMUXER_CTRL_NOTIMPL;
-	      } while (!streams[id]);
-	      ds->id = id;
+	      int i;
+	      for (i = 0; i < maxid; i++) {
+	        if (++ds->id >= maxid) ds->id = 0;
+	        if (streams[ds->id]) break;
+	      }
 	    }
 
 	    chunkid = (ds->id / 10 + '0') | (ds->id % 10 + '0') << 8;
 	    ds->sh = NULL;
-	    demux_avi_select_stream(demuxer, chunkid);
+	    if (!streams[ds->id]) // stream not available
+	      ds->id = -1;
+	    else
+	      demux_avi_select_stream(demuxer, chunkid);
 	    *(int *)arg = ds->id;
 	    return DEMUXER_CTRL_OK;
 	}