-void adec_byte_stream_next ( adec_byte_stream_t * p_byte_stream )
-{
- adec_thread_t * p_adec = p_byte_stream->info;
-
- /* We are looking for the next TS packet that contains real data,
- * and not just a PES header */
- do
- {
- /* We were reading the last TS packet of this PES packet... It's
- * time to jump to the next PES packet */
- if (p_adec->p_data->p_next == NULL)
- {
- /* We are going to read/write the start and end indexes of the
- * decoder fifo and to use the fifo's conditional variable,
- * that's why we need to take the lock before */
- vlc_mutex_lock (&p_adec->p_fifo->data_lock);
-
- /* Is the input thread dying ? */
- if (p_adec->p_fifo->b_die)
- {
- vlc_mutex_unlock (&(p_adec->p_fifo->data_lock));
- return;
- }
-
- /* We should increase the start index of the decoder fifo, but
- * if we do this now, the input thread could overwrite the
- * pointer to the current PES packet, and we weren't able to
- * give it back to the netlist. That's why we free the PES
- * packet first. */
- 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);
-
- while (DECODER_FIFO_ISEMPTY(*p_adec->p_fifo))
- {
- vlc_cond_wait (&p_adec->p_fifo->data_wait, &p_adec->p_fifo->data_lock);
- if (p_adec->p_fifo->b_die)
- {
- vlc_mutex_unlock (&(p_adec->p_fifo->data_lock));
- return;
- }
- }
-
- /* The next byte could be found in the next PES packet */
- p_adec->p_data = DECODER_FIFO_START (*p_adec->p_fifo)->p_first;
-
- /* We can release the fifo's data lock */
- vlc_mutex_unlock (&p_adec->p_fifo->data_lock);
- }
- /* Perhaps the next TS packet of the current PES packet contains
- * real data (ie its payload's size is greater than 0) */
- else
- {
- p_adec->p_data = p_adec->p_data->p_next;
- }
- } while (p_adec->p_data->p_payload_start == p_adec->p_data->p_payload_end);
-
- /* We've found a TS packet which contains interesting data... */
- p_byte_stream->p_byte = p_adec->p_data->p_payload_start;
- p_byte_stream->p_end = p_adec->p_data->p_payload_end;
-}