Commit 393a5d52 authored by Henri Fallon's avatar Henri Fallon

- Added vlc_mutex_destroy and vlc_cond_destroy function, for pthreads.
- Used them before quitting, every lock and cond is destroyed
- Checked the return value of malloc and realloc in input_programs
- Cosmetic changes

TODO: add vlc_*_destroy for beos and C_thread
parent eb8d4519
...@@ -70,7 +70,13 @@ ...@@ -70,7 +70,13 @@
* Types definition * Types definition
*****************************************************************************/ *****************************************************************************/
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
typedef pthread_t vlc_thread_t;
typedef pthread_mutex_t vlc_mutex_t;
typedef pthread_cond_t vlc_cond_t;
#elif defined(HAVE_CTHREADS_H)
typedef cthread_t vlc_thread_t; typedef cthread_t vlc_thread_t;
...@@ -111,12 +117,6 @@ typedef struct ...@@ -111,12 +117,6 @@ typedef struct
thread_id thread; thread_id thread;
} vlc_cond_t; } vlc_cond_t;
#elif defined(HAVE_PTHREAD_H)
typedef pthread_t vlc_thread_t;
typedef pthread_mutex_t vlc_mutex_t;
typedef pthread_cond_t vlc_cond_t;
#endif #endif
typedef void *(*vlc_thread_func_t)(void *p_data); typedef void *(*vlc_thread_func_t)(void *p_data);
...@@ -133,10 +133,12 @@ static __inline__ void vlc_thread_join ( vlc_thread_t thread ); ...@@ -133,10 +133,12 @@ static __inline__ void vlc_thread_join ( vlc_thread_t thread );
static __inline__ int vlc_mutex_init ( vlc_mutex_t *p_mutex ); static __inline__ int vlc_mutex_init ( vlc_mutex_t *p_mutex );
static __inline__ int vlc_mutex_lock ( vlc_mutex_t *p_mutex ); static __inline__ int vlc_mutex_lock ( vlc_mutex_t *p_mutex );
static __inline__ int vlc_mutex_unlock ( vlc_mutex_t *p_mutex ); static __inline__ int vlc_mutex_unlock ( vlc_mutex_t *p_mutex );
static __inline__ int vlc_mutex_destroy ( vlc_mutex_t *p_mutex );
static __inline__ int vlc_cond_init ( vlc_cond_t *p_condvar ); static __inline__ int vlc_cond_init ( vlc_cond_t *p_condvar );
static __inline__ int vlc_cond_signal ( vlc_cond_t *p_condvar ); static __inline__ int vlc_cond_signal ( vlc_cond_t *p_condvar );
static __inline__ int vlc_cond_wait ( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex ); static __inline__ int vlc_cond_wait ( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex );
static __inline__ int vlc_cond_destroy ( vlc_cond_t *p_condvar );
#if 0 #if 0
static _inline__ int vlc_cond_timedwait ( vlc_cond_t * condvar, vlc_mutex_t * mutex, static _inline__ int vlc_cond_timedwait ( vlc_cond_t * condvar, vlc_mutex_t * mutex,
...@@ -170,16 +172,16 @@ static __inline__ int vlc_thread_create( vlc_thread_t *p_thread, ...@@ -170,16 +172,16 @@ static __inline__ int vlc_thread_create( vlc_thread_t *p_thread,
*****************************************************************************/ *****************************************************************************/
static __inline__ void vlc_thread_exit( void ) static __inline__ void vlc_thread_exit( void )
{ {
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
pthread_exit( 0 );
#elif defined(HAVE_CTHREADS_H)
int result; int result;
cthread_exit( &result ); cthread_exit( &result );
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H) #elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H)
exit_thread( 0 ); exit_thread( 0 );
#elif defined(HAVE_PTHREAD_H)
pthread_exit( 0 );
#endif #endif
} }
...@@ -188,16 +190,16 @@ static __inline__ void vlc_thread_exit( void ) ...@@ -188,16 +190,16 @@ static __inline__ void vlc_thread_exit( void )
*****************************************************************************/ *****************************************************************************/
static __inline__ void vlc_thread_join( vlc_thread_t thread ) static __inline__ void vlc_thread_join( vlc_thread_t thread )
{ {
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
pthread_join( thread, NULL );
#elif defined(HAVE_CTHREADS_H)
cthread_join( thread ); cthread_join( thread );
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H) #elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H)
int32 exit_value; int32 exit_value;
wait_for_thread( thread, &exit_value ); wait_for_thread( thread, &exit_value );
#elif defined(HAVE_PTHREAD_H)
pthread_join( thread, NULL );
#endif #endif
} }
...@@ -206,7 +208,10 @@ static __inline__ void vlc_thread_join( vlc_thread_t thread ) ...@@ -206,7 +208,10 @@ static __inline__ void vlc_thread_join( vlc_thread_t thread )
*****************************************************************************/ *****************************************************************************/
static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex ) static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
{ {
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
return pthread_mutex_init( p_mutex, NULL );
#elif defined(HAVE_CTHREADS_H)
mutex_init( p_mutex ); mutex_init( p_mutex );
return 0; return 0;
...@@ -225,9 +230,6 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex ) ...@@ -225,9 +230,6 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
p_mutex->init = 9999; p_mutex->init = 9999;
return B_OK; return B_OK;
#elif defined(HAVE_PTHREAD_H)
return pthread_mutex_init( p_mutex, NULL );
#endif #endif
} }
...@@ -236,7 +238,10 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex ) ...@@ -236,7 +238,10 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
*****************************************************************************/ *****************************************************************************/
static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex ) static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
{ {
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
return pthread_mutex_lock( p_mutex );
#elif defined(HAVE_CTHREADS_H)
mutex_lock( p_mutex ); mutex_lock( p_mutex );
return 0; return 0;
...@@ -249,9 +254,6 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex ) ...@@ -249,9 +254,6 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
err = acquire_sem( p_mutex->lock ); err = acquire_sem( p_mutex->lock );
return err; return err;
#elif defined(HAVE_PTHREAD_H)
return pthread_mutex_lock( p_mutex );
#endif #endif
} }
...@@ -260,7 +262,10 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex ) ...@@ -260,7 +262,10 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
*****************************************************************************/ *****************************************************************************/
static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex ) static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
{ {
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
return pthread_mutex_unlock( p_mutex );
#elif defined(HAVE_CTHREADS_H)
mutex_unlock( p_mutex ); mutex_unlock( p_mutex );
return 0; return 0;
...@@ -272,9 +277,16 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex ) ...@@ -272,9 +277,16 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
release_sem( p_mutex->lock ); release_sem( p_mutex->lock );
return B_OK; return B_OK;
#elif defined(HAVE_PTHREAD_H) #endif
return pthread_mutex_unlock( p_mutex ); }
/*****************************************************************************
* vlc_mutex_destroy: destory a mutex
*****************************************************************************/
static __inline__ int vlc_mutex_destroy( vlc_mutex_t *p_mutex )
{
#if defined(HAVE_PTHREAD_H)
return pthread_mutex_destroy( p_mutex );
#endif #endif
} }
...@@ -283,7 +295,10 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex ) ...@@ -283,7 +295,10 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
*****************************************************************************/ *****************************************************************************/
static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar ) static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar )
{ {
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
return pthread_cond_init( p_condvar, NULL );
#elif defined(HAVE_CTHREADS_H)
/* condition_init() */ /* condition_init() */
spin_lock_init( &p_condvar->lock ); spin_lock_init( &p_condvar->lock );
cthread_queue_init( &p_condvar->queue ); cthread_queue_init( &p_condvar->queue );
...@@ -303,9 +318,6 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar ) ...@@ -303,9 +318,6 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar )
p_condvar->init = 9999; p_condvar->init = 9999;
return 0; return 0;
#elif defined(HAVE_PTHREAD_H)
return pthread_cond_init( p_condvar, NULL );
#endif #endif
} }
...@@ -314,7 +326,10 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar ) ...@@ -314,7 +326,10 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar )
*****************************************************************************/ *****************************************************************************/
static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar ) static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar )
{ {
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
return pthread_cond_signal( p_condvar );
#elif defined(HAVE_CTHREADS_H)
/* condition_signal() */ /* condition_signal() */
if ( p_condvar->queue.head || p_condvar->implications ) if ( p_condvar->queue.head || p_condvar->implications )
{ {
...@@ -351,9 +366,6 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar ) ...@@ -351,9 +366,6 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar )
return 0; return 0;
#elif defined(HAVE_PTHREAD_H)
return pthread_cond_signal( p_condvar );
#endif #endif
} }
...@@ -362,7 +374,10 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar ) ...@@ -362,7 +374,10 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar )
*****************************************************************************/ *****************************************************************************/
static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex ) static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
{ {
#if defined(HAVE_CTHREADS_H) #if defined(HAVE_PTHREAD_H)
return pthread_cond_wait( p_condvar, p_mutex );
#elif defined(HAVE_CTHREADS_H)
condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex ); condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex );
return 0; return 0;
...@@ -384,9 +399,15 @@ static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex ...@@ -384,9 +399,15 @@ static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex
vlc_mutex_lock( p_mutex ); vlc_mutex_lock( p_mutex );
return 0; return 0;
#elif defined(HAVE_PTHREAD_H)
return pthread_cond_wait( p_condvar, p_mutex );
#endif #endif
} }
/*****************************************************************************
* vlc_cond_destory: destroy a condition
*****************************************************************************/
static __inline__ int vlc_cond_destroy( vlc_cond_t *p_condvar )
{
#if defined(HAVE_PTHREAD_H)
return pthread_cond_destroy( p_condvar );
#endif
}
...@@ -66,7 +66,6 @@ void aout_AlsaClose ( aout_thread_t *p_aout ); ...@@ -66,7 +66,6 @@ void aout_AlsaClose ( aout_thread_t *p_aout );
*****************************************************************************/ *****************************************************************************/
plugin_info_t * GetConfig( void ) plugin_info_t * GetConfig( void )
{ {
int i_fd;
plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) ); plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
p_info->psz_name = "Alsa plugin"; p_info->psz_name = "Alsa plugin";
......
...@@ -259,7 +259,7 @@ long aout_AlsaGetBufInfo ( aout_thread_t *p_aout, long l_buffer_limit ) ...@@ -259,7 +259,7 @@ long aout_AlsaGetBufInfo ( aout_thread_t *p_aout, long l_buffer_limit )
return ( 1 ); return ( 1 );
} }
switch (alsa_channel_status.status) switch( alsa_channel_status.status )
{ {
case SND_PCM_STATUS_NOTREADY : intf_ErrMsg("Status NOT READY"); case SND_PCM_STATUS_NOTREADY : intf_ErrMsg("Status NOT READY");
break; break;
......
...@@ -339,6 +339,9 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) ...@@ -339,6 +339,9 @@ static int aout_SpawnThread( aout_thread_t * p_aout )
*****************************************************************************/ *****************************************************************************/
void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status ) void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
{ {
int i_fifo;
/* FIXME: pi_status is not handled correctly: check vout how to do!?? */ /* FIXME: pi_status is not handled correctly: check vout how to do!?? */
intf_DbgMsg("aout debug: requesting termination of audio output thread (%p)", p_aout); intf_DbgMsg("aout debug: requesting termination of audio output thread (%p)", p_aout);
...@@ -351,6 +354,14 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status ) ...@@ -351,6 +354,14 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
free( p_aout->buffer ); free( p_aout->buffer );
free( p_aout->s32_buffer ); free( p_aout->s32_buffer );
/* Destroy the condition and mutex locks */
vlc_mutex_destroy( &p_aout->fifos_lock );
for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
{
vlc_mutex_destroy( &p_aout->fifo[i_fifo].data_lock );
vlc_cond_destroy( &p_aout->fifo[i_fifo].data_wait );
}
/* Free the structure */ /* Free the structure */
p_aout->p_sys_close( p_aout ); p_aout->p_sys_close( p_aout );
intf_DbgMsg("aout debug: audio device (%s) closed", p_aout->psz_device); intf_DbgMsg("aout debug: audio device (%s) closed", p_aout->psz_device);
......
...@@ -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.65 2001/01/05 14:45:47 sam Exp $ * $Id: input.c,v 1.66 2001/01/07 03:56:40 henri Exp $
* *
* Authors: * Authors:
* *
...@@ -318,6 +318,10 @@ static void EndThread( input_thread_t * p_input ) ...@@ -318,6 +318,10 @@ static void EndThread( input_thread_t * p_input )
p_input->p_plugin->pf_end( p_input ); p_input->p_plugin->pf_end( p_input );
free( p_input->p_plugin ); free( p_input->p_plugin );
/* Destroy Mutex locks */
vlc_mutex_destroy( &p_input->stream.stream_lock );
vlc_mutex_destroy( &p_input->stream.control.control_lock );
/* Free input structure */ /* Free input structure */
free( p_input ); free( p_input );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_dec.c: Functions for the management of decoders * input_dec.c: Functions for the management of decoders
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input_dec.c,v 1.2 2000/12/22 10:58:27 massiot Exp $ * $Id: input_dec.c,v 1.3 2001/01/07 03:56:40 henri Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -57,6 +57,10 @@ void input_EndDecoder( decoder_fifo_t * p_decoder_fifo, vlc_thread_t thread_id ) ...@@ -57,6 +57,10 @@ void input_EndDecoder( decoder_fifo_t * p_decoder_fifo, vlc_thread_t thread_id )
vlc_cond_signal( &p_decoder_fifo->data_wait ); vlc_cond_signal( &p_decoder_fifo->data_wait );
vlc_mutex_unlock( &p_decoder_fifo->data_lock ); vlc_mutex_unlock( &p_decoder_fifo->data_lock );
/* Destroy the lock and cond */
vlc_cond_destroy( &p_decoder_fifo->data_wait );
vlc_mutex_destroy( &p_decoder_fifo->data_lock );
/* Waiting for the thread to exit */ /* Waiting for the thread to exit */
vlc_thread_join( thread_id ); vlc_thread_join( thread_id );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_netlist.c: netlist management * input_netlist.c: netlist management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_netlist.c,v 1.27 2001/01/06 05:44:45 henri Exp $ * $Id: input_netlist.c,v 1.28 2001/01/07 03:56:40 henri Exp $
* *
* Authors: Henri Fallon <henri@videolan.org> * Authors: Henri Fallon <henri@videolan.org>
* *
...@@ -387,6 +387,9 @@ void input_NetlistEnd( input_thread_t * p_input) ...@@ -387,6 +387,9 @@ void input_NetlistEnd( input_thread_t * p_input)
/* cast */ /* cast */
p_netlist = ( netlist_t * ) p_input->p_method_data; p_netlist = ( netlist_t * ) p_input->p_method_data;
/* destroy the mutex lock */
vlc_mutex_destroy (&p_netlist->lock);
/* free the FIFO, the buffer, and the netlist structure */ /* free the FIFO, the buffer, and the netlist structure */
free (p_netlist->pp_free_data); free (p_netlist->pp_free_data);
free (p_netlist->pp_free_pes); free (p_netlist->pp_free_pes);
......
/***************************************************************************** /*****************************************************************************
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
* 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.18 2000/12/28 18:00:38 massiot Exp $ * $Id: input_programs.c,v 1.19 2001/01/07 03:56:40 henri Exp $
* *
* Authors: * Authors:
* *
...@@ -62,7 +61,12 @@ void input_InitStream( input_thread_t * p_input, size_t i_data_len ) ...@@ -62,7 +61,12 @@ void input_InitStream( input_thread_t * p_input, size_t i_data_len )
if( i_data_len ) if( i_data_len )
{ {
p_input->stream.p_demux_data = malloc( i_data_len ); if ( (p_input->stream.p_demux_data = malloc( i_data_len )) == NULL )
{
intf_ErrMsg( "Unable to allocate memory in input_InitStream");
/* FIXME : find a way to tell if failed */
return;
}
memset( p_input->stream.p_demux_data, 0, i_data_len ); memset( p_input->stream.p_demux_data, 0, i_data_len );
} }
} }
...@@ -127,10 +131,20 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input, ...@@ -127,10 +131,20 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input,
p_input->stream.pp_programs = realloc( p_input->stream.pp_programs, p_input->stream.pp_programs = realloc( p_input->stream.pp_programs,
p_input->stream.i_pgrm_number p_input->stream.i_pgrm_number
* sizeof(pgrm_descriptor_t *) ); * sizeof(pgrm_descriptor_t *) );
if( p_input->stream.pp_programs == NULL )
{
intf_ErrMsg( "Unable to realloc memory in input_AddProgram" );
return NULL;
}
/* Allocate the structure to store this description */ /* Allocate the structure to store this description */
p_input->stream.pp_programs[i_pgrm_index] = p_input->stream.pp_programs[i_pgrm_index] =
malloc( sizeof(pgrm_descriptor_t) ); malloc( sizeof(pgrm_descriptor_t) );
if( p_input->stream.pp_programs[i_pgrm_index] == NULL )
{
intf_ErrMsg( "Unable to allocate memory in input_AddProgram" );
return NULL;
}
/* Init this entry */ /* Init this entry */
p_input->stream.pp_programs[i_pgrm_index]->i_number = i_pgrm_id; p_input->stream.pp_programs[i_pgrm_index]->i_number = i_pgrm_id;
...@@ -157,6 +171,11 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input, ...@@ -157,6 +171,11 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input,
{ {
p_input->stream.pp_programs[i_pgrm_index]->p_demux_data = p_input->stream.pp_programs[i_pgrm_index]->p_demux_data =
malloc( i_data_len ); malloc( i_data_len );
if( p_input->stream.pp_programs[i_pgrm_index]->p_demux_data == NULL )
{
intf_ErrMsg( "Unable to allocate memory in input_AddProgram" );
return NULL;
}
memset( p_input->stream.pp_programs[i_pgrm_index]->p_demux_data, 0, memset( p_input->stream.pp_programs[i_pgrm_index]->p_demux_data, 0,
i_data_len ); i_data_len );
} }
...@@ -208,6 +227,10 @@ void input_DelProgram( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm ) ...@@ -208,6 +227,10 @@ void input_DelProgram( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm )
p_input->stream.i_pgrm_number p_input->stream.i_pgrm_number
* sizeof(pgrm_descriptor_t *) ); * sizeof(pgrm_descriptor_t *) );
if( p_input->stream.pp_programs == NULL)
{
intf_ErrMsg( "Unable to realloc memory in input_DelProgram" );
}
/* Free the description of this program */ /* Free the description of this program */
free( p_pgrm ); free( p_pgrm );
} }
...@@ -246,10 +269,20 @@ es_descriptor_t * input_AddES( input_thread_t * p_input, ...@@ -246,10 +269,20 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
intf_DbgMsg("Adding description for ES 0x%x", i_es_id); intf_DbgMsg("Adding description for ES 0x%x", i_es_id);
p_es = (es_descriptor_t *)malloc( sizeof(es_descriptor_t) ); p_es = (es_descriptor_t *)malloc( sizeof(es_descriptor_t) );
if( p_es == NULL )
{
intf_ErrMsg( "Unable to allocate memory in input_AddES" );
return NULL;
}
p_input->stream.i_es_number++; p_input->stream.i_es_number++;
p_input->stream.pp_es = realloc( p_input->stream.pp_es, p_input->stream.pp_es = realloc( p_input->stream.pp_es,
p_input->stream.i_es_number p_input->stream.i_es_number
* sizeof(es_descriptor_t *) ); * sizeof(es_descriptor_t *) );
if( p_input->stream.pp_es == NULL )
{
intf_ErrMsg( "Unable to realloc memory in input_AddES" );
return NULL;
}
p_input->stream.pp_es[p_input->stream.i_es_number - 1] = p_es; p_input->stream.pp_es[p_input->stream.i_es_number - 1] = p_es;
p_es->i_id = i_es_id; p_es->i_id = i_es_id;
...@@ -261,6 +294,11 @@ es_descriptor_t * input_AddES( input_thread_t * p_input, ...@@ -261,6 +294,11 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
if( i_data_len ) if( i_data_len )
{ {
p_es->p_demux_data = malloc( i_data_len ); p_es->p_demux_data = malloc( i_data_len );
if( p_es->p_demux_data == NULL )
{
intf_ErrMsg( "Unable to allocate memory in input_AddES" );
return NULL;
}
memset( p_es->p_demux_data, 0, i_data_len ); memset( p_es->p_demux_data, 0, i_data_len );
} }
else else
...@@ -275,6 +313,11 @@ es_descriptor_t * input_AddES( input_thread_t * p_input, ...@@ -275,6 +313,11 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
p_pgrm->pp_es = realloc( p_pgrm->pp_es, p_pgrm->pp_es = realloc( p_pgrm->pp_es,
p_pgrm->i_es_number p_pgrm->i_es_number
* sizeof(es_descriptor_t *) ); * sizeof(es_descriptor_t *) );
if( p_pgrm->pp_es == NULL )
{
intf_ErrMsg( "Unable to realloc memory in input_AddES" );
return NULL;
}
p_pgrm->pp_es[p_pgrm->i_es_number - 1] = p_es; p_pgrm->pp_es[p_pgrm->i_es_number - 1] = p_es;
p_es->p_pgrm = p_pgrm; p_es->p_pgrm = p_pgrm;
} }
...@@ -317,6 +360,10 @@ void input_DelES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -317,6 +360,10 @@ void input_DelES( input_thread_t * p_input, es_descriptor_t * p_es )
p_pgrm->pp_es = realloc( p_pgrm->pp_es, p_pgrm->pp_es = realloc( p_pgrm->pp_es,
p_pgrm->i_es_number p_pgrm->i_es_number
* sizeof(es_descriptor_t *)); * sizeof(es_descriptor_t *));
if( p_pgrm->pp_es == NULL )
{
intf_ErrMsg( "Unable to realloc memory in input_DelES" );
}
break; break;
} }
} }
...@@ -344,6 +391,11 @@ void input_DelES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -344,6 +391,11 @@ void input_DelES( input_thread_t * p_input, es_descriptor_t * p_es )
p_input->stream.pp_es = realloc( p_input->stream.pp_es, p_input->stream.pp_es = realloc( p_input->stream.pp_es,
p_input->stream.i_es_number p_input->stream.i_es_number
* sizeof(es_descriptor_t *)); * sizeof(es_descriptor_t *));
if( p_input->stream.pp_es == NULL )
{
intf_ErrMsg( "Unable to realloc memory in input_DelES" );
}
} }
#ifdef STATS #ifdef STATS
...@@ -425,7 +477,11 @@ static vdec_config_t * GetVdecConfig( input_thread_t * p_input, ...@@ -425,7 +477,11 @@ static vdec_config_t * GetVdecConfig( input_thread_t * p_input,
{ {
vdec_config_t * p_config; vdec_config_t * p_config;
p_config = (vdec_config_t *)malloc( sizeof(vdec_config_t) ); if( (p_config = (vdec_config_t *)malloc( sizeof(vdec_config_t) )) == NULL)
{
intf_ErrMsg( "Unable to allocate memory in GetVdecConfig" );
return NULL;
}
p_config->p_vout = p_input->p_default_vout; p_config->p_vout = p_input->p_default_vout;
if( InitDecConfig( p_input, p_es, &p_config->decoder_config ) == -1 ) if( InitDecConfig( p_input, p_es, &p_config->decoder_config ) == -1 )
{ {
...@@ -444,7 +500,11 @@ static adec_config_t * GetAdecConfig( input_thread_t * p_input, ...@@ -444,7 +500,11 @@ static adec_config_t * GetAdecConfig( input_thread_t * p_input,
{ {
adec_config_t * p_config; adec_config_t * p_config;
p_config = (adec_config_t *)malloc( sizeof(adec_config_t) ); if ( (p_config = (adec_config_t *)malloc( sizeof(adec_config_t))) ==NULL )
{
intf_ErrMsg( "Unable to allocate memory in GetAdecConfig" );
return NULL;
}
p_config->p_aout = p_input->p_default_aout; p_config->p_aout = p_input->p_default_aout;
if( InitDecConfig( p_input, p_es, &p_config->decoder_config ) == -1 ) if( InitDecConfig( p_input, p_es, &p_config->decoder_config ) == -1 )
{ {
...@@ -532,6 +592,11 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -532,6 +592,11 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
p_input->stream.pp_selected_es, p_input->stream.pp_selected_es,
p_input->stream.i_selected_es_number p_input->stream.i_selected_es_number
* sizeof(es_descriptor_t *) ); * sizeof(es_descriptor_t *) );
if( p_input->stream.pp_selected_es == NULL )
{
intf_ErrMsg( "Unable to realloc memory in input_SelectES" );
return(-1);
}
p_input->stream.pp_selected_es[p_input->stream.i_selected_es_number - 1] p_input->stream.pp_selected_es[p_input->stream.i_selected_es_number - 1]
= p_es; = p_es;
} }
......
...@@ -175,6 +175,9 @@ void intf_MsgDestroy( void ) ...@@ -175,6 +175,9 @@ void intf_MsgDestroy( void )
} }
#endif #endif
/* destroy lock */
vlc_mutex_destroy( &p_main->p_msg->lock );
/* Free structure */ /* Free structure */
free( p_main->p_msg ); free( p_main->p_msg );
} }
......
...@@ -174,6 +174,9 @@ void module_DestroyBank( module_bank_t * p_bank ) ...@@ -174,6 +174,9 @@ void module_DestroyBank( module_bank_t * p_bank )
} }
} }
/* Destory the lock */
vlc_mutex_destroy( &p_bank->lock );
/* We can free the module bank */ /* We can free the module bank */
free( p_bank ); free( p_bank );
......
...@@ -708,6 +708,10 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type, ...@@ -708,6 +708,10 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
intf_DbgMsg("picture %p (in free picture slot)", p_free_picture ); intf_DbgMsg("picture %p (in free picture slot)", p_free_picture );
#endif #endif
vlc_mutex_unlock( &p_vout->picture_lock ); vlc_mutex_unlock( &p_vout->picture_lock );
/* Initialize mutex */
vlc_mutex_init( &(p_free_picture->lock_deccount) );
return( p_free_picture ); return( p_free_picture );
} }
...@@ -744,6 +748,10 @@ void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -744,6 +748,10 @@ void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
#ifdef DEBUG_VOUT #ifdef DEBUG_VOUT
intf_DbgMsg("picture %p", p_pic); intf_DbgMsg("picture %p", p_pic);
#endif #endif
/* destroy the lock that had been initialized in CreatePicture */
vlc_mutex_destroy( &(p_pic->lock_deccount) );
vlc_mutex_unlock( &p_vout->picture_lock ); vlc_mutex_unlock( &p_vout->picture_lock );
} }
...@@ -1311,6 +1319,11 @@ static void DestroyThread( vout_thread_t *p_vout, int i_status ) ...@@ -1311,6 +1319,11 @@ static void DestroyThread( vout_thread_t *p_vout, int i_status )
vout_UnloadFont( p_vout->p_large_font ); vout_UnloadFont( p_vout->p_large_font );
p_vout->p_sys_destroy( p_vout ); p_vout->p_sys_destroy( p_vout );
/* Destroy the locks */
vlc_mutex_destroy( &p_vout->picture_lock );
vlc_mutex_destroy( &p_vout->subpicture_lock );
vlc_mutex_destroy( &p_vout->change_lock );
/* Free structure */ /* Free structure */
free( p_vout ); free( p_vout );
*pi_status = i_status; *pi_status = i_status;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_fifo.c : video FIFO management * video_fifo.c : video FIFO management
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_fifo.c,v 1.25 2001/01/05 18:46:45 massiot Exp $ * $Id: video_fifo.c,v 1.26 2001/01/07 03:56:40 henri Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -62,6 +62,7 @@ void vpar_InitFIFO( vpar_thread_t * p_vpar ) ...@@ -62,6 +62,7 @@ void vpar_InitFIFO( vpar_thread_t * p_vpar )
p_vpar->vfifo.p_vpar = p_vpar; p_vpar->vfifo.p_vpar = p_vpar;
#ifdef VDEC_SMP #ifdef VDEC_SMP
/* Initialize mutex and cond */ /* Initialize mutex and cond */
vlc_mutex_init( &p_vpar->vfifo.lock ); vlc_mutex_init( &p_vpar->vfifo.lock );
vlc_cond_init( &p_vpar->vfifo.wait ); vlc_cond_init( &p_vpar->vfifo.wait );
......
...@@ -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.61 2001/01/05 18:46:45 massiot Exp $ * $Id: video_parser.c,v 1.62 2001/01/07 03:56:40 henri 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>
...@@ -384,6 +384,16 @@ static void EndThread( vpar_thread_t *p_vpar ) ...@@ -384,6 +384,16 @@ static void EndThread( vpar_thread_t *p_vpar )
#endif #endif
free( p_vpar->p_config ); free( p_vpar->p_config );
#ifdef VDEC_SMP
/* Destroy lock and cond */
vlc_mutex_destroy( &(p_vpar->vfifo.lock) );
vlc_mutex_destroy( &(p_vpar->vbuffer.lock) );
vlc_cond_destroy( &(p_vpar->vfifo.wait) );
#endif
vlc_mutex_destroy( &(p_vpar->synchro.fifo_lock) );
free( p_vpar ); free( p_vpar );
intf_DbgMsg("vpar debug: EndThread(%p)", p_vpar); intf_DbgMsg("vpar debug: EndThread(%p)", p_vpar);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vpar_headers.c : headers parsing * vpar_headers.c : headers parsing
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: vpar_headers.c,v 1.66 2001/01/05 18:46:45 massiot Exp $ * $Id: vpar_headers.c,v 1.67 2001/01/07 03:56:40 henri Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -698,7 +698,6 @@ static void PictureHeader( vpar_thread_t * p_vpar ) ...@@ -698,7 +698,6 @@ static void PictureHeader( vpar_thread_t * p_vpar )
<< ( 1 - p_vpar->picture.b_frame_structure )); << ( 1 - p_vpar->picture.b_frame_structure ));
P_picture->i_deccount = p_vpar->sequence.i_mb_size; P_picture->i_deccount = p_vpar->sequence.i_mb_size;
vlc_mutex_init( &p_vpar->picture.p_picture->lock_deccount );
#ifdef VDEC_SMP #ifdef VDEC_SMP
memset( p_vpar->picture.pp_mb, 0, MAX_MB*sizeof(macroblock_t *) ); memset( p_vpar->picture.pp_mb, 0, MAX_MB*sizeof(macroblock_t *) );
#endif #endif
......
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