* input_ext-dec.c: services to the decoders
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: input_ext-dec.c,v 1.35 2002/10/21 10:46:34 fenrir Exp $
+ * $Id: input_ext-dec.c,v 1.36 2002/10/23 23:17:44 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
vlc_mutex_unlock (&p_fifo->data_lock);
}
+/*****************************************************************************
+ * GetPES: return the first PES from the fifo
+ *****************************************************************************/
+static inline pes_packet_t *_GetPES( decoder_fifo_t * p_fifo )
+{
+ pes_packet_t * p_pes;
+
+ vlc_mutex_lock( &p_fifo->data_lock );
+
+ if( p_fifo->p_first == NULL )
+ {
+ /* No PES in the FIFO. p_last is no longer valid. */
+ p_fifo->pp_last = &p_fifo->p_first;
+
+ if( p_fifo->b_die )
+ {
+ vlc_mutex_unlock( &p_fifo->data_lock );
+ return NULL;
+ }
+
+ /* Signal the input thread we're waiting. This is only
+ * needed in case of slave clock (ES plug-in) but it won't
+ * harm. */
+ vlc_cond_signal( &p_fifo->data_wait );
+
+ /* Wait for the input to tell us when we receive a packet. */
+ vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
+ }
+
+ p_pes = p_fifo->p_first;
+
+ vlc_mutex_unlock( &p_fifo->data_lock );
+
+ return p_pes;
+}
+
+pes_packet_t * GetPES( decoder_fifo_t * p_fifo )
+{
+ return( _GetPES( p_fifo ) );
+}
+
+/*****************************************************************************
+ * NextPES: free the current PES and return the next one
+ *****************************************************************************/
+static inline pes_packet_t * _NextPES( decoder_fifo_t * p_fifo )
+{
+ pes_packet_t * p_next;
+
+ vlc_mutex_lock( &p_fifo->data_lock );
+
+ /* Free the previous PES packet. */
+ p_next = p_fifo->p_first->p_next;
+ p_fifo->p_first->p_next = NULL;
+ input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first );
+ p_fifo->p_first = p_next;
+ p_fifo->i_depth--;
+
+ vlc_mutex_unlock( &p_fifo->data_lock );
+
+ return _GetPES( p_fifo );
+}
+
+pes_packet_t * NextPES( decoder_fifo_t * p_fifo )
+{
+ return( _NextPES( p_fifo ) );
+}
+
/*****************************************************************************
* NextDataPacket: go to the data packet after *pp_data, return 1 if we
* changed PES
* time to jump to the next PES packet */
if( (*pp_data)->p_next == NULL )
{
- pes_packet_t * p_next;
-
- vlc_mutex_lock( &p_fifo->data_lock );
-
- /* Free the previous PES packet. */
- p_next = p_fifo->p_first->p_next;
- p_fifo->p_first->p_next = NULL;
- input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first );
- p_fifo->p_first = p_next;
- p_fifo->i_depth--;
-
- if( p_fifo->p_first == NULL )
- {
- /* No PES in the FIFO. p_last is no longer valid. */
- p_fifo->pp_last = &p_fifo->p_first;
-
- /* Signal the input thread we're waiting. This is only
- * needed in case of slave clock (ES plug-in) but it won't
- * harm. */
- vlc_cond_signal( &p_fifo->data_wait );
-
- /* Wait for the input to tell us when we receive a packet. */
- vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
- }
-
/* The next packet could be found in the next PES packet */
- *pp_data = p_fifo->p_first->p_first;
-
- vlc_mutex_unlock( &p_fifo->data_lock );
+ *pp_data = (_NextPES( p_fifo ))->p_first;
b_new_pes = 1;
}