diff options
author | jstebbins <[email protected]> | 2011-02-12 21:38:34 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-02-12 21:38:34 +0000 |
commit | 8bf55ae1a275b3576971c4596c4b0b1090902364 (patch) | |
tree | 754846425d4660147e7d658cf500359c7298866d | |
parent | 335e7e305d59063132ddae2fff76e7c6c7b02d47 (diff) |
plug some memory leaks.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3797 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/decavcodec.c | 5 | ||||
-rw-r--r-- | libhb/decmpeg2.c | 2 | ||||
-rw-r--r-- | libhb/fifo.c | 20 | ||||
-rw-r--r-- | libhb/reader.c | 5 | ||||
-rw-r--r-- | libhb/work.c | 16 |
5 files changed, 36 insertions, 12 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 298fba69d..612991c79 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -64,6 +64,7 @@ #include "downmix.h" #include "libavcodec/audioconvert.h" +static void flushDelayQueue( hb_work_private_t *pv ); static int decavcodecInit( hb_work_object_t *, hb_job_t * ); static int decavcodecWork( hb_work_object_t *, hb_buffer_t **, hb_buffer_t ** ); static void decavcodecClose( hb_work_object_t * ); @@ -271,6 +272,8 @@ static void closePrivData( hb_work_private_t ** ppv ) if ( pv ) { + flushDelayQueue( pv ); + if ( pv->job && pv->context && pv->context->codec ) { hb_log( "%s-decoder done: %u frames, %u decoder errors, %u drops", @@ -291,7 +294,7 @@ static void closePrivData( hb_work_private_t ** ppv ) } if ( pv->list ) { - hb_list_close( &pv->list ); + hb_list_empty( &pv->list ); } if ( pv->buffer ) { diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c index 1d2d059b8..6604ac1ea 100644 --- a/libhb/decmpeg2.c +++ b/libhb/decmpeg2.c @@ -834,7 +834,7 @@ static void decmpeg2Close( hb_work_object_t * w ) { hb_log( "mpeg2 done: %d frames", pv->libmpeg2->nframes ); } - hb_list_close( &pv->list ); + hb_list_empty( &pv->list ); if ( pv->libmpeg2->list_subtitle ) { hb_list_close( &pv->libmpeg2->list_subtitle ); diff --git a/libhb/fifo.c b/libhb/fifo.c index a29e84696..755a6d164 100644 --- a/libhb/fifo.c +++ b/libhb/fifo.c @@ -193,18 +193,22 @@ void hb_buffer_realloc( hb_buffer_t * b, int size ) void hb_buffer_close( hb_buffer_t ** _b ) { hb_buffer_t * b = *_b; - hb_fifo_t *buffer_pool = size_to_pool( b->alloc ); - if( buffer_pool && b->data && !hb_fifo_is_full( buffer_pool ) ) - { - hb_fifo_push_head( buffer_pool, b ); - *_b = NULL; - return; - } - /* either the pool is full or this size doesn't use a pool - free the buf */ while( b ) { hb_buffer_t * next = b->next; + hb_fifo_t *buffer_pool = size_to_pool( b->alloc ); + + b->next = NULL; + + if( buffer_pool && b->data && !hb_fifo_is_full( buffer_pool ) ) + { + hb_fifo_push_head( buffer_pool, b ); + b = next; + continue; + } + // either the pool is full or this size doesn't use a pool + // free the buf if( b->data ) { free( b->data ); diff --git a/libhb/reader.c b/libhb/reader.c index 783535492..bd3758eea 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -84,9 +84,14 @@ static void push_buf( const hb_reader_t *r, hb_fifo_t *fifo, hb_buffer_t *buf ) if ( hb_fifo_full_wait( fifo ) ) { hb_fifo_push( fifo, buf ); + buf = NULL; break; } } + if ( buf ) + { + hb_buffer_close( &buf ); + } } static int is_audio( hb_reader_t *r, int id ) diff --git a/libhb/work.c b/libhb/work.c index 045f5b9bb..e3d094542 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -984,10 +984,10 @@ static void do_job( hb_job_t * job, int cpu_count ) w = muxer; } + hb_buffer_t * buf_in, * buf_out; + while ( !*job->die && !*w->done && w->status != HB_WORK_DONE ) { - hb_buffer_t * buf_in, * buf_out; - buf_in = hb_fifo_get_wait( w->fifo_in ); if ( buf_in == NULL ) continue; @@ -1018,12 +1018,18 @@ static void do_job( hb_job_t * job, int cpu_count ) if ( hb_fifo_full_wait( w->fifo_out ) ) { hb_fifo_push( w->fifo_out, buf_out ); + buf_out = NULL; break; } } } } + if ( buf_out ) + { + hb_buffer_close( &buf_out ); + } + hb_handle_t * h = job->h; hb_state_t state; hb_get_state( h, &state ); @@ -1253,11 +1259,17 @@ static void work_loop( void * _w ) if ( hb_fifo_full_wait( w->fifo_out ) ) { hb_fifo_push( w->fifo_out, buf_out ); + buf_out = NULL; break; } } } } + if ( buf_out ) + { + hb_buffer_close( &buf_out ); + } + // Consume data in incoming fifo till job complete so that // residual data does not stall the pipeline while( !*w->done ) |