]> git.sesse.net Git - vlc/blobdiff - src/input/input_dec.c
*Added udf fix by Billy Biggs
[vlc] / src / input / input_dec.c
index c6be01e6b2414f8cbda33e8a2c4a4a7359394aeb..20e6a2edc2a7278f7d1e6f6cb395096b20e10f1e 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.6 2001/01/12 17:33:18 massiot Exp $
+ * $Id: input_dec.c,v 1.10 2001/04/06 09:15:47 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -27,6 +27,8 @@
 #include "defs.h"
 
 #include <stdlib.h>
+#include <string.h>                                    /* memcpy(), memset() */
+
 #include "config.h"
 #include "common.h"
 #include "threads.h"
@@ -53,17 +55,28 @@ vlc_thread_t input_RunDecoder( decoder_capabilities_t * p_decoder,
  *****************************************************************************/
 void input_EndDecoder( input_thread_t * p_input, es_descriptor_t * p_es )
 {
+    int i_dummy;
+
     p_es->p_decoder_fifo->b_die = 1;
 
-    /* Make sure the thread leaves the NextDataPacket() function */
-    input_NullPacket( p_input, p_es );
+    /* Make sure the thread leaves the NextDataPacket() function by
+     * sending it a few null packets. */
+    for( i_dummy = 0; i_dummy < PADDING_PACKET_NUMBER; i_dummy++ )
+    {
+        input_NullPacket( p_input, p_es );
+    }
+
     if( p_es->p_pes != NULL )
     {
         input_DecodePES( p_es->p_decoder_fifo, p_es->p_pes );
     }
 
     /* Waiting for the thread to exit */
+    /* I thought that unlocking was better since thread join can be long
+     * but it actually creates late pictures and freezes --stef */
+//    vlc_mutex_unlock( &p_input->stream.stream_lock );
     vlc_thread_join( p_es->thread_id );
+//    vlc_mutex_lock( &p_input->stream.stream_lock );
 
     /* Freeing all packets still in the decoder fifo. */
     while( !DECODER_FIFO_ISEMPTY( *p_es->p_decoder_fifo ) )
@@ -104,7 +117,52 @@ void input_DecodePES( decoder_fifo_t * p_decoder_fifo, pes_packet_t * p_pes )
         /* The FIFO is full !!! This should not happen. */
         p_decoder_fifo->pf_delete_pes( p_decoder_fifo->p_packets_mgt,
                                        p_pes );
-        intf_ErrMsg( "PES trashed - fifo full !" );
+        intf_ErrMsg( "PES trashed - decoder fifo full !" );
     }
     vlc_mutex_unlock( &p_decoder_fifo->data_lock );
 }
+
+/*****************************************************************************
+ * input_EscapeDiscontinuity: send a NULL packet to the decoders
+ *****************************************************************************/
+void input_EscapeDiscontinuity( input_thread_t * p_input,
+                                pgrm_descriptor_t * p_pgrm )
+{
+    int     i_es, i;
+
+    for( i_es = 0; i_es < p_pgrm->i_es_number; i_es++ )
+    {
+        es_descriptor_t * p_es = p_pgrm->pp_es[i_es];
+
+        if( p_es->p_decoder_fifo != NULL )
+        {
+            for( i = 0; i < PADDING_PACKET_NUMBER; i++ )
+            {
+                input_NullPacket( p_input, p_es );
+            }
+        }
+    }
+}
+
+/*****************************************************************************
+ * input_EscapeAudioDiscontinuity: send a NULL packet to the audio decoders
+ *****************************************************************************/
+void input_EscapeAudioDiscontinuity( input_thread_t * p_input,
+                                     pgrm_descriptor_t * p_pgrm )
+{
+    int     i_es, i;
+
+    for( i_es = 0; i_es < p_pgrm->i_es_number; i_es++ )
+    {
+        es_descriptor_t * p_es = p_pgrm->pp_es[i_es];
+
+        if( p_es->p_decoder_fifo != NULL && p_es->b_audio )
+        {
+            for( i = 0; i < PADDING_PACKET_NUMBER; i++ )
+            {
+                input_NullPacket( p_input, p_es );
+            }
+        }
+    }
+}
+