[vlc-commits] avi: remove 10 ms sleeps

Rémi Denis-Courmont git at videolan.org
Wed Mar 20 05:36:24 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Mar 20 06:29:21 2019 +0200| [dc499445be7562f1fd144b0c5c0ed7f07e215d36] | committer: Rémi Denis-Courmont

avi: remove 10 ms sleeps

This originally was intended to leave the user a chance to stop the
input (assuming that vlc_object_t.b_die was atomic). But right now, it
leaves the demuxer infinitely. This does not even really solve the CPU
usage problem, as sleeping for 10 milliseconds might well be cause a
busy loop internally.

In practice, this nowadays relies on the VLC interrupt subsystem to
cause an I/O error if the user stops the (broken) input. That does not
depend on the demuxer sleeping to happen.

To completely address the problem, the demuxe callback should presumably
return after a few iterations, so that the input thread can pace and
eventually terminate cleanly.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc499445be7562f1fd144b0c5c0ed7f07e215d36
---

 modules/demux/avi/avi.c | 37 ++++++-------------------------------
 1 file changed, 6 insertions(+), 31 deletions(-)

diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 2dfc7b4c6c..62b5e89d0d 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -1085,17 +1085,8 @@ static int Demux_Seekable( demux_t *p_demux )
                         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) )
-                    {
-                        vlc_tick_sleep( VLC_HARD_MIN_SLEEP );
-
-                        if( !i_loop_count )
-                            msg_Warn( p_demux,
-                                      "don't seem to find any data..." );
-                    }
+                    if( !++i_loop_count )
+                         msg_Warn( p_demux, "don't seem to find any data..." );
                     continue;
                 }
                 else
@@ -1820,16 +1811,8 @@ static int AVI_StreamChunkFind( demux_t *p_demux, unsigned int i_stream )
                 return VLC_EGENERIC;
             }
 
-            /* 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) )
-            {
-                vlc_tick_sleep( VLC_HARD_MIN_SLEEP );
-
-                if( !i_loop_count )
-                    msg_Warn( p_demux, "don't seem to find any data..." );
-            }
+            if( !++i_loop_count )
+                 msg_Warn( p_demux, "don't seem to find any data..." );
         }
         else
         {
@@ -2238,16 +2221,8 @@ static int AVI_PacketSearch( demux_t *p_demux )
                 return VLC_SUCCESS;
         }
 
-        /* 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 (not that we care much anyway because
-         * this code is called only on broken files). */
-        if( !(++i_count % 1024) )
-        {
-            vlc_tick_sleep( VLC_HARD_MIN_SLEEP );
-            if( !i_count )
-                msg_Warn( p_demux, "trying to resync..." );
-        }
+        if( !++i_count )
+            msg_Warn( p_demux, "trying to resync..." );
     }
 }
 



More information about the vlc-commits mailing list