]> git.sesse.net Git - vlc/commitdiff
- Added vlc_mutex_destroy and vlc_cond_destroy function, for pthreads.
authorHenri Fallon <henri@videolan.org>
Sun, 7 Jan 2001 03:56:40 +0000 (03:56 +0000)
committerHenri Fallon <henri@videolan.org>
Sun, 7 Jan 2001 03:56:40 +0000 (03:56 +0000)
- 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

14 files changed:
include/threads.h
plugins/alsa/alsa.c
plugins/alsa/aout_alsa.c
src/audio_output/audio_output.c
src/input/input.c
src/input/input_dec.c
src/input/input_netlist.c
src/input/input_programs.c
src/interface/intf_msg.c
src/misc/modules.c
src/video_output/video_output.c
src/video_parser/video_fifo.c
src/video_parser/video_parser.c
src/video_parser/vpar_headers.c

index cd7c0d23af1d6e10c5755d9c269d5d1fbf8d1e01..7d195508dc6f477355f0b6d85bcf2e6b4387cb42 100644 (file)
  * 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;
 
@@ -111,12 +117,6 @@ typedef struct
     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);
@@ -130,13 +130,15 @@ static __inline__ int  vlc_thread_create( vlc_thread_t *p_thread, char *psz_name
 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,
@@ -170,16 +172,16 @@ static __inline__ int vlc_thread_create( vlc_thread_t *p_thread,
  *****************************************************************************/
 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
 }
 
@@ -188,16 +190,16 @@ static __inline__ void vlc_thread_exit( void )
  *****************************************************************************/
 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
 }
 
@@ -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 )
 {
-#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;
 
@@ -225,9 +230,6 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
     p_mutex->init = 9999;
     return B_OK;
 
-#elif defined(HAVE_PTHREAD_H)
-    return pthread_mutex_init( p_mutex, NULL );
-
 #endif
 }
 
@@ -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 )
 {
-#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;
 
@@ -249,9 +254,6 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
     err = acquire_sem( p_mutex->lock );
     return err;
 
-#elif defined(HAVE_PTHREAD_H)
-    return pthread_mutex_lock( p_mutex );
-
 #endif
 }
 
@@ -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 )
 {
-#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;
 
@@ -272,18 +277,28 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
     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 );
@@ -303,9 +318,6 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar )
     p_condvar->init = 9999;
     return 0;
 
-#elif defined(HAVE_PTHREAD_H)
-    return pthread_cond_init( p_condvar, NULL );
-
 #endif
 }
 
@@ -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 )
 {
-#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 )
     {
@@ -351,9 +366,6 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar )
     
     return 0;
 
-#elif defined(HAVE_PTHREAD_H)
-    return pthread_cond_signal( p_condvar );
-
 #endif
 }
 
@@ -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 )
 {
-#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;
 
@@ -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 );
     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    
+}
index 91652a2daf6a407eb5a8fde574f120a52d0442f3..0ddf1c5c86a62addeaedc7b54dc0d09a08d727de 100644 (file)
@@ -66,7 +66,6 @@ void    aout_AlsaClose        ( aout_thread_t *p_aout );
  *****************************************************************************/
 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";
index d9c813548dfdfaf4758ce025063228019e99c4f8..7436e49189badcc7e83c76d61ecbd92b5e432645 100644 (file)
@@ -259,7 +259,7 @@ long aout_AlsaGetBufInfo ( aout_thread_t *p_aout, long l_buffer_limit )
         return ( 1 );
     }
 
-    switch (alsa_channel_status.status)
+    switch( alsa_channel_status.status )
     {
         case SND_PCM_STATUS_NOTREADY : intf_ErrMsg("Status NOT READY");
                                        break;
index f637bb315265c6c31b0c4965ebff8cec5c4ec517..473857bc5199a949da2cfcdd54551f454bc83f66 100644 (file)
@@ -339,6 +339,9 @@ static int aout_SpawnThread( aout_thread_t * p_aout )
  *****************************************************************************/
 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);
@@ -351,6 +354,14 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
     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);
index a046ed360fa12918d4392a81d562f59fa316ef74..1edfcd777dbefe3df005bd76fd71adccee7a4628 100644 (file)
@@ -4,7 +4,7 @@
  * 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: 
  *
@@ -318,6 +318,10 @@ static void EndThread( input_thread_t * p_input )
     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 );
 
index 3bfd489929f8c53dd7526114364806983dfc27e1..e829cb526f98318107e598642d3ba034ad2c9b03 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
  *
@@ -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_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 );
 
index 46e7659fdfda4a7f3ef9460c04780a2b96855f41..fc8dc0d09d476968023891e4012f94eed4b72931 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
  *
@@ -387,6 +387,9 @@ void input_NetlistEnd( input_thread_t * p_input)
     /* 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);
index 3f54c81567187b6ef746cfce352295036c5513d9..5cd3b4a4b2bbe28b569193f81e6f8c14f57baab4 100644 (file)
@@ -1,9 +1,8 @@
 /*****************************************************************************
  * 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:
  *
@@ -62,7 +61,12 @@ void input_InitStream( input_thread_t * p_input, size_t 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 );
     }
 }
@@ -127,11 +131,21 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input,
     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;
@@ -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 =
             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 );
     }
@@ -208,6 +227,10 @@ void input_DelProgram( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm )
                                            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 );
 }
@@ -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);
 
     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;
 
@@ -261,6 +294,11 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
     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
@@ -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->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;
     }
@@ -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->i_es_number
                                           * sizeof(es_descriptor_t *));
+                if( p_pgrm->pp_es == NULL )
+                {
+                    intf_ErrMsg( "Unable to realloc memory in input_DelES" );
+                }
                 break;
             }
         }
@@ -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.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
@@ -425,7 +477,11 @@ static vdec_config_t * GetVdecConfig( input_thread_t * p_input,
 {
     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 )
     {
@@ -444,7 +500,11 @@ static adec_config_t * GetAdecConfig( input_thread_t * p_input,
 {
     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 )
     {
@@ -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.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;
     }
index dcb5b92ea29a917bfba461f6f8e36e8e6fc8a726..b6b0e449c93c911a83ff356b48a9a1ca8d8b7aa7 100644 (file)
@@ -175,6 +175,9 @@ void intf_MsgDestroy( void )
     }
 #endif
 
+    /* destroy lock */
+    vlc_mutex_destroy( &p_main->p_msg->lock );
+    
     /* Free structure */
     free( p_main->p_msg );
 }
index 334e3a0cf9814349fa8381e92aa00ab6993e26b3..ee771fe6af73a864f43881a8a2e63a20e7c364a2 100644 (file)
@@ -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 */
     free( p_bank );
 
index ae0b331c1f51e8cbf410382428d6a5edc6f797b9..46d985e00a0f2da36490e805ede7d61de855d85c 100644 (file)
@@ -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 );
 #endif
         vlc_mutex_unlock( &p_vout->picture_lock );
+
+        /* Initialize mutex */
+        vlc_mutex_init( &(p_free_picture->lock_deccount) );
+        
         return( p_free_picture );
     }
 
@@ -744,6 +748,10 @@ void vout_DestroyPicture( vout_thread_t *p_vout, picture_t *p_pic )
 #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 );
 }
 
@@ -1311,6 +1319,11 @@ static void DestroyThread( vout_thread_t *p_vout, int i_status )
     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;
index edf84d83bcbbf74ef05ca799b24b2ed11d0149e1..779e05ac1b05e67122aa1612f83b257e8e85ddb5 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
  *
@@ -62,6 +62,7 @@ void vpar_InitFIFO( vpar_thread_t * p_vpar )
     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 );
index 25f1f134f58d4361668be6e1031f79c11c59b621..1d2212f7159c0dda81ca0a10c9b1867cce32b3ff 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -384,6 +384,16 @@ static void EndThread( vpar_thread_t *p_vpar )
 #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);
index 3555e4a8b1058199a0c729a193baf20f56bfb87a..4c2d165835169b8ce0ec4e72a109e2c50447ec8e 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -698,7 +698,6 @@ static void PictureHeader( vpar_thread_t * p_vpar )
                     << ( 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