[vlc-devel] commit: The msleep in stream.c is useless as access MUST wait themselves. ( Laurent Aimar )

git version control git at videolan.org
Sun Sep 7 23:11:56 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Sep  7 22:50:54 2008 +0200| [0069e74976a75ee075a901f4632b3a4239a48388] | committer: Laurent Aimar 

The msleep in stream.c is useless as access MUST wait themselves.

At worst it will use a lot of CPU but this will allow to detect buggy
access/access_demux module.

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

 src/input/stream.c |   31 +++++++++++--------------------
 1 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/src/input/stream.c b/src/input/stream.c
index d0bd67a..8ddb246 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -76,7 +76,6 @@
  *  We get blocks and put them in the linked list.
  *  We release blocks once the total size is bigger than CACHE_BLOCK_SIZE
  */
-#define STREAM_DATA_WAIT 40000       /* Time between before a pf_block retry */
 
 /* Method2: A bit more complex, for pf_read
  *  - We use ring buffers, only one if unseekable, all if seekable
@@ -863,9 +862,8 @@ static void AStreamPrebufferBlock( stream_t *s )
         /* Fetch a block */
         if( ( b = AReadBlock( s, &b_eof ) ) == NULL )
         {
-            if( b_eof ) break;
-
-            msleep( STREAM_DATA_WAIT );
+            if( b_eof )
+                break;
             continue;
         }
 
@@ -1201,15 +1199,14 @@ static int AStreamRefillBlock( stream_t *s )
     {
         bool b_eof;
 
-        if( s->b_die ) return VLC_EGENERIC;
-
+        if( s->b_die )
+            return VLC_EGENERIC;
 
         /* Fetch a block */
-        if( ( b = AReadBlock( s, &b_eof ) ) ) break;
-
-        if( b_eof ) return VLC_EGENERIC;
-
-        msleep( STREAM_DATA_WAIT );
+        if( ( b = AReadBlock( s, &b_eof ) ) )
+            break;
+        if( b_eof )
+            return VLC_EGENERIC;
     }
 
     while( b )
@@ -1563,12 +1560,12 @@ static int AStreamRefillStream( stream_t *s )
         /* msg_Dbg( s, "AStreamRefillStream: read=%d", i_read ); */
         if( i_read <  0 )
         {
-            msleep( STREAM_DATA_WAIT );
             continue;
         }
         else if( i_read == 0 )
         {
-            if( !b_read ) return VLC_EGENERIC;
+            if( !b_read )
+                return VLC_EGENERIC;
             return VLC_SUCCESS;
         }
         b_read = true;
@@ -1642,15 +1639,9 @@ static void AStreamPrebufferStream( stream_t *s )
         i_read = __MIN( p_sys->stream.i_read_size, i_read );
         i_read = AReadStream( s, &tk->p_buffer[tk->i_end], i_read );
         if( i_read <  0 )
-        {
-            msleep( STREAM_DATA_WAIT );
             continue;
-        }
         else if( i_read == 0 )
-        {
-            /* EOF */
-            break;
-        }
+            break;  /* EOF */
 
         if( i_first == 0 )
         {




More information about the vlc-devel mailing list