[vlc-commits] Smooth Streaming: don't use block_t

Frédéric Yhuel git at videolan.org
Fri Oct 12 11:22:37 CEST 2012


vlc | branch: master | Frédéric Yhuel <yhuelf at gmail.com> | Wed Oct 10 18:54:58 2012 +0200| [0986ff4adb63ebba6951a2d3112b65fe89b086d8] | committer: Jean-Baptiste Kempf

Smooth Streaming: don't use block_t

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/stream_filter/smooth/downloader.c |   17 ++++++++---------
 modules/stream_filter/smooth/smooth.c     |   10 +++++-----
 modules/stream_filter/smooth/smooth.h     |    2 +-
 modules/stream_filter/smooth/utils.c      |    5 ++---
 4 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/modules/stream_filter/smooth/downloader.c b/modules/stream_filter/smooth/downloader.c
index b5222d4..26cca95 100644
--- a/modules/stream_filter/smooth/downloader.c
+++ b/modules/stream_filter/smooth/downloader.c
@@ -78,7 +78,7 @@ static unsigned set_track_id( chunk_t *chunk, const unsigned tid )
     uint32_t size, type;
     if( !chunk->data )
         return 0;
-    uint8_t *slice = chunk->data->p_buffer;
+    uint8_t *slice = chunk->data;
     if( !slice )
         return 0;
 
@@ -121,7 +121,7 @@ static int sms_Download( stream_t *s, chunk_t *chunk, char *url )
     chunk->offset = p_sys->download.next_chunk_offset;
     p_sys->download.next_chunk_offset += chunk->size;
 
-    chunk->data = block_Alloc( size );
+    chunk->data = malloc( size );
 
     if( chunk->data == NULL )
     {
@@ -129,12 +129,12 @@ static int sms_Download( stream_t *s, chunk_t *chunk, char *url )
         return VLC_ENOMEM;
     }
 
-    int read = stream_Read( p_ts, chunk->data->p_buffer, size );
+    int read = stream_Read( p_ts, chunk->data, size );
     if( read < size )
     {
         msg_Warn( s, "sms_Download: I requested %"PRIi64" bytes, "\
                 "but I got only %i", size, read );
-        chunk->data = block_Realloc( chunk->data, 0, read );
+        chunk->data = realloc( chunk->data, read );
     }
 
     stream_Delete( p_ts );
@@ -190,7 +190,7 @@ static int get_new_chunks( stream_t *s, chunk_t *ck )
 {
     stream_sys_t *p_sys = s->p_sys;
 
-    uint8_t *slice = ck->data->p_buffer;
+    uint8_t *slice = ck->data;
     if( !slice )
         return VLC_EGENERIC;
     uint8_t version, fragment_count;
@@ -359,11 +359,11 @@ static chunk_t *build_init_chunk( stream_t *s )
         goto build_init_chunk_error;
 
     ret->size = SMOO_SIZE;
-    ret->data = block_Alloc( SMOO_SIZE );
+    ret->data = malloc( SMOO_SIZE );
     if( !ret->data )
         goto build_init_chunk_error;
 
-    int res = build_smoo_box( s, ret->data->p_buffer );
+    int res = build_smoo_box( s, ret->data );
     if( res != VLC_SUCCESS )
         goto build_init_chunk_error;
 
@@ -639,8 +639,7 @@ void* sms_Thread( void *p_this )
                 ck->read_pos = 0;
                 if( ck->data == NULL )
                     continue;
-                block_Release( ck->data );
-                ck->data = NULL;
+                FREENULL( ck->data );
             }
 
             vlc_array_destroy( p_sys->download.chunks );
diff --git a/modules/stream_filter/smooth/smooth.c b/modules/stream_filter/smooth/smooth.c
index 9a4ad20..7293ab1 100644
--- a/modules/stream_filter/smooth/smooth.c
+++ b/modules/stream_filter/smooth/smooth.c
@@ -570,8 +570,8 @@ static int sms_Read( stream_t *s, uint8_t *p_read, int i_read )
             }
             if( !p_sys->b_cache || p_sys->b_live )
             {
-                block_Release( chunk->data );
-                chunk->data = NULL;
+                FREENULL( chunk->data );
+                chunk->read_pos = 0;
             }
 
             chunk->read_pos = 0;
@@ -589,14 +589,14 @@ static int sms_Read( stream_t *s, uint8_t *p_read, int i_read )
                         verb, chunk->sequence, i_read, chunk->type );
             /* check integrity */
             uint32_t type;
-            uint8_t *slice = chunk->data->p_buffer;
+            uint8_t *slice = chunk->data;
             SMS_GET4BYTES( type );
             SMS_GETFOURCC( type );
             assert( type == ATOM_moof || type == ATOM_uuid );
         }
 
         int len = -1;
-        uint8_t *src = chunk->data->p_buffer + chunk->read_pos;
+        uint8_t *src = chunk->data + chunk->read_pos;
         if( i_read <= chunk->size - chunk->read_pos )
             len = i_read;
         else
@@ -655,7 +655,7 @@ static int Peek( stream_t *s, const uint8_t **pp_peek, unsigned i_peek )
         msg_Err( s, "could not peek %u bytes, only %i!", i_peek, bytes );
     }
     msg_Dbg( s, "peeking at chunk %u!", chunk->sequence );
-    *pp_peek = chunk->data->p_buffer + chunk->read_pos;
+    *pp_peek = chunk->data + chunk->read_pos;
 
     return bytes;
 }
diff --git a/modules/stream_filter/smooth/smooth.h b/modules/stream_filter/smooth/smooth.h
index 965fa0e..c121973 100644
--- a/modules/stream_filter/smooth/smooth.h
+++ b/modules/stream_filter/smooth/smooth.h
@@ -49,7 +49,7 @@ typedef struct chunk_s
     int         read_pos;   /* position in the chunk */
     int         type;       /* video, audio, or subtitles */
 
-    block_t     *data;
+    uint8_t     *data;
 } chunk_t;
 
 typedef struct quality_level_s
diff --git a/modules/stream_filter/smooth/utils.c b/modules/stream_filter/smooth/utils.c
index d02d63c..eb2a4bc 100644
--- a/modules/stream_filter/smooth/utils.c
+++ b/modules/stream_filter/smooth/utils.c
@@ -98,9 +98,8 @@ chunk_t *chunk_New( sms_stream_t* sms, uint64_t duration,\
 void chunk_Free( chunk_t *chunk )
 {
     if( chunk->data )
-        block_Release( chunk->data );
-    free( chunk );
-    chunk = NULL;
+        FREENULL( chunk->data );
+    FREENULL( chunk );
 }
 
 sms_stream_t * sms_New( void )



More information about the vlc-commits mailing list