]> git.sesse.net Git - vlc/commitdiff
* Backported the DecoderError() patch.
authorSam Hocevar <sam@videolan.org>
Sun, 30 Dec 2001 06:06:00 +0000 (06:06 +0000)
committerSam Hocevar <sam@videolan.org>
Sun, 30 Dec 2001 06:06:00 +0000 (06:06 +0000)
12 files changed:
include/common.h
include/input_ext-dec.h
include/modules_export.h
plugins/ac3_adec/ac3_adec.c
plugins/ac3_spdif/ac3_spdif.c
plugins/lpcm_adec/lpcm_adec.c
plugins/mad_adec/mad_adec.c
plugins/mpeg_adec/mpeg_adec.c
plugins/mpeg_adec/mpeg_adec.h
plugins/mpeg_vdec/video_parser.c
plugins/spu_dec/spu_decoder.c
src/input/input_ext-dec.c

index 5a730aa8c701d517a7999c8991bd1f3d1e0e4c62..d6087dfbecc59267fe656b2cb03907de9822df15 100644 (file)
@@ -3,7 +3,7 @@
  * Collection of useful common types and macros definitions
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: common.h,v 1.53 2001/12/07 18:33:07 sam Exp $
+ * $Id: common.h,v 1.53.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@via.ecp.fr>
  *          Vincent Seguin <seguin@via.ecp.fr>
@@ -320,6 +320,7 @@ typedef struct module_symbols_s
                                       void ( * ) ( struct bit_stream_s *,
                                                    boolean_t ),
                                       void * );
+    void ( * DecoderError )         ( struct decoder_fifo_s * p_fifo );
     int  ( * input_InitStream )     ( struct input_thread_s *, size_t );
     void ( * input_EndStream )      ( struct input_thread_s * );
 
index d5283416ce40637cec9a17bb5f783bba3486381e..b3fdc0f03001306589463657a9227ebe29451a29 100644 (file)
@@ -2,7 +2,7 @@
  * input_ext-dec.h: structures exported to the VideoLAN decoders
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-dec.h,v 1.41 2001/12/07 18:33:07 sam Exp $
+ * $Id: input_ext-dec.h,v 1.41.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Michel Kaempf <maxx@via.ecp.fr>
@@ -212,7 +212,7 @@ typedef struct bit_stream_s
 #endif
 
 /*****************************************************************************
- * Protoypes from input_ext-dec.c
+ * Prototypes from input_ext-dec.c
  *****************************************************************************/
 #ifndef PLUGIN
 u32  UnalignedShowBits( struct bit_stream_s *, unsigned int );
@@ -532,3 +532,12 @@ typedef struct decoder_config_s
                                                  void * );
 } decoder_config_t;
 
+/*****************************************************************************
+ * Prototypes from input_dec.c
+ *****************************************************************************/
+#ifndef PLUGIN
+void DecoderError      ( struct decoder_fifo_s * p_fifo );
+#else
+#   define DecoderError p_symbols->DecoderError
+#endif
+
index 4317a3215f1dc1d211f64d7498f1ce1002f4a175..499fb5dcbc73132f7f8e779018f5d14f4283ba74 100644 (file)
@@ -66,6 +66,7 @@
     (p_symbols)->input_AddArea = input_AddArea; \
     (p_symbols)->input_DelArea = input_DelArea; \
     (p_symbols)->InitBitstream = InitBitstream; \
+    (p_symbols)->DecoderError = DecoderError; \
     (p_symbols)->input_InitStream = input_InitStream; \
     (p_symbols)->input_EndStream = input_EndStream; \
     (p_symbols)->input_ParsePES = input_ParsePES; \
 #   define input_DelArea p_symbols->input_DelArea
 
 #   define InitBitstream p_symbols->InitBitstream
+#   define DecoderError p_symbols->DecoderError
 #   define input_InitStream p_symbols->input_InitStream
 #   define input_EndStream p_symbols->input_EndStream
 
index 0633e762328e8d9ea13bdb5e45476d4cf8417122..b13058d8fe7910ffd9677e963280f418badc4910 100644 (file)
@@ -2,7 +2,7 @@
  * ac3_adec.c: ac3 decoder module main file
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: ac3_adec.c,v 1.5 2001/12/03 16:18:37 sam Exp $
+ * $Id: ac3_adec.c,v 1.5.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Michel Lespinasse <walken@zoy.org>
  *
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int      ac3_adec_Probe      ( probedata_t * );
-static int      ac3_adec_Run         ( decoder_config_t * );
-static int      ac3_adec_Init        (ac3dec_thread_t * p_adec);
-static void     ac3_adec_ErrorThread (ac3dec_thread_t * p_adec);
-static void     ac3_adec_EndThread   (ac3dec_thread_t * p_adec);
-static void     BitstreamCallback    ( bit_stream_t *p_bit_stream,
-                                              boolean_t b_new_pes );
+static int  decoder_Probe     ( probedata_t * );
+static int  decoder_Run       ( decoder_config_t * );
+static int  InitThread        ( ac3dec_thread_t * p_adec );
+static void EndThread         ( ac3dec_thread_t * p_adec );
+static void BitstreamCallback ( bit_stream_t *p_bit_stream,
+                                boolean_t b_new_pes );
 
 /*****************************************************************************
  * Capabilities
  *****************************************************************************/
 void _M( adec_getfunctions )( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = ac3_adec_Probe;
-    p_function_list->functions.dec.pf_run = ac3_adec_Run;
+    p_function_list->pf_probe = decoder_Probe;
+    p_function_list->functions.dec.pf_run = decoder_Run;
 }
 
 /*****************************************************************************
@@ -100,20 +99,20 @@ MODULE_DEACTIVATE_STOP
 
 
 /*****************************************************************************
- * ac3_adec_Probe: probe the decoder and return score
+ * decoder_Probe: probe the decoder and return score
  *****************************************************************************
  * Tries to launch a decoder and return score so that the interface is able 
  * to chose.
  *****************************************************************************/
-static int ac3_adec_Probe( probedata_t *p_data )
+static int decoder_Probe( probedata_t *p_data )
 {
     return ( p_data->i_type == AC3_AUDIO_ES ) ? 50 : 0;
 }
 
 /*****************************************************************************
- * ac3_adec_Run: this function is called just after the thread is created
+ * decoder_Run: this function is called just after the thread is created
  *****************************************************************************/
-static int ac3_adec_Run ( decoder_config_t * p_config )
+static int decoder_Run ( decoder_config_t * p_config )
 {
     ac3dec_thread_t *   p_ac3thread;
     int sync;
@@ -126,7 +125,8 @@ static int ac3_adec_Run ( decoder_config_t * p_config )
     if( p_ac3thread == NULL )
     {
         intf_ErrMsg ( "ac3_adec error: not enough memory "
-                      "for ac3_adec_Run() to allocate p_ac3thread" );
+                      "for decoder_Run() to allocate p_ac3thread" );
+        DecoderError( p_config->p_decoder_fifo );
         return( -1 );
     }
    
@@ -134,9 +134,10 @@ static int ac3_adec_Run ( decoder_config_t * p_config )
      * Initialize the thread properties
      */
     p_ac3thread->p_config = p_config;
-    if( ac3_adec_Init( p_ac3thread ) )
+    if( InitThread( p_ac3thread ) )
     {
         intf_ErrMsg( "ac3_adec error: could not initialize thread" );
+        DecoderError( p_config->p_decoder_fifo );
         free( p_ac3thread );
         return( -1 );
     }
@@ -212,11 +213,11 @@ static int ac3_adec_Run ( decoder_config_t * p_config )
     /* If b_error is set, the ac3 decoder thread enters the error loop */
     if (p_ac3thread->p_fifo->b_error)
     {
-        ac3_adec_ErrorThread (p_ac3thread);
+        DecoderError( p_ac3thread->p_fifo );
     }
 
     /* End of the ac3 decoder thread */
-    ac3_adec_EndThread (p_ac3thread);
+    EndThread (p_ac3thread);
 
     free( p_ac3thread );
 
@@ -225,9 +226,9 @@ static int ac3_adec_Run ( decoder_config_t * p_config )
 
 
 /*****************************************************************************
- * ac3_adec_Init: initialize data before entering main loop
+ * InitThread: initialize data before entering main loop
  *****************************************************************************/
-static int ac3_adec_Init( ac3dec_thread_t * p_ac3thread )
+static int InitThread( ac3dec_thread_t * p_ac3thread )
 {
     /*
      * Thread properties 
@@ -371,41 +372,10 @@ static int ac3_adec_Init( ac3dec_thread_t * p_ac3thread )
     return( 0 );
 }
 
-
-/*****************************************************************************
- * ac3_adec_ErrorThread : ac3 decoder's RunThread() error loop
- *****************************************************************************/
-static void ac3_adec_ErrorThread (ac3dec_thread_t * p_ac3thread)
-{
-    /* We take the lock, because we are going to read/write the start/end
-     * indexes of the decoder fifo */
-    vlc_mutex_lock (&p_ac3thread->p_fifo->data_lock);
-
-    /* Wait until a `die' order is sent */
-    while (!p_ac3thread->p_fifo->b_die)
-    {
-        /* Trash all received PES packets */
-        while (!DECODER_FIFO_ISEMPTY(*p_ac3thread->p_fifo))
-        {
-            p_ac3thread->p_fifo->pf_delete_pes(
-                    p_ac3thread->p_fifo->p_packets_mgt,
-                    DECODER_FIFO_START(*p_ac3thread->p_fifo));
-            DECODER_FIFO_INCSTART (*p_ac3thread->p_fifo);
-        }
-
-        /* Waiting for the input thread to put new PES packets in the fifo */
-        vlc_cond_wait (&p_ac3thread->p_fifo->data_wait,
-                       &p_ac3thread->p_fifo->data_lock);
-    }
-
-    /* We can release the lock before leaving */
-    vlc_mutex_unlock (&p_ac3thread->p_fifo->data_lock);
-}
-
 /*****************************************************************************
- * ac3_adec_EndThread : ac3 decoder thread destruction
+ * EndThread : ac3 decoder thread destruction
  *****************************************************************************/
-static void ac3_adec_EndThread (ac3dec_thread_t * p_ac3thread)
+static void EndThread (ac3dec_thread_t * p_ac3thread)
 {
     intf_DbgMsg ("ac3dec debug: destroying ac3 decoder thread %p", p_ac3thread);
 
index b6e98bead4907ac516a75b26449e08dbb2621220..d125a06156bcbf5742e47849ab808a1f3bafcd65 100644 (file)
@@ -2,7 +2,7 @@
  * ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: ac3_spdif.c,v 1.5 2001/12/03 16:18:37 sam Exp $
+ * $Id: ac3_spdif.c,v 1.5.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *          Juha Yrjola <jyrjola@cc.hut.fi>
 /****************************************************************************
  * Local Prototypes
  ****************************************************************************/
-static int  ac3_spdif_Probe       ( probedata_t * );
-static int  ac3_spdif_Run         ( decoder_config_t * );
-static int  ac3_spdif_Init        ( ac3_spdif_thread_t * );
-static void ac3_spdif_ErrorThread ( ac3_spdif_thread_t * );
-static void ac3_spdif_EndThread   ( ac3_spdif_thread_t * );
-static void BitstreamCallback( bit_stream_t *, boolean_t );
+static int  decoder_Probe     ( probedata_t * );
+static int  decoder_Run       ( decoder_config_t * );
+static int  InitThread        ( ac3_spdif_thread_t * );
+static void EndThread         ( ac3_spdif_thread_t * );
+static void BitstreamCallback ( bit_stream_t *, boolean_t );
 
 /*****************************************************************************
  * Capabilities
  *****************************************************************************/
 void _M( adec_getfunctions )( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = ac3_spdif_Probe;
-    p_function_list->functions.dec.pf_run = ac3_spdif_Run;
+    p_function_list->pf_probe = decoder_Probe;
+    p_function_list->functions.dec.pf_run = decoder_Run;
 }
 
 /*****************************************************************************
@@ -99,12 +98,12 @@ MODULE_DEACTIVATE_START
 MODULE_DEACTIVATE_STOP
 
 /*****************************************************************************
- * ac3_spdif_Probe: probe the decoder and return score
+ * decoder_Probe: probe the decoder and return score
  *****************************************************************************
  * Tries to launch a decoder and return score so that the interface is able 
  * to chose.
  *****************************************************************************/
-static int ac3_spdif_Probe( probedata_t *p_data )
+static int decoder_Probe( probedata_t *p_data )
 {
     if( main_GetIntVariable( AOUT_SPDIF_VAR, 0 ) && 
         p_data->i_type == AC3_AUDIO_ES )
@@ -115,11 +114,11 @@ static int ac3_spdif_Probe( probedata_t *p_data )
 
 
 /****************************************************************************
- * ac3_spdif_Run: the whole thing
+ * decoder_Run: the whole thing
  ****************************************************************************
  * This function is called just after the thread is launched.
  ****************************************************************************/
-static int ac3_spdif_Run( decoder_config_t * p_config )
+static int decoder_Run( decoder_config_t * p_config )
 {
     ac3_spdif_thread_t *   p_spdif;
     mtime_t     i_frame_time;
@@ -136,14 +135,17 @@ static int ac3_spdif_Run( decoder_config_t * p_config )
     {
         intf_ErrMsg ( "spdif error: not enough memory "
                       "for spdif_CreateThread() to create the new thread");
+        DecoderError( p_config->p_decoder_fifo );
         return( -1 );
     }
   
     p_spdif->p_config = p_config; 
     
-    if (ac3_spdif_Init( p_spdif ) )
+    if (InitThread( p_spdif ) )
     {
         intf_ErrMsg( "spdif error: could not initialize thread" );
+        DecoderError( p_config->p_decoder_fifo );
+        free( p_spdif );
         return( -1 );
     }
 
@@ -214,19 +216,19 @@ static int ac3_spdif_Run( decoder_config_t * p_config )
     /* If b_error is set, the ac3 spdif thread enters the error loop */
     if( p_spdif->p_fifo->b_error )
     {
-        ac3_spdif_ErrorThread( p_spdif );
+        DecoderError( p_spdif->p_fifo );
     }
 
     /* End of the ac3 decoder thread */
-    ac3_spdif_EndThread( p_spdif );
+    EndThread( p_spdif );
     
     return( 0 );
 }
 
 /****************************************************************************
- * ac3_spdif_Init: initialize thread data and create output fifo
+ * InitThread: initialize thread data and create output fifo
  ****************************************************************************/
-static int ac3_spdif_Init( ac3_spdif_thread_t * p_spdif )
+static int InitThread( ac3_spdif_thread_t * p_spdif )
 {
     boolean_t b_sync = 0;
 
@@ -302,40 +304,10 @@ static int ac3_spdif_Init( ac3_spdif_thread_t * p_spdif )
     return( 0 );
 }
 
-
-/*****************************************************************************
- * ac3_spdif_ErrorThread : ac3 spdif's RunThread() error loop
- *****************************************************************************/
-static void ac3_spdif_ErrorThread( ac3_spdif_thread_t * p_spdif )
-{
-    /* We take the lock, because we are going to read/write the start/end
-     * indexes of the decoder fifo */
-    vlc_mutex_lock (&p_spdif->p_fifo->data_lock);
-
-    /* Wait until a `die' order is sent */
-    while( !p_spdif->p_fifo->b_die )
-    {
-        /* Trash all received PES packets */
-        while( !DECODER_FIFO_ISEMPTY( *p_spdif->p_fifo ) )
-        {
-            p_spdif->p_fifo->pf_delete_pes(p_spdif->p_fifo->p_packets_mgt,
-                    DECODER_FIFO_START( *p_spdif->p_fifo ) );
-            DECODER_FIFO_INCSTART( *p_spdif->p_fifo );
-        }
-
-        /* Waiting for the input thread to put new PES packets in the fifo */
-        vlc_cond_wait( &p_spdif->p_fifo->data_wait,
-                       &p_spdif->p_fifo->data_lock );
-    }
-
-    /* We can release the lock before leaving */
-    vlc_mutex_unlock( &p_spdif->p_fifo->data_lock );
-}
-
 /*****************************************************************************
- * ac3_spdif_EndThread : ac3 spdif thread destruction
+ * EndThread : ac3 spdif thread destruction
  *****************************************************************************/
-static void ac3_spdif_EndThread( ac3_spdif_thread_t * p_spdif )
+static void EndThread( ac3_spdif_thread_t * p_spdif )
 {
     intf_DbgMsg( "spdif debug: destroying thread %p", p_spdif );
 
index 4fb641b091496e3e2d01af7a086549badd32e114..e31041ae5700821548af7b15b450ffcde6214ed2 100644 (file)
@@ -2,7 +2,7 @@
  * lpcm_decoder_thread.c: lpcm decoder thread
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: lpcm_adec.c,v 1.3 2001/12/03 16:18:37 sam Exp $
+ * $Id: lpcm_adec.c,v 1.3.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Henri Fallon <henri@videolan.org>
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int      lpcm_adec_Probe         ( probedata_t * );
-static int      lpcm_adec_Run           ( decoder_config_t * );
-void            lpcm_adec_DecodeFrame   ( lpcmdec_thread_t * );
-static int      lpcm_adec_Init          ( lpcmdec_thread_t * );
-static void     lpcm_adec_ErrorThread   ( lpcmdec_thread_t * );
-static void     lpcm_adec_EndThread     ( lpcmdec_thread_t * );
+static int  decoder_Probe  ( probedata_t * );
+static int  decoder_Run    ( decoder_config_t * );
+       void DecodeFrame    ( lpcmdec_thread_t * );
+static int  InitThread     ( lpcmdec_thread_t * );
+static void EndThread      ( lpcmdec_thread_t * );
 
 
 /*****************************************************************************
@@ -70,8 +69,8 @@ static void     lpcm_adec_EndThread     ( lpcmdec_thread_t * );
  *****************************************************************************/
 void _M( adec_getfunctions )( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = lpcm_adec_Probe;
-    p_function_list->functions.dec.pf_run = lpcm_adec_Run;
+    p_function_list->pf_probe = decoder_Probe;
+    p_function_list->functions.dec.pf_run = decoder_Run;
 }
 
 /*****************************************************************************
@@ -95,9 +94,9 @@ MODULE_DEACTIVATE_START
 MODULE_DEACTIVATE_STOP
 
 /*****************************************************************************
- * lpcm_adec_Probe: probe the decoder and return score
+ * decoder_Probe: probe the decoder and return score
  *****************************************************************************/
-static int lpcm_adec_Probe( probedata_t *p_data )
+static int decoder_Probe( probedata_t *p_data )
 {
     if( p_data->i_type == LPCM_AUDIO_ES )
         return( 100 );
@@ -106,9 +105,9 @@ static int lpcm_adec_Probe( probedata_t *p_data )
 }
 
 /*****************************************************************************
- * lpcm_adec_Run: the lpcm decoder
+ * decoder_Run: the lpcm decoder
  *****************************************************************************/
-static int lpcm_adec_Run( decoder_config_t * p_config )
+static int decoder_Run( decoder_config_t * p_config )
 {
     lpcmdec_thread_t *   p_lpcmdec;
 
@@ -119,6 +118,7 @@ static int lpcm_adec_Run( decoder_config_t * p_config )
             == NULL) 
     {
         intf_ErrMsg( "LPCM : error : cannot create lpcmdec_thread_t" );
+        DecoderError( p_config->p_decoder_fifo );
         return( -1 );
     }
 
@@ -128,8 +128,10 @@ static int lpcm_adec_Run( decoder_config_t * p_config )
     p_lpcmdec->p_config = p_config;
     p_lpcmdec->p_fifo = p_config->p_decoder_fifo;
 
-    if( lpcm_adec_Init( p_lpcmdec ) )
+    if( InitThread( p_lpcmdec ) )
     {
+        DecoderError( p_config->p_decoder_fifo );
+        free( p_lpcmdec );
         return( -1 );
     }
 
@@ -139,25 +141,25 @@ static int lpcm_adec_Run( decoder_config_t * p_config )
     /* lpcm decoder thread's main loop */
     while ((!p_lpcmdec->p_fifo->b_die) && (!p_lpcmdec->p_fifo->b_error))
     {
-        lpcm_adec_DecodeFrame(p_lpcmdec);
+        DecodeFrame(p_lpcmdec);
     }
 
     /* If b_error is set, the lpcm decoder thread enters the error loop */
     if (p_lpcmdec->p_fifo->b_error)
     {
-        lpcm_adec_ErrorThread (p_lpcmdec);
+        DecoderError( p_lpcmdec->p_fifo );
     }
 
     /* End of the lpcm decoder thread */
-    lpcm_adec_EndThread (p_lpcmdec);
+    EndThread (p_lpcmdec);
 
     return( 0 );
 }
 
 /*****************************************************************************
- * lpcm_adec_Init : initialize an lpcm decoder thread
+ * InitThread : initialize an lpcm decoder thread
  *****************************************************************************/
-static int lpcm_adec_Init (lpcmdec_thread_t * p_lpcmdec)
+static int InitThread (lpcmdec_thread_t * p_lpcmdec)
 {
 
     /* Init the BitStream */
@@ -177,9 +179,9 @@ static int lpcm_adec_Init (lpcmdec_thread_t * p_lpcmdec)
 }
 
 /*****************************************************************************
- * lpcm_adec_DecodeFrame: decodes a frame.
+ * DecodeFrame: decodes a frame.
  *****************************************************************************/
-void lpcm_adec_DecodeFrame( lpcmdec_thread_t * p_lpcmdec )
+void DecodeFrame( lpcmdec_thread_t * p_lpcmdec )
 {
     byte_t * buffer,p_temp[LPCMDEC_FRAME_SIZE];
     int i_loop;
@@ -233,40 +235,10 @@ void lpcm_adec_DecodeFrame( lpcmdec_thread_t * p_lpcmdec )
 
 }
 
-
-/*****************************************************************************
- * lpcm_adec_ErrorThread : lpcm decoder's RunThread() error loop
- *****************************************************************************/
-static void lpcm_adec_ErrorThread( lpcmdec_thread_t * p_lpcmdec )
-{
-    /* We take the lock, because we are going to read/write the start/end
-     * indexes of the decoder fifo */
-    vlc_mutex_lock( &p_lpcmdec->p_fifo->data_lock );
-
-    /* Wait until a `die' order is sent */
-    while( !p_lpcmdec->p_fifo->b_die ) 
-    {
-        /* Trash all received PES packets */
-        while( !DECODER_FIFO_ISEMPTY(*p_lpcmdec->p_fifo) ) 
-        {
-            p_lpcmdec->p_fifo->pf_delete_pes( p_lpcmdec->p_fifo->p_packets_mgt,
-                    DECODER_FIFO_START(*p_lpcmdec->p_fifo ));
-            DECODER_FIFO_INCSTART( *p_lpcmdec->p_fifo );
-        }
-
-        /* Waiting for the input thread to put new PES packets in the fifo */
-        vlc_cond_wait ( &p_lpcmdec->p_fifo->data_wait, 
-                        &p_lpcmdec->p_fifo->data_lock );
-    }
-
-    /* We can release the lock before leaving */
-    vlc_mutex_unlock( &p_lpcmdec->p_fifo->data_lock );
-}
-
 /*****************************************************************************
- * lpcm_adec_EndThread : lpcm decoder thread destruction
+ * EndThread : lpcm decoder thread destruction
  *****************************************************************************/
-static void lpcm_adec_EndThread( lpcmdec_thread_t * p_lpcmdec )
+static void EndThread( lpcmdec_thread_t * p_lpcmdec )
 {
     intf_DbgMsg( "LPCM Debug: destroying lpcm decoder thread %p", p_lpcmdec );
 
index d4346271a59cce43de3b74ea91ffb7c3629763c6..4a1a9d608aa1e26d19d756b09518fbdd13f74b2a 100644 (file)
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int      mad_adec_Probe       ( probedata_t * );
-static int      mad_adec_Run         ( decoder_config_t * );
-static int      mad_adec_Init        (mad_adec_thread_t * p_mad_adec);
-static void     mad_adec_ErrorThread (mad_adec_thread_t * p_mad_adec);
-static void     mad_adec_EndThread   (mad_adec_thread_t * p_mad_adec);
+static int  decoder_Probe  ( probedata_t * );
+static int  decoder_Run    ( decoder_config_t * );
+static int  InitThread     ( mad_adec_thread_t * p_mad_adec );
+static void EndThread      ( mad_adec_thread_t * p_mad_adec );
 
 /*****************************************************************************
  * Capabilities
  *****************************************************************************/
 void _M( adec_getfunctions )( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = mad_adec_Probe;
-    p_function_list->functions.dec.pf_run = mad_adec_Run;
+    p_function_list->pf_probe = decoder_Probe;
+    p_function_list->functions.dec.pf_run = decoder_Run;
 }
 
 /*****************************************************************************
@@ -94,12 +93,12 @@ MODULE_DEACTIVATE_START
 MODULE_DEACTIVATE_STOP
 
 /*****************************************************************************
- * mad_adec_Probe: probe the decoder and return score
+ * decoder_Probe: probe the decoder and return score
  *****************************************************************************
  * Tries to launch a decoder and return score so that the interface is able
  * to chose.
  *****************************************************************************/
-static int mad_adec_Probe( probedata_t *p_data )
+static int decoder_Probe( probedata_t *p_data )
 {
     if( p_data->i_type == MPEG1_AUDIO_ES || p_data->i_type == MPEG2_AUDIO_ES )
     {
@@ -116,9 +115,9 @@ static int mad_adec_Probe( probedata_t *p_data )
 }
 
 /*****************************************************************************
- * mad_adec_Run: this function is called just after the thread is created
+ * decoder_Run: this function is called just after the thread is created
  *****************************************************************************/
-static int mad_adec_Run ( decoder_config_t * p_config )
+static int decoder_Run ( decoder_config_t * p_config )
 {
     mad_adec_thread_t *   p_mad_adec;
 
@@ -130,7 +129,8 @@ static int mad_adec_Run ( decoder_config_t * p_config )
     if (p_mad_adec == NULL)
     {
         intf_ErrMsg ( "mad_adec error: not enough memory "
-                      "for mad_adec_Run() to allocate p_mad_adec" );
+                      "for decoder_Run() to allocate p_mad_adec" );
+        DecoderError( p_config->p_decoder_fifo );
         return( -1 );
     }
 
@@ -139,9 +139,11 @@ static int mad_adec_Run ( decoder_config_t * p_config )
      */
     p_mad_adec->p_config = p_config;
     p_mad_adec->p_fifo = p_mad_adec->p_config->p_decoder_fifo;
-    if( mad_adec_Init( p_mad_adec ) )
+    if( InitThread( p_mad_adec ) )
     {
         intf_ErrMsg( "mad_adec error: could not initialize thread" );
+        DecoderError( p_config->p_decoder_fifo );
+        free( p_mad_adec );
         return( -1 );
     }
 
@@ -152,7 +154,8 @@ static int mad_adec_Run ( decoder_config_t * p_config )
        if (mad_decoder_run(p_mad_adec->libmad_decoder, MAD_DECODER_MODE_SYNC)==-1)
        {
          intf_ErrMsg( "mad_adec error: libmad decoder returns abnormally");
-         mad_adec_EndThread(p_mad_adec);
+          DecoderError( p_mad_adec->p_fifo );
+         EndThread(p_mad_adec);
          return( -1 );
        }
     }
@@ -160,19 +163,19 @@ static int mad_adec_Run ( decoder_config_t * p_config )
     /* If b_error is set, the mad decoder thread enters the error loop */
     if (p_mad_adec->p_fifo->b_error)
     {
-        mad_adec_ErrorThread (p_mad_adec);
+        DecoderError( p_mad_adec->p_fifo );
     }
 
     /* End of the ac3 decoder thread */
-    mad_adec_EndThread (p_mad_adec);
+    EndThread (p_mad_adec);
 
     return( 0 );
 }
 
 /*****************************************************************************
- * mad_adec_Init: initialize data before entering main loop
+ * InitThread: initialize data before entering main loop
  *****************************************************************************/
-static int mad_adec_Init( mad_adec_thread_t * p_mad_adec )
+static int InitThread( mad_adec_thread_t * p_mad_adec )
 {
     /*
      * Properties of audio for libmad
index e20835d282e28e367eedd167a38b092247195b16..6cfd653d671a4877985b12447f4bc5efb83ce510 100644 (file)
@@ -2,7 +2,7 @@
  * mpeg_adec.c: MPEG audio decoder thread
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: mpeg_adec.c,v 1.5 2001/12/04 13:47:46 massiot Exp $
+ * $Id: mpeg_adec.c,v 1.5.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Michel Lespinasse <walken@via.ecp.fr>
 /*****************************************************************************
  * Local Prototypes
  *****************************************************************************/
-static int          adec_Probe( probedata_t * );
-static int          adec_RunThread   ( decoder_config_t * );
-static void         adec_EndThread ( adec_thread_t * );
-static void         adec_ErrorThread ( adec_thread_t * );
-static void         adec_Decode( adec_thread_t * );
+static int   decoder_Probe ( probedata_t * );
+static int   decoder_Run   ( decoder_config_t * );
+static void  EndThread     ( adec_thread_t * );
+static void  DecodeThread  ( adec_thread_t * );
 
 
 /*****************************************************************************
@@ -69,8 +68,8 @@ static void         adec_Decode( adec_thread_t * );
  *****************************************************************************/
 void _M( adec_getfunctions )( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = adec_Probe;
-    p_function_list->functions.dec.pf_run = adec_RunThread;
+    p_function_list->pf_probe = decoder_Probe;
+    p_function_list->functions.dec.pf_run = decoder_Run;
 }
 
 /*****************************************************************************
@@ -94,9 +93,9 @@ MODULE_DEACTIVATE_START
 MODULE_DEACTIVATE_STOP
 
 /*****************************************************************************
- * adec_Probe: probe the decoder and return score
+ * decoder_Probe: probe the decoder and return score
  *****************************************************************************/
-static int adec_Probe( probedata_t *p_data )
+static int decoder_Probe( probedata_t *p_data )
 {
     if( p_data->i_type == MPEG1_AUDIO_ES || p_data->i_type == MPEG2_AUDIO_ES )
     {
@@ -115,9 +114,9 @@ static int adec_Probe( probedata_t *p_data )
 }
 
 /*****************************************************************************
- * adec_RunThread: initialize, go inside main loop, detroy
+ * decoder_Run: initialize, go inside main loop, detroy
  *****************************************************************************/
-static int adec_RunThread ( decoder_config_t * p_config )
+static int decoder_Run ( decoder_config_t * p_config )
 {
     adec_thread_t   * p_adec;
     
@@ -128,6 +127,7 @@ static int adec_RunThread ( decoder_config_t * p_config )
     {
         intf_ErrMsg ( "adec error: not enough memory for"
                       " adec_CreateThread() to create the new thread" );
+        DecoderError( p_config->p_decoder_fifo );
         return 0;
     }
     
@@ -167,17 +167,17 @@ static int adec_RunThread ( decoder_config_t * p_config )
     /* Audio decoder thread's main loop */
     while( (!p_adec->p_fifo->b_die) && (!p_adec->p_fifo->b_error) )
     {
-        adec_Decode( p_adec );
+        DecodeThread( p_adec );
     }
     
     /* If b_error is set, the audio decoder thread enters the error loop */
     if( p_adec->p_fifo->b_error ) 
     {
-        adec_ErrorThread( p_adec );
+        DecoderError( p_adec->p_fifo );
     }
 
     /* End of the audio decoder thread */
-    adec_EndThread( p_adec );
+    EndThread( p_adec );
 
     return( 0 );
 }
@@ -187,9 +187,9 @@ static int adec_RunThread ( decoder_config_t * p_config )
  */
 
 /*****************************************************************************
- * adec_Decode: decodes a mpeg frame
+ * DecodeThread: decodes a mpeg frame
  *****************************************************************************/
-static void adec_Decode( adec_thread_t * p_adec )
+static void DecodeThread( adec_thread_t * p_adec )
 {
     s16 * buffer;
     adec_sync_info_t sync_info;
@@ -233,45 +233,12 @@ static void adec_Decode( adec_thread_t * p_adec )
 }
 
 /*****************************************************************************
- * adec_ErrorThread : audio decoder's RunThread() error loop
- *****************************************************************************
- * This function is called when an error occured during thread main's loop. The
- * thread can still receive feed, but must be ready to terminate as soon as
- * possible.
- *****************************************************************************/
-static void adec_ErrorThread ( adec_thread_t *p_adec )
-{
-    /* We take the lock, because we are going to read/write the start/end
-     * indexes of the decoder fifo */
-    vlc_mutex_lock ( &p_adec->p_fifo->data_lock );
-
-    /* Wait until a `die' order is sent */
-    while ( !p_adec->p_fifo->b_die ) 
-    {
-        /* Trash all received PES packets */
-        while ( !DECODER_FIFO_ISEMPTY(*p_adec->p_fifo) ) 
-        {
-            p_adec->p_fifo->pf_delete_pes ( p_adec->p_fifo->p_packets_mgt,
-                                   DECODER_FIFO_START(*p_adec->p_fifo) );
-            DECODER_FIFO_INCSTART ( *p_adec->p_fifo );
-        }
-
-        /* Waiting for the input thread to put new PES packets in the fifo */
-        vlc_cond_wait ( &p_adec->p_fifo->data_wait, &p_adec->p_fifo->data_lock );
-    }
-
-    /* We can release the lock before leaving */
-    vlc_mutex_unlock ( &p_adec->p_fifo->data_lock );
-}
-
-
-/*****************************************************************************
- * adec_EndThread : audio decoder thread destruction
+ * EndThread : audio decoder thread destruction
  *****************************************************************************
  * This function is called when the thread ends after a sucessful
  * initialization.
  *****************************************************************************/
-static void adec_EndThread ( adec_thread_t *p_adec )
+static void EndThread ( adec_thread_t *p_adec )
 {
     intf_DbgMsg ( "adec debug: destroying audio decoder thread %p", p_adec );
 
index 0f21100171c49d36d591d81e65b4707e2fc97a28..e0318f2f498f942dcc6382a5d466d5502f6fc8c2 100644 (file)
@@ -2,7 +2,7 @@
  * mpeg_adec.h : audio decoder thread interface
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: mpeg_adec.h,v 1.1 2001/11/13 12:09:18 henri Exp $
+ * $Id: mpeg_adec.h,v 1.1.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *
@@ -63,3 +63,4 @@ typedef struct adec_thread_s
  */
 int adec_SyncFrame( adec_thread_t *, adec_sync_info_t * );
 int adec_DecodeFrame( adec_thread_t * , s16 * );
+
index 6a4a2116c89ae3078ba59181a39fd954d0578046..b94569d62cd76d9d0e20198e28c4b5eb02c7556c 100644 (file)
@@ -2,7 +2,7 @@
  * video_parser.c : video parser thread
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: video_parser.c,v 1.6 2001/12/07 18:33:08 sam Exp $
+ * $Id: video_parser.c,v 1.6.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
 /*
  * Local prototypes
  */
-static int      mpeg_vdec_Probe         ( probedata_t * );
-static int      mpeg_vdec_Run           ( decoder_config_t * );
-static int      mpeg_vdec_Init          ( vpar_thread_t * );
-static void     mpeg_vdec_ErrorThread   ( vpar_thread_t * );
-static void     mpeg_vdec_EndThread     ( vpar_thread_t * );
-static void     BitstreamCallback       ( bit_stream_t *, boolean_t );
+static int      decoder_Probe     ( probedata_t * );
+static int      decoder_Run       ( decoder_config_t * );
+static int      InitThread        ( vpar_thread_t * );
+static void     EndThread         ( vpar_thread_t * );
+static void     BitstreamCallback ( bit_stream_t *, boolean_t );
 
 /*****************************************************************************
  * Capabilities
  *****************************************************************************/
 void _M( vdec_getfunctions )( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = mpeg_vdec_Probe;
-    p_function_list->functions.dec.pf_run = mpeg_vdec_Run;
+    p_function_list->pf_probe = decoder_Probe;
+    p_function_list->functions.dec.pf_run = decoder_Run;
 }
 
 /*****************************************************************************
@@ -102,12 +101,12 @@ MODULE_DEACTIVATE_STOP
 
 
 /*****************************************************************************
- * mpeg_vdec_Probe: probe the decoder and return score
+ * decoder_Probe: probe the decoder and return score
  *****************************************************************************
  * Tries to launch a decoder and return score so that the interface is able 
  * to chose.
  *****************************************************************************/
-static int mpeg_vdec_Probe( probedata_t *p_data )
+static int decoder_Probe( probedata_t *p_data )
 {
     if( p_data->i_type == MPEG1_VIDEO_ES || p_data->i_type == MPEG2_VIDEO_ES )
         return( 50 );
@@ -116,9 +115,9 @@ static int mpeg_vdec_Probe( probedata_t *p_data )
 }
 
 /*****************************************************************************
- * mpeg_vdec_Run: this function is called just after the thread is created
+ * decoder_Run: this function is called just after the thread is created
  *****************************************************************************/
-static int mpeg_vdec_Run ( decoder_config_t * p_config )
+static int decoder_Run ( decoder_config_t * p_config )
 {
     vpar_thread_t *     p_vpar;
     boolean_t           b_error;
@@ -130,6 +129,7 @@ static int mpeg_vdec_Run ( decoder_config_t * p_config )
     {
         intf_ErrMsg( "vpar error: not enough memory "
                      "for vpar_CreateThread() to create the new thread");
+        DecoderError( p_config->p_decoder_fifo );
         return( -1 );
     }
 
@@ -143,7 +143,7 @@ static int mpeg_vdec_Run ( decoder_config_t * p_config )
     /*
      * Initialize thread
      */
-    p_vpar->p_fifo->b_error = mpeg_vdec_Init( p_vpar );
+    p_vpar->p_fifo->b_error = InitThread( p_vpar );
      
     /*
      * Main loop - it is not executed if an error occured during
@@ -172,11 +172,11 @@ static int mpeg_vdec_Run ( decoder_config_t * p_config )
      */
     if( ( b_error = p_vpar->p_fifo->b_error ) )
     {
-        mpeg_vdec_ErrorThread( p_vpar );
+        DecoderError( p_vpar->p_fifo );
     }
 
     /* End of thread */
-    mpeg_vdec_EndThread( p_vpar );
+    EndThread( p_vpar );
 
     if( b_error )
     {
@@ -188,13 +188,13 @@ static int mpeg_vdec_Run ( decoder_config_t * p_config )
 } 
 
 /*****************************************************************************
- * mpeg_vdec_Init: initialize vpar output thread
+ * InitThread: initialize vpar output thread
  *****************************************************************************
- * This function is called from mpeg_vdec_Run and performs the second step 
+ * This function is called from decoder_Run and performs the second step 
  * of the initialization. It returns 0 on success. Note that the thread's 
  * flag are not modified inside this function.
  *****************************************************************************/
-static int mpeg_vdec_Init( vpar_thread_t *p_vpar )
+static int InitThread( vpar_thread_t *p_vpar )
 {
     /*
      * Choose the best motion compensation module
@@ -314,12 +314,12 @@ static void mpeg_vdec_ErrorThread( vpar_thread_t *p_vpar )
 }
 
 /*****************************************************************************
- * mpeg_vdec_EndThread: thread destruction
+ * EndThread: thread destruction
  *****************************************************************************
  * This function is called when the thread ends after a sucessful
  * initialization.
  *****************************************************************************/
-static void mpeg_vdec_EndThread( vpar_thread_t *p_vpar )
+static void EndThread( vpar_thread_t *p_vpar )
 {
     intf_DbgMsg("vpar debug: destroying video parser thread %p", p_vpar);
 
index a9eab6a0abea4ef49452c038088529eca09b97ca..09e531604464efe551145ac53386d32807fa75cb 100644 (file)
@@ -2,7 +2,7 @@
  * spu_decoder.c : spu decoder thread
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: spu_decoder.c,v 1.5.2.1 2001/12/13 23:56:18 sam Exp $
+ * $Id: spu_decoder.c,v 1.5.2.2 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -62,7 +62,6 @@
 static int spu_dec_Probe         ( probedata_t * );
 static int  spu_dec_Run          ( decoder_config_t * );
 static int  spu_dec_Init         ( spudec_thread_t * );
-static void spu_dec_ErrorThread  ( spudec_thread_t * );
 static void spu_dec_EndThread    ( spudec_thread_t * );
 
 static int  SyncPacket           ( spudec_thread_t * );
@@ -129,6 +128,7 @@ static int spu_dec_Run( decoder_config_t * p_config )
     {
         intf_ErrMsg( "spudec error: not enough memory "
                      "for spudec_CreateThread() to create the new thread" );
+        DecoderError( p_config->p_decoder_fifo );
         return( -1 );
     }
     
@@ -161,7 +161,7 @@ static int spu_dec_Run( decoder_config_t * p_config )
      */
     if( p_spudec->p_fifo->b_error )
     {
-        spu_dec_ErrorThread( p_spudec );
+        DecoderError( p_spudec->p_fifo );
     }
 
     /* End of thread */
@@ -219,39 +219,6 @@ static int spu_dec_Init( spudec_thread_t *p_spudec )
     return( 0 );
 }
 
-/*****************************************************************************
- * spu_dec_ErrorThread: spu_dec_Run() error loop
- *****************************************************************************
- * This function is called when an error occured during thread main's loop. The
- * thread can still receive feed, but must be ready to terminate as soon as
- * possible.
- *****************************************************************************/
-static void spu_dec_ErrorThread( spudec_thread_t *p_spudec )
-{
-    /* We take the lock, because we are going to read/write the start/end
-     * indexes of the decoder fifo */
-    vlc_mutex_lock( &p_spudec->p_fifo->data_lock );
-
-    /* Wait until a `die' order is sent */
-    while( !p_spudec->p_fifo->b_die )
-    {
-        /* Trash all received PES packets */
-        while( !DECODER_FIFO_ISEMPTY(*p_spudec->p_fifo) )
-        {
-            p_spudec->p_fifo->pf_delete_pes( p_spudec->p_fifo->p_packets_mgt,
-                    DECODER_FIFO_START(*p_spudec->p_fifo) );
-            DECODER_FIFO_INCSTART( *p_spudec->p_fifo );
-        }
-
-        /* Waiting for the input thread to put new PES packets in the fifo */
-        vlc_cond_wait( &p_spudec->p_fifo->data_wait,
-                       &p_spudec->p_fifo->data_lock );
-    }
-
-    /* We can release the lock before leaving */
-    vlc_mutex_unlock( &p_spudec->p_fifo->data_lock );
-}
-
 /*****************************************************************************
  * spu_dec_EndThread: thread destruction
  *****************************************************************************
index 013a8c0cd8fd6f7ee433dc9b1ade73f0b2885166..b38a144cd52a005eb22ca7ac6a1235e4c896d3a0 100644 (file)
@@ -2,7 +2,7 @@
  * input_ext-dec.c: services to the decoders
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_ext-dec.c,v 1.21 2001/11/28 15:08:06 massiot Exp $
+ * $Id: input_ext-dec.c,v 1.21.2.1 2001/12/30 06:06:00 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -87,6 +87,34 @@ void InitBitstream( bit_stream_t * p_bit_stream, decoder_fifo_t * p_fifo,
     }
 }
 
+/*****************************************************************************
+ * DecoderError : an error occured, use this function to empty the fifo
+ *****************************************************************************/
+void DecoderError( decoder_fifo_t * p_fifo )
+{
+    /* We take the lock, because we are going to read/write the start/end
+     * indexes of the decoder fifo */
+    vlc_mutex_lock( &p_fifo->data_lock );
+
+    /* Wait until a `die' order is sent */
+    while( !p_fifo->b_die )
+    {
+        /* Trash all received PES packets */
+        while( !DECODER_FIFO_ISEMPTY(*p_fifo) )
+        {
+            p_fifo->pf_delete_pes( p_fifo->p_packets_mgt,
+                                   DECODER_FIFO_START(*p_fifo) );
+            DECODER_FIFO_INCSTART( *p_fifo );
+        }
+
+        /* Waiting for the input thread to put new PES packets in the fifo */
+        vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
+    }
+
+    /* We can release the lock before leaving */
+    vlc_mutex_unlock( &p_fifo->data_lock );
+}
+
 /*****************************************************************************
  * NextDataPacket: go to the next data packet
  *****************************************************************************/