From dc499445be7562f1fd144b0c5c0ed7f07e215d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net> Date: Wed, 20 Mar 2019 06:29:21 +0200 Subject: [PATCH] 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. --- 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 2dfc7b4c6c8b..62b5e89d0d4b 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..." ); } } -- GitLab