]> git.sesse.net Git - vlc/commitdiff
* modules/demux/avi/avi.c: Fixed infinite loop in the AVI demux on broken/incomplete...
authorGildas Bazin <gbazin@videolan.org>
Thu, 29 Apr 2004 14:43:12 +0000 (14:43 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 29 Apr 2004 14:43:12 +0000 (14:43 +0000)
NEWS
modules/demux/avi/avi.c

diff --git a/NEWS b/NEWS
index d25d36ec07d220799367283af16252bd2d9ceb65..0196cbe5f9f21cfad57a01fad6645ab485b14693 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,7 @@ Input:
 Demux:
  * Annodex (http://www.annodex.net) support.
  * mmsh streaming fixes.
+ * Fixed infinite loop in the AVI demux on broken/incomplete files.
 
 Subtitles:
  * Subviewer and subviewer v2 subtitles support.
index 9b5347d0e8420715e5f5a3406bb830e60863c3e4..d98bbab62d5ad953b45ad7bebec7679619c89960 100644 (file)
@@ -693,6 +693,8 @@ static int Demux_Seekable( demux_t *p_demux )
 
         if( i_pos == -1 )
         {
+            int i_loop_count = 0;
+
             /* no valid index, we will parse directly the stream
              * in case we fail we will disable all finished stream */
             if( p_sys->i_movi_lastchunk_pos >= p_sys->i_movi_begin + 12 )
@@ -727,6 +729,19 @@ static int Demux_Seekable( demux_t *p_demux )
                                   "cannot skip packet, track disabled" );
                         return( AVI_TrackStopFinishedStreams( p_demux ) ? 0 : 1 );
                     }
+
+                    /* Prevents from eating all the CPU with broken files.
+                     * This value should be low enough so that it doesn't
+                     * affect the reading speed too much. */
+                    if( !(++i_loop_count % 1024) )
+                    {
+                        if( p_demux->b_die ) return -1;
+                        msleep( 10000 );
+
+                        if( !(i_loop_count % (1024 * 10)) )
+                            msg_Warn( p_demux,
+                                      "doesn't seem to find any data..." );
+                    }
                     continue;
                 }
                 else