]> git.sesse.net Git - vlc/blobdiff - src/input/stream.c
* ALL: Major rework of the subpictures architecture.
[vlc] / src / input / stream.c
index fc6559c043871008d9b8dc224db819aaa24f28f5..762e0fa1a7d3ec67e5c76541487051f233253212 100644 (file)
@@ -450,7 +450,10 @@ static void AStreamPrebufferBlock( stream_t *s )
         }
 
         if( i_first == 0 )
+        {
             i_first = mdate();
+            msg_Dbg( s, "received first data for our buffer");
+        }
 
         /* Append the block */
         p_sys->block.i_size += b->i_buffer;
@@ -476,6 +479,9 @@ static int AStreamReadBlock( stream_t *s, void *p_read, int i_read )
     if( p_sys->block.p_current == NULL )
         return 0;
 
+    if( p_read == NULL )
+        return AStreamSeekBlock( s, p_sys->i_pos + i_read ) ? 0 : i_read;
+
     while( i_data < i_read )
     {
         int i_current =
@@ -792,6 +798,9 @@ static int AStreamReadStream( stream_t *s, void *p_read, int i_read )
 
     if( tk->i_start >= tk->i_end ) return 0; /* EOF */
 
+    if( p_read == NULL )
+        return AStreamSeekStream( s, p_sys->i_pos + i_read ) ? 0 : i_read;
+
 #if 0
     msg_Dbg( s, "AStreamReadStream: %d pos="I64Fd" tk=%d start="I64Fd
              " offset=%d end="I64Fd,
@@ -1028,6 +1037,7 @@ static int AStreamRefillStream( stream_t *s )
     int i_toread =
         __MIN( p_sys->stream.i_used, STREAM_CACHE_TRACK_SIZE -
                (tk->i_end - tk->i_start - p_sys->stream.i_offset) );
+    vlc_bool_t b_read = VLC_FALSE;
     int64_t i_start, i_stop;
 
     if( i_toread <= 0 ) return VLC_EGENERIC; /* EOF */
@@ -1054,8 +1064,11 @@ static int AStreamRefillStream( stream_t *s )
         }
         else if( i_read == 0 )
         {
-            return VLC_EGENERIC;
+            if( !b_read )
+                return VLC_EGENERIC;
+            return VLC_SUCCESS;
         }
+        b_read = VLC_TRUE;
 
         /* Update end */
         tk->i_end += i_read;
@@ -1089,6 +1102,8 @@ static void AStreamPrebufferStream( stream_t *s )
 
     int64_t i_first = 0;
     int64_t i_start;
+    int64_t i_prebuffer = (s->p_sys->p_access->info.i_title > 1 ||
+                           s->p_sys->p_access->info.i_seekpoint > 1) ? STREAM_CACHE_PREBUFFER_SIZE : STREAM_CACHE_TRACK_SIZE / 3;
 
     msg_Dbg( s, "pre buffering" );
     i_start = mdate();
@@ -1099,7 +1114,7 @@ static void AStreamPrebufferStream( stream_t *s )
         int64_t i_date = mdate();
         int i_read;
 
-        if( s->b_die || tk->i_end >= STREAM_CACHE_PREBUFFER_SIZE ||
+        if( s->b_die || tk->i_end >= i_prebuffer ||
             (i_first > 0 && i_first + STREAM_CACHE_PREBUFFER_LENGTH < i_date) )
         {
             int64_t i_byterate;
@@ -1135,7 +1150,10 @@ static void AStreamPrebufferStream( stream_t *s )
         }
 
         if( i_first == 0 )
+        {
             i_first = mdate();
+            msg_Dbg( s, "received first data for our buffer");
+        }
 
         tk->i_end += i_read;
 
@@ -1192,7 +1210,8 @@ char *stream_ReadLine( stream_t *s )
     }
 
     /* Remove trailing LF/CR */
-    while( i_line > 0 && ( p_line[i_line-1] == '\r' || p_line[i_line-1] == '\n') ) i_line--;
+    while( i_line > 0 && ( p_line[i_line-1] == '\r' ||
+           p_line[i_line-1] == '\n') ) i_line--;
 
     if( i_read > 0 )
     {
@@ -1200,7 +1219,7 @@ char *stream_ReadLine( stream_t *s )
         return p_line;
     }
 
-    /* We failed to read any data, probably EOF*/
+    /* We failed to read any data, probably EOF */
     if( p_line ) free( p_line );
     return NULL;
 }