Commit dca61827 authored by Christophe Massiot's avatar Christophe Massiot

Fixed various memory leaks.

parent c570d9bc
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_decoder_thread.c: ac3 decoder thread * ac3_decoder_thread.c: ac3 decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder_thread.c,v 1.19 2000/12/21 13:25:50 massiot Exp $ * $Id: ac3_decoder_thread.c,v 1.20 2000/12/21 14:18:15 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -321,7 +321,8 @@ static void EndThread (ac3dec_thread_t * p_ac3dec) ...@@ -321,7 +321,8 @@ static void EndThread (ac3dec_thread_t * p_ac3dec)
} }
/* Destroy descriptor */ /* Destroy descriptor */
free (p_ac3dec); free( p_ac3dec->p_config );
free( p_ac3dec );
intf_DbgMsg ("ac3dec debug: ac3 decoder thread %p destroyed\n", p_ac3dec); intf_DbgMsg ("ac3dec debug: ac3 decoder thread %p destroyed\n", p_ac3dec);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* audio_decoder.c: MPEG audio decoder thread * audio_decoder.c: MPEG audio decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: audio_decoder.c,v 1.40 2000/12/21 13:25:50 massiot Exp $ * $Id: audio_decoder.c,v 1.41 2000/12/21 14:18:15 massiot Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -320,7 +320,8 @@ static void EndThread ( adec_thread_t *p_adec ) ...@@ -320,7 +320,8 @@ static void EndThread ( adec_thread_t *p_adec )
vlc_mutex_unlock (&(p_adec->p_aout_fifo->data_lock)); vlc_mutex_unlock (&(p_adec->p_aout_fifo->data_lock));
} }
/* Destroy descriptor */ /* Destroy descriptor */
free (p_adec); free( p_adec->p_config );
free( p_adec );
intf_DbgMsg ("adec debug: audio decoder thread %p destroyed\n", p_adec); intf_DbgMsg ("adec debug: audio decoder thread %p destroyed\n", p_adec);
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input.c,v 1.61 2000/12/21 13:54:15 massiot Exp $ * $Id: input.c,v 1.62 2000/12/21 14:18:15 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -316,18 +316,38 @@ static void EndThread( input_thread_t * p_input ) ...@@ -316,18 +316,38 @@ static void EndThread( input_thread_t * p_input )
for( i_es_loop = 0; i_es_loop < p_input->i_selected_es_number; for( i_es_loop = 0; i_es_loop < p_input->i_selected_es_number;
i_es_loop++ ) i_es_loop++ )
{ {
p_input->pp_selected_es[i_es_loop]->p_decoder_fifo->b_die = 1; decoder_fifo_t * p_decoder_fifo;
/* Make sure the thread leaves the GetByte() function */
vlc_mutex_lock( &p_input->pp_selected_es[i_es_loop]->p_decoder_fifo->data_lock); p_decoder_fifo = p_input->pp_selected_es[i_es_loop]->p_decoder_fifo;
vlc_cond_signal( &p_input->pp_selected_es[i_es_loop]->p_decoder_fifo->data_wait ); p_decoder_fifo->b_die = 1;
vlc_mutex_unlock( &p_input->pp_selected_es[i_es_loop]->p_decoder_fifo->data_lock );
/* Make sure the thread leaves the NextDataPacket() function */
vlc_mutex_lock( &p_decoder_fifo->data_lock);
vlc_cond_signal( &p_decoder_fifo->data_wait );
vlc_mutex_unlock( &p_decoder_fifo->data_lock );
/* Waiting for the thread to exit */ /* Waiting for the thread to exit */
vlc_thread_join( p_input->pp_selected_es[i_es_loop]->thread_id ); vlc_thread_join( p_input->pp_selected_es[i_es_loop]->thread_id );
/* Freeing all packets still in the decoder fifo. */
while( !DECODER_FIFO_ISEMPTY( *p_decoder_fifo ) )
{
p_decoder_fifo->pf_delete_pes( p_decoder_fifo->p_packets_mgt,
DECODER_FIFO_START( *p_decoder_fifo ) );
DECODER_FIFO_INCSTART( *p_decoder_fifo );
}
free( p_input->pp_selected_es[i_es_loop]->p_decoder_fifo ); free( p_input->pp_selected_es[i_es_loop]->p_decoder_fifo );
} }
/* Free demultiplexer's data */ /* Free demultiplexer's data */
p_input->p_plugin->pf_end( p_input );
free( p_input->p_plugin );
/* Free input structures */
input_EndStream( p_input );
free( p_input->pp_es );
free( p_input->pp_selected_es );
free( p_input );
/* Update status */ /* Update status */
*pi_status = THREAD_OVER; *pi_status = THREAD_OVER;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input.h: structures of the input not exported to other modules * input.h: structures of the input not exported to other modules
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input.h,v 1.4 2000/12/20 16:04:31 massiot Exp $ * $Id: input.h,v 1.5 2000/12/21 14:18:15 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -77,6 +77,7 @@ void NextDataPacket ( struct bit_stream_s * ); ...@@ -77,6 +77,7 @@ void NextDataPacket ( struct bit_stream_s * );
* Prototypes from input_programs.c * Prototypes from input_programs.c
*****************************************************************************/ *****************************************************************************/
void input_InitStream( struct input_thread_s *, size_t ); void input_InitStream( struct input_thread_s *, size_t );
void input_EndStream( struct input_thread_s * );
struct pgrm_descriptor_s * input_AddProgram( struct input_thread_s *, struct pgrm_descriptor_s * input_AddProgram( struct input_thread_s *,
u16, size_t ); u16, size_t );
void input_DelProgram( struct input_thread_s *, u16 ); void input_DelProgram( struct input_thread_s *, u16 );
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* FIXME : check the return value of realloc() and malloc() ! * FIXME : check the return value of realloc() and malloc() !
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input_programs.c,v 1.11 2000/12/21 13:54:15 massiot Exp $ * $Id: input_programs.c,v 1.12 2000/12/21 14:18:15 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -65,6 +65,32 @@ void input_InitStream( input_thread_t * p_input, size_t i_data_len ) ...@@ -65,6 +65,32 @@ void input_InitStream( input_thread_t * p_input, size_t i_data_len )
} }
} }
/*****************************************************************************
* input_EndStream: free all stream descriptors
*****************************************************************************/
void input_EndStream( input_thread_t * p_input )
{
int i, j;
for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
{
for( j = 0; j < p_input->stream.pp_programs[i]->i_es_number; j++ )
{
if( p_input->stream.pp_programs[i]->pp_es[j]->p_demux_data != NULL )
{
free( p_input->stream.pp_programs[i]->pp_es[j]->p_demux_data );
}
free( p_input->stream.pp_programs[i]->pp_es[j] );
}
if( p_input->stream.pp_programs[i]->p_demux_data != NULL )
{
free( p_input->stream.pp_programs[i]->p_demux_data );
}
free( p_input->stream.pp_programs[i] );
}
}
/***************************************************************************** /*****************************************************************************
* input_AddProgram: add and init a program descriptor * input_AddProgram: add and init a program descriptor
***************************************************************************** *****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management * input_ps.c: PS demux and packet management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ps.c,v 1.8 2000/12/20 18:45:43 massiot Exp $ * $Id: input_ps.c,v 1.9 2000/12/21 14:18:15 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -417,6 +417,7 @@ input_capabilities_t * PSKludge( void ) ...@@ -417,6 +417,7 @@ input_capabilities_t * PSKludge( void )
p_plugin = (input_capabilities_t *)malloc( sizeof(input_capabilities_t) ); p_plugin = (input_capabilities_t *)malloc( sizeof(input_capabilities_t) );
p_plugin->pf_init = PSInit; p_plugin->pf_init = PSInit;
p_plugin->pf_end = PSEnd;
p_plugin->pf_read = PSRead; p_plugin->pf_read = PSRead;
p_plugin->pf_demux = input_DemuxPS; /* FIXME: use i_p_config_t ! */ p_plugin->pf_demux = input_DemuxPS; /* FIXME: use i_p_config_t ! */
p_plugin->pf_new_packet = NewPacket; p_plugin->pf_new_packet = NewPacket;
......
...@@ -20,9 +20,6 @@ ...@@ -20,9 +20,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
/* repomp sur video_decoder.c
* FIXME: passer en terminate/destroy avec les signaux supplmentaires ?? */
/***************************************************************************** /*****************************************************************************
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
...@@ -364,6 +361,7 @@ static void ErrorThread( spudec_thread_t *p_spudec ) ...@@ -364,6 +361,7 @@ static void ErrorThread( spudec_thread_t *p_spudec )
static void EndThread( spudec_thread_t *p_spudec ) static void EndThread( spudec_thread_t *p_spudec )
{ {
intf_DbgMsg( "spudec debug: destroying spu decoder thread %p\n", p_spudec ); intf_DbgMsg( "spudec debug: destroying spu decoder thread %p\n", p_spudec );
free( p_spudec->p_config );
free( p_spudec ); free( p_spudec );
intf_DbgMsg( "spudec debug: spu decoder thread %p destroyed\n", p_spudec); intf_DbgMsg( "spudec debug: spu decoder thread %p destroyed\n", p_spudec);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_parser.c : video parser thread * video_parser.c : video parser thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_parser.c,v 1.55 2000/12/21 13:25:51 massiot Exp $ * $Id: video_parser.c,v 1.56 2000/12/21 14:18:15 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -313,11 +313,6 @@ static void EndThread( vpar_thread_t *p_vpar ) ...@@ -313,11 +313,6 @@ static void EndThread( vpar_thread_t *p_vpar )
intf_DbgMsg("vpar debug: destroying video parser thread %p\n", p_vpar); intf_DbgMsg("vpar debug: destroying video parser thread %p\n", p_vpar);
#ifdef DEBUG
/* Check for remaining PES packets */
/* XXX?? */
#endif
#ifdef STATS #ifdef STATS
intf_Msg("vpar stats: %d loops among %d sequence(s)\n", intf_Msg("vpar stats: %d loops among %d sequence(s)\n",
p_vpar->c_loops, p_vpar->c_sequences); p_vpar->c_loops, p_vpar->c_sequences);
...@@ -361,10 +356,6 @@ static void EndThread( vpar_thread_t *p_vpar ) ...@@ -361,10 +356,6 @@ static void EndThread( vpar_thread_t *p_vpar )
S.i_matrix_coefficients); S.i_matrix_coefficients);
#endif #endif
/* Destroy thread structures allocated by InitThread */
// vout_DestroyStream( p_vpar->p_vout, p_vpar->i_stream );
/* XXX?? */
/* Dispose of matrices if they have been allocated. */ /* Dispose of matrices if they have been allocated. */
if( p_vpar->sequence.intra_quant.b_allocated ) if( p_vpar->sequence.intra_quant.b_allocated )
{ {
...@@ -396,6 +387,7 @@ static void EndThread( vpar_thread_t *p_vpar ) ...@@ -396,6 +387,7 @@ static void EndThread( vpar_thread_t *p_vpar )
free( p_vpar->pp_vdec[0] ); free( p_vpar->pp_vdec[0] );
#endif #endif
free( p_vpar->p_config );
free( p_vpar ); free( p_vpar );
intf_DbgMsg("vpar debug: EndThread(%p)\n", p_vpar); intf_DbgMsg("vpar debug: EndThread(%p)\n", p_vpar);
......
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