]> git.sesse.net Git - vlc/blobdiff - src/input/stream.c
macosx: Fix crash log and remove some unneeded NSLog.
[vlc] / src / input / stream.c
index 48174e7b8544f287539a73f636696ea3ba754909..019e5c00dd37e238895bd846897dffcd7c1704f8 100644 (file)
@@ -297,10 +297,7 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
 
     s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
     if( p_sys == NULL )
-    {
-        msg_Err( s, "Out of memory when allocating stream_sys_t" );
         goto error;
-    }
 
     /* UTF16 and UTF32 text file conversion */
     s->i_char_width = 1;
@@ -338,10 +335,7 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
     {
         access_entry_t *p_entry = malloc( sizeof(access_entry_t) );
         if( p_entry == NULL )
-        {
-            msg_Err( s, "Out of memory when allocating access_entry_t" );
             goto error;
-        }
         char *psz_name, *psz_parser = psz_name = psz_list;
 
         p_sys->p_list_access = p_access;
@@ -349,7 +343,6 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
         p_entry->psz_path = strdup( p_access->psz_path );
         if( p_entry->psz_path == NULL )
         {
-            msg_Err( s, "Out of memory when duplicating p_access->psz_path" );
             free( p_entry );
             goto error;
         }
@@ -380,10 +373,7 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
 
                 p_entry = malloc( sizeof(access_entry_t) );
                 if( p_entry == NULL )
-                {
-                    msg_Err( p_access, "Out of memory when allocating access_entry_t" );
                     goto error;
-                }
                 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 );
@@ -522,6 +512,7 @@ static void AStreamDestroy( stream_t *s )
     vlc_object_detach( s );
 
     if( p_sys->method == Block ) block_ChainRelease( p_sys->block.p_first );
+    else if ( p_sys->method == Immediate ) free( p_sys->immediate.p_buffer );
     else free( p_sys->stream.p_buffer );
 
     free( p_sys->p_peek );
@@ -545,7 +536,6 @@ static void UStreamDestroy( stream_t *s )
 {
     access_t *p_access = (access_t *)s->p_parent;
     AStreamDestroy( s );
-    vlc_object_release( p_access );
     access_Delete( p_access );
 }
 
@@ -1006,19 +996,21 @@ static int AStreamSeekBlock( stream_t *s, int64_t i_pos )
     }
     else
     {
-        /* Read enough data */
-        while( p_sys->block.i_start + p_sys->block.i_size < i_pos )
+        do
         {
+            /* Read and skip enough data */
             if( AStreamRefillBlock( s ) )
                 return VLC_EGENERIC;
 
             while( p_sys->block.p_current &&
-                   p_sys->i_pos + p_sys->block.p_current->i_buffer < i_pos )
+                   p_sys->i_pos + p_sys->block.p_current->i_buffer - p_sys->block.i_offset < i_pos )
             {
-                p_sys->i_pos += p_sys->block.p_current->i_buffer;
+                p_sys->i_pos += p_sys->block.p_current->i_buffer - p_sys->block.i_offset;
                 p_sys->block.p_current = p_sys->block.p_current->p_next;
+                p_sys->block.i_offset = 0;
             }
         }
+        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->i_pos = i_pos;
@@ -1793,10 +1785,7 @@ char * stream_ReadLine( stream_t *s )
             i_data = (psz_eol - (char *)p_data) + 1;
             p_line = realloc( p_line, i_line + i_data + s->i_char_width ); /* add \0 */
             if( !p_line )
-            {
-                msg_Err( s, "Out of memory when reallocating p_line" );
                 goto error;
-            }
             i_data = stream_Read( s, &p_line[i_line], i_data );
             if( i_data <= 0 ) break; /* Hmmm */
             i_line += i_data - s->i_char_width; /* skip \n */;
@@ -1809,10 +1798,7 @@ char * stream_ReadLine( stream_t *s )
         /* Read data (+1 for easy \0 append) */
         p_line = realloc( p_line, i_line + STREAM_PROBE_LINE + s->i_char_width );
         if( !p_line )
-        {
-            msg_Err( s, "Out of memory when reallocating p_line" );
             goto error;
-        }
         i_data = stream_Read( s, &p_line[i_line], STREAM_PROBE_LINE );
         if( i_data <= 0 ) break; /* Hmmm */
         i_line += i_data;
@@ -1837,10 +1823,7 @@ char * stream_ReadLine( stream_t *s )
             /* iconv */
             psz_new_line = malloc( i_line );
             if( psz_new_line == NULL )
-            {
-                msg_Err( s, "Out of memory when allocating psz_new_line" );
                 goto error;
-            }
             i_in = i_out = (size_t)i_line;
             p_in = p_line;
             p_out = psz_new_line;
@@ -1891,6 +1874,8 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
     if( !p_sys->i_list )
     {
         i_read = p_access->pf_read( p_access, p_read, i_read );
+        if( p_access->b_die )
+            vlc_object_kill( s );
         if( p_input )
         {
             vlc_mutex_lock( &p_input->p->counters.counters_lock );
@@ -1906,6 +1891,8 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
 
     i_read = p_sys->p_list_access->pf_read( p_sys->p_list_access, p_read,
                                             i_read );
+    if( p_access->b_die )
+        vlc_object_kill( s );
 
     /* If we reached an EOF then switch to the next stream in the list */
     if( i_read == 0 && p_sys->i_list_index + 1 < p_sys->i_list )
@@ -1957,6 +1944,8 @@ static block_t *AReadBlock( stream_t *s, bool *pb_eof )
     if( !p_sys->i_list )
     {
         p_block = p_access->pf_block( p_access );
+        if( p_access->b_die )
+            vlc_object_kill( s );
         if( pb_eof ) *pb_eof = p_access->info.b_eof;
         if( p_input && p_block && libvlc_stats (p_access) )
         {
@@ -1972,6 +1961,8 @@ static block_t *AReadBlock( stream_t *s, bool *pb_eof )
     }
 
     p_block = p_sys->p_list_access->pf_block( p_access );
+    if( p_access->b_die )
+        vlc_object_kill( s );
     b_eof = p_sys->p_list_access->info.b_eof;
     if( pb_eof ) *pb_eof = b_eof;