* 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>
*
#include "defs.h"
#include <stdlib.h>
+#include <string.h> /* memcpy(), memset() */
+
#include "config.h"
#include "common.h"
#include "threads.h"
*****************************************************************************/
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 ) )
/* 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 );
+ }
+ }
+ }
+}
+