Commit 1ef0c797 authored by yhuelf's avatar yhuelf Committed by Jean-Baptiste Kempf
Browse files

Smooth Streaming: fix a memory leak



initialization chunks were not freed on Close()
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 0986ff4a
......@@ -514,6 +514,7 @@ static int Download( stream_t *s, sms_stream_t *sms )
vlc_mutex_lock( &p_sys->download.lock_wait );
vlc_array_append( p_sys->download.chunks, new_init_ck );
vlc_array_append( p_sys->init_chunks, new_init_ck );
vlc_mutex_unlock( &p_sys->download.lock_wait );
}
return VLC_SUCCESS;
......@@ -578,6 +579,7 @@ void* sms_Thread( void *p_this )
vlc_mutex_lock( &p_sys->download.lock_wait );
vlc_array_append( p_sys->download.chunks, init_ck );
vlc_array_append( p_sys->init_chunks, init_ck );
vlc_mutex_unlock( &p_sys->download.lock_wait );
p_sys->download.next_chunk_offset = init_ck->size;
......@@ -664,6 +666,7 @@ void* sms_Thread( void *p_this )
p_sys->download.next_chunk_offset += new_init_ck->size;
vlc_array_append( p_sys->download.chunks, new_init_ck );
vlc_array_append( p_sys->init_chunks, new_init_ck );
p_sys->b_tseek = false;
}
vlc_mutex_unlock( &p_sys->download.lock_wait );
......
......@@ -403,8 +403,9 @@ static int Open( vlc_object_t *p_this )
p_sys->sms_streams = vlc_array_new();
p_sys->selected_st = vlc_array_new();
p_sys->download.chunks = vlc_array_new();
p_sys->init_chunks = vlc_array_new();
if( unlikely( !p_sys->sms_streams || !p_sys->download.chunks ||
!p_sys->selected_st ) )
!p_sys->selected_st || !p_sys->init_chunks ) )
{
free( p_sys );
return VLC_ENOMEM;
......@@ -492,14 +493,22 @@ static void Close( vlc_object_t *p_this )
for( int i = 0; i < vlc_array_count( p_sys->sms_streams ); i++ )
{
sms = vlc_array_item_at_index( p_sys->sms_streams, i );
if( sms)
if( sms )
sms_Free( sms );
}
/* Free downloaded chunks */
chunk_t *chunk;
for( int i = 0; i < vlc_array_count( p_sys->init_chunks ); i++ )
{
chunk = vlc_array_item_at_index( p_sys->init_chunks, i );
chunk_Free( chunk );
}
sms_queue_free( p_sys->bws );
vlc_array_destroy( p_sys->sms_streams );
vlc_array_destroy( p_sys->selected_st );
vlc_array_destroy( p_sys->download.chunks );
vlc_array_destroy( p_sys->init_chunks );
free( p_sys->base_url );
free( p_sys );
......
......@@ -92,6 +92,7 @@ struct stream_sys_t
vlc_array_t *sms_streams; /* available streams */
vlc_array_t *selected_st; /* selected streams */
vlc_array_t *init_chunks;
unsigned i_tracks; /* Total number of tracks in the Manifest */
sms_queue_t *bws; /* Measured bandwidths of the N last chunks */
uint64_t vod_duration; /* total duration of the VOD media */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment