]> git.sesse.net Git - vlc/blobdiff - src/input/stream.c
Remove uninitialized and unsynchronized global stats
[vlc] / src / input / stream.c
index 66cb58fdd4da53638d4ceaacef3738b7400d729f..ec2570502cf97b9b9c422f3a77f5e3e979d8cbb9 100644 (file)
@@ -40,7 +40,7 @@
 
 #include "input_internal.h"
 
-#undef STREAM_DEBUG
+// #define STREAM_DEBUG 1
 
 /* TODO:
  *  - tune the 2 methods (block/stream)
@@ -237,6 +237,7 @@ void stream_CommonDelete( stream_t *s )
             vlc_iconv_close( s->p_text->conv );
         free( s->p_text );
     }
+    free( s->psz_path );
     vlc_object_release( s );
 }
 
@@ -284,8 +285,9 @@ stream_t *stream_AccessNew( access_t *p_access, char **ppsz_list )
     if( !s )
         return NULL;
 
+    s->psz_path = strdup( p_access->psz_path );
     s->p_sys = p_sys = malloc( sizeof( *p_sys ) );
-    if( !p_sys )
+    if( !s->psz_path || !s->p_sys )
     {
         stream_CommonDelete( s );
         return NULL;
@@ -974,7 +976,6 @@ static int AStreamSeekBlock( stream_t *s, int64_t i_pos )
 static int AStreamRefillBlock( stream_t *s )
 {
     stream_sys_t *p_sys = s->p_sys;
-    int64_t      i_start, i_stop;
     block_t      *b;
 
     /* Release data */
@@ -998,7 +999,7 @@ static int AStreamRefillBlock( stream_t *s )
     }
 
     /* Now read a new block */
-    i_start = mdate();
+    const int64_t i_start = mdate();
     for( ;; )
     {
         bool b_eof;
@@ -1013,10 +1014,9 @@ static int AStreamRefillBlock( stream_t *s )
             return VLC_EGENERIC;
     }
 
+    p_sys->stat.i_read_time += mdate() - i_start;
     while( b )
     {
-        i_stop = mdate();
-
         /* Append the block */
         p_sys->block.i_size += b->i_buffer;
         *p_sys->block.pp_last = b;
@@ -1028,11 +1028,9 @@ static int AStreamRefillBlock( stream_t *s )
 
         /* Update stat */
         p_sys->stat.i_bytes += b->i_buffer;
-        p_sys->stat.i_read_time += i_stop - i_start;
         p_sys->stat.i_read_count++;
 
         b = b->p_next;
-        i_start = mdate();
     }
     return VLC_SUCCESS;
 }