]> git.sesse.net Git - vlc/blobdiff - src/input/input_dec.c
* Implemented basic stream navigation function, and bound Jump forward
[vlc] / src / input / input_dec.c
index e829cb526f98318107e598642d3ba034ad2c9b03..1ffb24e37587234abd2bdc108619e0a60661b2f0 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.3 2001/01/07 03:56:40 henri Exp $
+ * $Id: input_dec.c,v 1.8 2001/02/08 13:52:35 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -24,9 +24,9 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-/* FIXME: we shouldn't be obliged to include these */
 #include "defs.h"
 
+#include <stdlib.h>
 #include "config.h"
 #include "common.h"
 #include "threads.h"
@@ -35,6 +35,9 @@
 
 #include "stream_control.h"
 #include "input_ext-dec.h"
+#include "input_ext-intf.h"
+
+#include "input.h"
 
 /*****************************************************************************
  * input_RunDecoder: spawns a new decoder thread
@@ -48,29 +51,42 @@ vlc_thread_t input_RunDecoder( decoder_capabilities_t * p_decoder,
 /*****************************************************************************
  * input_EndDecoder: kills a decoder thread and waits until it's finished
  *****************************************************************************/
-void input_EndDecoder( decoder_fifo_t * p_decoder_fifo, vlc_thread_t thread_id )
+void input_EndDecoder( input_thread_t * p_input, es_descriptor_t * p_es )
 {
-    p_decoder_fifo->b_die = 1;
+    int i_dummy;
 
-    /* Make sure the thread leaves the NextDataPacket() function */
-    vlc_mutex_lock( &p_decoder_fifo->data_lock);
-    vlc_cond_signal( &p_decoder_fifo->data_wait );
-    vlc_mutex_unlock( &p_decoder_fifo->data_lock );
+    p_es->p_decoder_fifo->b_die = 1;
+
+    /* 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 );
+    }
 
-    /* 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 );
+    vlc_thread_join( p_es->thread_id );
 
     /* Freeing all packets still in the decoder fifo. */
-    while( !DECODER_FIFO_ISEMPTY( *p_decoder_fifo ) )
+    while( !DECODER_FIFO_ISEMPTY( *p_es->p_decoder_fifo ) )
     {
-        p_decoder_fifo->pf_delete_pes( p_decoder_fifo->p_packets_mgt,
-                                       DECODER_FIFO_START( *p_decoder_fifo ) );
-        DECODER_FIFO_INCSTART( *p_decoder_fifo );
+        p_es->p_decoder_fifo->pf_delete_pes(
+                            p_es->p_decoder_fifo->p_packets_mgt,
+                            DECODER_FIFO_START( *p_es->p_decoder_fifo ) );
+        DECODER_FIFO_INCSTART( *p_es->p_decoder_fifo );
     }
+
+    /* Destroy the lock and cond */
+    vlc_cond_destroy( &p_es->p_decoder_fifo->data_wait );
+    vlc_mutex_destroy( &p_es->p_decoder_fifo->data_lock );
+
+    free( p_es->p_decoder_fifo );
+    p_es->p_decoder_fifo = NULL;
 }
 
 /*****************************************************************************
@@ -99,3 +115,48 @@ void input_DecodePES( decoder_fifo_t * p_decoder_fifo, pes_packet_t * p_pes )
     }
     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 );
+            }
+        }
+    }
+}
+