]> git.sesse.net Git - vlc/blobdiff - src/input/stream.c
Removed useless ACCESS_GET_MTU/STREAM_GET_MTU.
[vlc] / src / input / stream.c
index 128a084afb23d5c6f6ee4676de4c4d9e26720745..66cb58fdd4da53638d4ceaacef3738b7400d729f 100644 (file)
@@ -266,7 +266,7 @@ stream_t *__stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
         return NULL;
     }
 
-    if( !( p_res = stream_AccessNew( p_access ) ) )
+    if( !( p_res = stream_AccessNew( p_access, NULL ) ) )
     {
         access_Delete( p_access );
         return NULL;
@@ -276,16 +276,15 @@ stream_t *__stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
     return p_res;
 }
 
-stream_t *stream_AccessNew( access_t *p_access )
+stream_t *stream_AccessNew( access_t *p_access, char **ppsz_list )
 {
     stream_t *s = stream_CommonNew( VLC_OBJECT(p_access) );
     stream_sys_t *p_sys;
-    char *psz_list = NULL;
 
     if( !s )
         return NULL;
 
-    s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
+    s->p_sys = p_sys = malloc( sizeof( *p_sys ) );
     if( !p_sys )
     {
         stream_CommonDelete( s );
@@ -317,67 +316,54 @@ stream_t *stream_AccessNew( access_t *p_access )
     p_sys->stat.i_seek_count = 0;
     p_sys->stat.i_seek_time = 0;
 
-    p_sys->i_list = 0;
-    p_sys->list = 0;
+    TAB_INIT( p_sys->i_list, p_sys->list );
     p_sys->i_list_index = 0;
-    p_sys->p_list_access = 0;
+    p_sys->p_list_access = NULL;
 
     /* Get the additional list of inputs if any (for concatenation) */
-    if( (psz_list = var_CreateGetString( s, "input-list" )) && *psz_list )
+    if( ppsz_list && ppsz_list[0] )
     {
-        access_entry_t *p_entry = malloc( sizeof(access_entry_t) );
-        if( p_entry == NULL )
+        access_entry_t *p_entry = malloc( sizeof(*p_entry) );
+        if( !p_entry )
             goto error;
-        char *psz_name, *psz_parser = psz_name = psz_list;
 
-        p_sys->p_list_access = p_access;
         p_entry->i_size = p_access->info.i_size;
         p_entry->psz_path = strdup( p_access->psz_path );
-        if( p_entry->psz_path == NULL )
+        if( !p_entry->psz_path )
         {
             free( p_entry );
             goto error;
         }
+        p_sys->p_list_access = p_access;
         TAB_APPEND( p_sys->i_list, p_sys->list, p_entry );
         msg_Dbg( p_access, "adding file `%s', (%"PRId64" bytes)",
                  p_entry->psz_path, p_access->info.i_size );
 
-        while( psz_name && *psz_name )
+        for( int i = 0; ppsz_list[i] != NULL; i++ )
         {
-            psz_parser = strchr( psz_name, ',' );
-            if( psz_parser ) *psz_parser = 0;
+            char *psz_name = strdup( ppsz_list[i] );
 
-            psz_name = strdup( psz_name );
-            if( psz_name )
-            {
-                access_t *p_tmp = access_New( p_access, p_access->psz_access,
-                                               "", psz_name );
+            if( !psz_name )
+                break;
 
-                if( !p_tmp )
-                {
-                    psz_name = psz_parser;
-                    if( psz_name ) psz_name++;
-                    continue;
-                }
+            access_t *p_tmp = access_New( p_access,
+                                          p_access->psz_access, "", psz_name );
+            if( !p_tmp )
+                continue;
 
-                msg_Dbg( p_access, "adding file `%s', (%"PRId64" bytes)",
-                         psz_name, p_tmp->info.i_size );
+            msg_Dbg( p_access, "adding file `%s', (%"PRId64" bytes)",
+                     psz_name, p_tmp->info.i_size );
 
-                p_entry = malloc( sizeof(access_entry_t) );
-                if( p_entry == NULL )
-                    goto error;
+            p_entry = malloc( sizeof(*p_entry) );
+            if( p_entry )
+            {
                 p_entry->i_size = p_tmp->info.i_size;
                 p_entry->psz_path = psz_name;
                 TAB_APPEND( p_sys->i_list, p_sys->list, p_entry );
-
-                access_Delete( p_tmp );
             }
-
-            psz_name = psz_parser;
-            if( psz_name ) psz_name++;
+            access_Delete( p_tmp );
         }
     }
-    FREENULL( psz_list );
 
     /* Peek */
     p_sys->i_peek = 0;
@@ -424,12 +410,10 @@ stream_t *stream_AccessNew( access_t *p_access )
         if( p_sys->stream.p_buffer == NULL )
             goto error;
         p_sys->stream.i_used   = 0;
-        access_Control( p_access, ACCESS_GET_MTU,
-                         &p_sys->stream.i_read_size );
-        if( p_sys->stream.i_read_size <= 0 )
-            p_sys->stream.i_read_size = STREAM_READ_ATONCE;
-        else if( p_sys->stream.i_read_size <= 256 )
-            p_sys->stream.i_read_size = 256;
+        p_sys->stream.i_read_size = STREAM_READ_ATONCE;
+#if STREAM_READ_ATONCE < 256
+#   error "Invalid STREAM_READ_ATONCE value"
+#endif
 
         for( i = 0; i < STREAM_CACHE_TRACK; i++ )
         {
@@ -464,7 +448,6 @@ error:
     while( p_sys->i_list > 0 )
         free( p_sys->list[--(p_sys->i_list)] );
     free( p_sys->list );
-    free( psz_list );
     free( s->p_sys );
     vlc_object_detach( s );
     stream_CommonDelete( s );
@@ -630,9 +613,6 @@ static int AStreamControl( stream_t *s, int i_query, va_list args )
                 return VLC_EGENERIC;
             }
 
-        case STREAM_GET_MTU:
-            return VLC_EGENERIC;
-
         case STREAM_CONTROL_ACCESS:
         {
             i_int = (int) va_arg( args, int );
@@ -673,7 +653,6 @@ static int AStreamControl( stream_t *s, int i_query, va_list args )
 static void AStreamPrebufferBlock( stream_t *s )
 {
     stream_sys_t *p_sys = s->p_sys;
-    access_t     *p_access = p_sys->p_access;
 
     int64_t i_first = 0;
     int64_t i_start;
@@ -983,7 +962,7 @@ static int AStreamSeekBlock( stream_t *s, int64_t i_pos )
         }
         while( p_sys->block.i_start + p_sys->block.i_size < i_pos );
 
-        p_sys->block.i_offset = i_pos - p_sys->i_pos;
+        p_sys->block.i_offset += i_pos - p_sys->i_pos;
         p_sys->i_pos = i_pos;
 
         return VLC_SUCCESS;
@@ -1414,7 +1393,6 @@ static int AStreamRefillStream( stream_t *s )
 static void AStreamPrebufferStream( stream_t *s )
 {
     stream_sys_t *p_sys = s->p_sys;
-    access_t     *p_access = p_sys->p_access;
 
     int64_t i_first = 0;
     int64_t i_start;
@@ -1691,7 +1669,7 @@ static int AReadStream( stream_t *s, void *p_read, unsigned int i_read )
     int i_total = 0;
 
     if( s->p_parent && s->p_parent->p_parent &&
-        s->p_parent->p_parent->i_object_type == VLC_OBJECT_INPUT )
+        vlc_internals( s->p_parent->p_parent )->i_object_type == VLC_OBJECT_INPUT )
         p_input = (input_thread_t *)s->p_parent->p_parent;
 
     if( !p_sys->i_list )
@@ -1761,7 +1739,7 @@ static block_t *AReadBlock( stream_t *s, bool *pb_eof )
     int i_total = 0;
 
     if( s->p_parent && s->p_parent->p_parent &&
-        s->p_parent->p_parent->i_object_type == VLC_OBJECT_INPUT )
+        vlc_internals( s->p_parent->p_parent )->i_object_type == VLC_OBJECT_INPUT )
         p_input = (input_thread_t *)s->p_parent->p_parent;
 
     if( !p_sys->i_list )