* 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;
thread_id thread;
} 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
typedef void *(*vlc_thread_func_t)(void *p_data);
static __inline__ void vlc_thread_exit ( void );
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_lock ( vlc_mutex_t *p_mutex );
-static __inline__ int vlc_mutex_unlock ( 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_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_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_destroy ( vlc_cond_t *p_condvar );
#if 0
static _inline__ int vlc_cond_timedwait ( vlc_cond_t * condvar, vlc_mutex_t * mutex,
*****************************************************************************/
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;
cthread_exit( &result );
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H)
exit_thread( 0 );
-#elif defined(HAVE_PTHREAD_H)
- pthread_exit( 0 );
-
#endif
}
*****************************************************************************/
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 );
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H)
int32 exit_value;
wait_for_thread( thread, &exit_value );
-#elif defined(HAVE_PTHREAD_H)
- pthread_join( thread, NULL );
-
#endif
}
*****************************************************************************/
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 );
return 0;
p_mutex->init = 9999;
return B_OK;
-#elif defined(HAVE_PTHREAD_H)
- return pthread_mutex_init( p_mutex, NULL );
-
#endif
}
*****************************************************************************/
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 );
return 0;
err = acquire_sem( p_mutex->lock );
return err;
-#elif defined(HAVE_PTHREAD_H)
- return pthread_mutex_lock( p_mutex );
-
#endif
}
*****************************************************************************/
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 );
return 0;
release_sem( p_mutex->lock );
return B_OK;
-#elif defined(HAVE_PTHREAD_H)
- return pthread_mutex_unlock( p_mutex );
-
#endif
}
+/*****************************************************************************
+ * 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
+}
+
/*****************************************************************************
* vlc_cond_init: initialize a condition
*****************************************************************************/
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() */
spin_lock_init( &p_condvar->lock );
cthread_queue_init( &p_condvar->queue );
p_condvar->init = 9999;
return 0;
-#elif defined(HAVE_PTHREAD_H)
- return pthread_cond_init( p_condvar, NULL );
-
#endif
}
*****************************************************************************/
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() */
if ( p_condvar->queue.head || p_condvar->implications )
{
return 0;
-#elif defined(HAVE_PTHREAD_H)
- return pthread_cond_signal( p_condvar );
-
#endif
}
*****************************************************************************/
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 );
return 0;
vlc_mutex_lock( p_mutex );
return 0;
-#elif defined(HAVE_PTHREAD_H)
- return pthread_cond_wait( p_condvar, p_mutex );
-
#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
+}
*****************************************************************************/
plugin_info_t * GetConfig( void )
{
- int i_fd;
plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
p_info->psz_name = "Alsa plugin";
return ( 1 );
}
- switch (alsa_channel_status.status)
+ switch( alsa_channel_status.status )
{
case SND_PCM_STATUS_NOTREADY : intf_ErrMsg("Status NOT READY");
break;
*****************************************************************************/
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!?? */
intf_DbgMsg("aout debug: requesting termination of audio output thread (%p)", p_aout);
free( p_aout->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 */
p_aout->p_sys_close( p_aout );
intf_DbgMsg("aout debug: audio device (%s) closed", p_aout->psz_device);
* decoders.
*****************************************************************************
* 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:
*
p_input->p_plugin->pf_end( p_input );
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( p_input );
* input_dec.c: Functions for the management of decoders
*****************************************************************************
* 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>
*
vlc_cond_signal( &p_decoder_fifo->data_wait );
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 */
vlc_thread_join( thread_id );
* input_netlist.c: netlist management
*****************************************************************************
* 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>
*
/* cast */
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 (p_netlist->pp_free_data);
free (p_netlist->pp_free_pes);
/*****************************************************************************
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management
- * FIXME : check the return value of realloc() and malloc() !
*****************************************************************************
* 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:
*
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 );
}
}
p_input->stream.pp_programs = realloc( p_input->stream.pp_programs,
p_input->stream.i_pgrm_number
* 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 */
p_input->stream.pp_programs[i_pgrm_index] =
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 */
p_input->stream.pp_programs[i_pgrm_index]->i_number = i_pgrm_id;
p_input->stream.pp_programs[i_pgrm_index]->b_is_ok = 0;
{
p_input->stream.pp_programs[i_pgrm_index]->p_demux_data =
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,
i_data_len );
}
p_input->stream.i_pgrm_number
* 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( p_pgrm );
}
intf_DbgMsg("Adding description for ES 0x%x", i_es_id);
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.pp_es = realloc( p_input->stream.pp_es,
p_input->stream.i_es_number
* 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_es->i_id = i_es_id;
if( 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 );
}
else
p_pgrm->pp_es = realloc( p_pgrm->pp_es,
p_pgrm->i_es_number
* 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_es->p_pgrm = p_pgrm;
}
p_pgrm->pp_es = realloc( p_pgrm->pp_es,
p_pgrm->i_es_number
* sizeof(es_descriptor_t *));
+ if( p_pgrm->pp_es == NULL )
+ {
+ intf_ErrMsg( "Unable to realloc memory in input_DelES" );
+ }
break;
}
}
p_input->stream.pp_es = realloc( p_input->stream.pp_es,
p_input->stream.i_es_number
* sizeof(es_descriptor_t *));
+ if( p_input->stream.pp_es == NULL )
+ {
+ intf_ErrMsg( "Unable to realloc memory in input_DelES" );
+ }
+
}
#ifdef STATS
{
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;
if( InitDecConfig( p_input, p_es, &p_config->decoder_config ) == -1 )
{
{
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;
if( InitDecConfig( p_input, p_es, &p_config->decoder_config ) == -1 )
{
p_input->stream.pp_selected_es,
p_input->stream.i_selected_es_number
* 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_es;
}
}
#endif
+ /* destroy lock */
+ vlc_mutex_destroy( &p_main->p_msg->lock );
+
/* Free structure */
free( p_main->p_msg );
}
}
}
+ /* Destory the lock */
+ vlc_mutex_destroy( &p_bank->lock );
+
/* We can free the module bank */
free( p_bank );
intf_DbgMsg("picture %p (in free picture slot)", p_free_picture );
#endif
vlc_mutex_unlock( &p_vout->picture_lock );
+
+ /* Initialize mutex */
+ vlc_mutex_init( &(p_free_picture->lock_deccount) );
+
return( p_free_picture );
}
#ifdef DEBUG_VOUT
intf_DbgMsg("picture %p", p_pic);
#endif
+
+ /* destroy the lock that had been initialized in CreatePicture */
+ vlc_mutex_destroy( &(p_pic->lock_deccount) );
+
vlc_mutex_unlock( &p_vout->picture_lock );
}
vout_UnloadFont( p_vout->p_large_font );
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( p_vout );
*pi_status = i_status;
* video_fifo.c : video FIFO management
*****************************************************************************
* 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>
*
p_vpar->vfifo.p_vpar = p_vpar;
#ifdef VDEC_SMP
+
/* Initialize mutex and cond */
vlc_mutex_init( &p_vpar->vfifo.lock );
vlc_cond_init( &p_vpar->vfifo.wait );
* video_parser.c : video parser thread
*****************************************************************************
* 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>
* Samuel Hocevar <sam@via.ecp.fr>
#endif
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 );
intf_DbgMsg("vpar debug: EndThread(%p)", p_vpar);
* vpar_headers.c : headers parsing
*****************************************************************************
* 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>
* Stéphane Borel <stef@via.ecp.fr>
<< ( 1 - p_vpar->picture.b_frame_structure ));
P_picture->i_deccount = p_vpar->sequence.i_mb_size;
- vlc_mutex_init( &p_vpar->picture.p_picture->lock_deccount );
#ifdef VDEC_SMP
memset( p_vpar->picture.pp_mb, 0, MAX_MB*sizeof(macroblock_t *) );
#endif