audio_decoder.c 14 KB
Newer Older
1
/*****************************************************************************
Sam Hocevar's avatar
 
Sam Hocevar committed
2
 * audio_decoder.c: MPEG audio decoder thread
3 4
 *****************************************************************************
 * Copyright (C) 1999, 2000 VideoLAN
5
 * $Id: audio_decoder.c,v 1.40 2000/12/21 13:25:50 massiot Exp $
6
 *
7 8 9
 * Authors: Michel Kaempf <maxx@via.ecp.fr>
 *          Michel Lespinasse <walken@via.ecp.fr>
 *          Samuel Hocevar <sam@via.ecp.fr>
10 11 12 13 14
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
Sam Hocevar's avatar
 
Sam Hocevar committed
15
 * 
16 17
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
20
 *
21 22 23
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
25 26 27

/*
 * TODO :
28 29
 *
 * - optimiser les NeedBits() et les GetBits() du code l o c'est possible ;
Sam Hocevar's avatar
 
Sam Hocevar committed
30
 * - vlc_cond_signal() / vlc_cond_wait() ;
31
 *
Michel Kaempf's avatar
Michel Kaempf committed
32 33
 */

Sam Hocevar's avatar
 
Sam Hocevar committed
34 35 36 37
/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include "defs.h"
Michel Kaempf's avatar
Michel Kaempf committed
38

Sam Hocevar's avatar
 
Sam Hocevar committed
39
#include <unistd.h>                                              /* getpid() */
Sam Hocevar's avatar
Sam Hocevar committed
40

Sam Hocevar's avatar
 
Sam Hocevar committed
41 42 43 44 45
#include <stdio.h>                                           /* "intf_msg.h" */
#include <stdlib.h>                                      /* malloc(), free() */
#include <sys/types.h>                        /* on BSD, uio.h needs types.h */
#include <sys/uio.h>                                            /* "input.h" */
#include <netinet/in.h>                                             /* ntohl */
Michel Kaempf's avatar
Michel Kaempf committed
46

Sam Hocevar's avatar
 
Sam Hocevar committed
47 48 49 50 51 52
#include "threads.h"
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "plugins.h"
#include "debug.h"                                      /* "input_netlist.h" */
Michel Kaempf's avatar
Michel Kaempf committed
53

Sam Hocevar's avatar
 
Sam Hocevar committed
54 55 56 57
#include "intf_msg.h"                        /* intf_DbgMsg(), intf_ErrMsg() */
 
#include "stream_control.h"
#include "input_ext-dec.h"
Michel Kaempf's avatar
Michel Kaempf committed
58

Sam Hocevar's avatar
 
Sam Hocevar committed
59
#include "audio_output.h"               /* aout_fifo_t (for audio_decoder.h) */
Michel Kaempf's avatar
Michel Kaempf committed
60

Sam Hocevar's avatar
 
Sam Hocevar committed
61 62 63
#include "adec_generic.h"
#include "audio_decoder.h"
#include "adec_math.h"                                     /* DCT32(), PCM() */
Michel Kaempf's avatar
Michel Kaempf committed
64

Sam Hocevar's avatar
 
Sam Hocevar committed
65
#define ADEC_FRAME_SIZE (2*1152)
66

Sam Hocevar's avatar
 
Sam Hocevar committed
67 68 69 70 71 72 73
/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
static int      InitThread             (adec_thread_t * p_adec);
static void     RunThread              (adec_thread_t * p_adec);
static void     ErrorThread            (adec_thread_t * p_adec);
static void     EndThread              (adec_thread_t * p_adec);
74

Sam Hocevar's avatar
 
Sam Hocevar committed
75 76 77 78 79 80 81
/*****************************************************************************
 * adec_CreateThread: creates an audio decoder thread
 *****************************************************************************
 * This function creates a new audio decoder thread, and returns a pointer to
 * its description. On error, it returns NULL.
 *****************************************************************************/
vlc_thread_t adec_CreateThread ( adec_config_t * p_config )
Michel Kaempf's avatar
Michel Kaempf committed
82
{
Sam Hocevar's avatar
 
Sam Hocevar committed
83
    adec_thread_t *     p_adec;
Michel Kaempf's avatar
Michel Kaempf committed
84

Sam Hocevar's avatar
 
Sam Hocevar committed
85
    intf_DbgMsg ( "adec debug: creating audio decoder thread\n" );
86

Sam Hocevar's avatar
 
Sam Hocevar committed
87 88
    /* Allocate the memory needed to store the thread's structure */
    if ( (p_adec = (adec_thread_t *)malloc (sizeof(adec_thread_t))) == NULL ) 
Henri Fallon's avatar
 
Henri Fallon committed
89
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
90 91
        intf_ErrMsg ( "adec error: not enough memory for adec_CreateThread() to create the new thread\n" );
        return 0;
Michel Kaempf's avatar
Michel Kaempf committed
92 93
    }

Sam Hocevar's avatar
 
Sam Hocevar committed
94 95 96 97 98
    /*
     * Initialize the thread properties
     */
    p_adec->p_config = p_config;
    p_adec->p_fifo = p_config->decoder_config.p_decoder_fifo;
99

Sam Hocevar's avatar
Sam Hocevar committed
100

Sam Hocevar's avatar
 
Sam Hocevar committed
101 102 103 104
    /*
     * Initialize the decoder properties
     */
    adec_init ( &p_adec->audio_decoder );
Sam Hocevar's avatar
Sam Hocevar committed
105

Sam Hocevar's avatar
 
Sam Hocevar committed
106 107 108 109 110
    /*
     * Initialize the output properties
     */
    p_adec->p_aout = p_config->p_aout;
    p_adec->p_aout_fifo = NULL;
Sam Hocevar's avatar
Sam Hocevar committed
111

Sam Hocevar's avatar
 
Sam Hocevar committed
112 113
    /* Spawn the audio decoder thread */
    if ( vlc_thread_create(&p_adec->thread_id, "audio decoder", (vlc_thread_func_t)RunThread, (void *)p_adec) ) 
Henri Fallon's avatar
 
Henri Fallon committed
114
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
115 116 117
        intf_ErrMsg ("adec error: can't spawn audio decoder thread\n");
        free (p_adec);
        return 0;
Michel Kaempf's avatar
Michel Kaempf committed
118
    }
119

Sam Hocevar's avatar
 
Sam Hocevar committed
120 121
    intf_DbgMsg ("adec debug: audio decoder thread (%p) created\n", p_adec);
    return p_adec->thread_id;
122 123
}

Sam Hocevar's avatar
 
Sam Hocevar committed
124 125 126 127 128 129 130
/*****************************************************************************
 * InitThread : initialize an audio decoder thread
 *****************************************************************************
 * This function is called from RunThread and performs the second step of the
 * initialization. It returns 0 on success.
 *****************************************************************************/
static int InitThread (adec_thread_t * p_adec)
131
{
Sam Hocevar's avatar
 
Sam Hocevar committed
132 133
    aout_fifo_t          aout_fifo;
    adec_byte_stream_t * byte_stream;
134

Sam Hocevar's avatar
 
Sam Hocevar committed
135
    intf_DbgMsg ("adec debug: initializing audio decoder thread %p\n", p_adec);
Sam Hocevar's avatar
Sam Hocevar committed
136

Sam Hocevar's avatar
 
Sam Hocevar committed
137 138 139 140
    /* Our first job is to initialize the bit stream structure with the
     * beginning of the input stream */
    vlc_mutex_lock ( &p_adec->p_fifo->data_lock );
    while ( DECODER_FIFO_ISEMPTY(*p_adec->p_fifo) ) 
Henri Fallon's avatar
 
Henri Fallon committed
141
    {
142
        if (p_adec->p_fifo->b_die) 
Sam Hocevar's avatar
Sam Hocevar committed
143
        {
Sam Hocevar's avatar
 
Sam Hocevar committed
144 145
            vlc_mutex_unlock ( &p_adec->p_fifo->data_lock );
            return -1;
Sam Hocevar's avatar
Sam Hocevar committed
146
        }
Sam Hocevar's avatar
 
Sam Hocevar committed
147
        vlc_cond_wait ( &p_adec->p_fifo->data_wait, &p_adec->p_fifo->data_lock );
Michel Kaempf's avatar
Michel Kaempf committed
148
    }
Sam Hocevar's avatar
 
Sam Hocevar committed
149 150 151 152 153 154
    p_adec->p_data = DECODER_FIFO_START ( *p_adec->p_fifo )->p_first;
    byte_stream = adec_byte_stream ( &p_adec->audio_decoder );
    byte_stream->p_byte = p_adec->p_data->p_payload_start;
    byte_stream->p_end = p_adec->p_data->p_payload_end;
    byte_stream->info = p_adec;
    vlc_mutex_unlock ( &p_adec->p_fifo->data_lock );
Michel Kaempf's avatar
Michel Kaempf committed
155

Sam Hocevar's avatar
 
Sam Hocevar committed
156 157 158 159
    aout_fifo.i_type = AOUT_ADEC_STEREO_FIFO;
    aout_fifo.i_channels = 2;
    aout_fifo.b_stereo = 1;
    aout_fifo.l_frame_size = ADEC_FRAME_SIZE;
160

Sam Hocevar's avatar
 
Sam Hocevar committed
161 162
    /* Creating the audio output fifo */
    if ( (p_adec->p_aout_fifo = aout_CreateFifo(p_adec->p_aout, &aout_fifo)) == NULL ) 
Henri Fallon's avatar
 
Henri Fallon committed
163
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
164
        return -1;
Michel Kaempf's avatar
Michel Kaempf committed
165 166
    }

Sam Hocevar's avatar
 
Sam Hocevar committed
167
    intf_DbgMsg ( "adec debug: audio decoder thread %p initialized\n", p_adec );
168 169 170
    return 0;
}

Sam Hocevar's avatar
 
Sam Hocevar committed
171 172 173 174 175 176 177
/*****************************************************************************
 * RunThread : audio decoder thread
 *****************************************************************************
 * Audio decoder thread. This function does only returns when the thread is
 * terminated.
 *****************************************************************************/
static void RunThread (adec_thread_t * p_adec)
178
{
Sam Hocevar's avatar
 
Sam Hocevar committed
179
    int sync;
Henri Fallon's avatar
 
Henri Fallon committed
180

Sam Hocevar's avatar
 
Sam Hocevar committed
181
    intf_DbgMsg ( "adec debug: running audio decoder thread (%p) (pid == %i)\n", p_adec, getpid() );
Henri Fallon's avatar
 
Henri Fallon committed
182

Sam Hocevar's avatar
 
Sam Hocevar committed
183 184
    /* You really suck */
    //msleep ( INPUT_PTS_DELAY );
Henri Fallon's avatar
 
Henri Fallon committed
185

Sam Hocevar's avatar
 
Sam Hocevar committed
186 187
    /* Initializing the audio decoder thread */
    if( InitThread (p_adec) )
Henri Fallon's avatar
 
Henri Fallon committed
188
    {
189
        p_adec->p_fifo->b_error = 1;
Sam Hocevar's avatar
Sam Hocevar committed
190
    }
Henri Fallon's avatar
 
Henri Fallon committed
191

Sam Hocevar's avatar
 
Sam Hocevar committed
192
    sync = 0;
Henri Fallon's avatar
 
Henri Fallon committed
193

Sam Hocevar's avatar
 
Sam Hocevar committed
194
    /* Audio decoder thread's main loop */
195
    while( (!p_adec->p_fifo->b_die) && (!p_adec->p_fifo->b_error) )
Henri Fallon's avatar
 
Henri Fallon committed
196
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
197 198
        s16 * buffer;
        adec_sync_info_t sync_info;
Henri Fallon's avatar
 
Henri Fallon committed
199

Sam Hocevar's avatar
 
Sam Hocevar committed
200
        if ( !sync )
Henri Fallon's avatar
 
Henri Fallon committed
201
        {
Sam Hocevar's avatar
 
Sam Hocevar committed
202 203 204 205 206 207 208 209 210 211 212
            /* have to find a synchro point */
            adec_byte_stream_t * p_byte_stream;
            
            intf_DbgMsg ( "adec: sync\n" );
            
            p_byte_stream = adec_byte_stream ( &p_adec->audio_decoder );
            /* FIXME: the check will be done later, am I right ? */

            /* FIXME: is this really needed ?
            adec_byte_stream_next ( p_byte_stream ); */

213
            if( p_adec->p_fifo->b_die || p_adec->p_fifo->b_error )
Sam Hocevar's avatar
Sam Hocevar committed
214
            {
Sam Hocevar's avatar
 
Sam Hocevar committed
215
                goto bad_frame;
Sam Hocevar's avatar
Sam Hocevar committed
216 217 218
            }

        }
219

Sam Hocevar's avatar
 
Sam Hocevar committed
220
        if( DECODER_FIFO_START( *p_adec->p_fifo)->b_has_pts )
Sam Hocevar's avatar
Sam Hocevar committed
221
        {
Sam Hocevar's avatar
 
Sam Hocevar committed
222 223 224
            p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] =
                DECODER_FIFO_START( *p_adec->p_fifo )->i_pts;
            DECODER_FIFO_START(*p_adec->p_fifo)->b_has_pts = 0;
Sam Hocevar's avatar
Sam Hocevar committed
225
        }
Sam Hocevar's avatar
 
Sam Hocevar committed
226
        else
Sam Hocevar's avatar
Sam Hocevar committed
227
        {
Sam Hocevar's avatar
 
Sam Hocevar committed
228 229
            p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] =
                LAST_MDATE;
Sam Hocevar's avatar
Sam Hocevar committed
230 231
        }

Sam Hocevar's avatar
 
Sam Hocevar committed
232
        if( adec_sync_frame (&p_adec->audio_decoder, &sync_info) )
Sam Hocevar's avatar
Sam Hocevar committed
233
        {
Sam Hocevar's avatar
 
Sam Hocevar committed
234
            goto bad_frame;
Sam Hocevar's avatar
Sam Hocevar committed
235
        }
Sam Hocevar's avatar
 
Sam Hocevar committed
236 237
        
        sync = 1;
Sam Hocevar's avatar
Sam Hocevar committed
238

Sam Hocevar's avatar
 
Sam Hocevar committed
239
        p_adec->p_aout_fifo->l_rate = sync_info.sample_rate;
Sam Hocevar's avatar
Sam Hocevar committed
240

Sam Hocevar's avatar
 
Sam Hocevar committed
241 242
        buffer = ((s16 *)p_adec->p_aout_fifo->buffer)
                    + (p_adec->p_aout_fifo->l_end_frame * ADEC_FRAME_SIZE);
Sam Hocevar's avatar
Sam Hocevar committed
243

Sam Hocevar's avatar
 
Sam Hocevar committed
244
        if( adec_decode_frame (&p_adec->audio_decoder, buffer) )
Sam Hocevar's avatar
Sam Hocevar committed
245
        {
Sam Hocevar's avatar
 
Sam Hocevar committed
246 247 248
            sync = 0;
            goto bad_frame;
        }
Sam Hocevar's avatar
Sam Hocevar committed
249

Sam Hocevar's avatar
 
Sam Hocevar committed
250
        vlc_mutex_lock (&p_adec->p_aout_fifo->data_lock);
Sam Hocevar's avatar
Sam Hocevar committed
251

Sam Hocevar's avatar
 
Sam Hocevar committed
252 253 254 255
        p_adec->p_aout_fifo->l_end_frame =
            (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
        vlc_cond_signal (&p_adec->p_aout_fifo->data_wait);
        vlc_mutex_unlock (&p_adec->p_aout_fifo->data_lock);
Sam Hocevar's avatar
Sam Hocevar committed
256

Sam Hocevar's avatar
 
Sam Hocevar committed
257
        bad_frame:
Michel Kaempf's avatar
Michel Kaempf committed
258 259
    }

Sam Hocevar's avatar
 
Sam Hocevar committed
260
    /* If b_error is set, the audio decoder thread enters the error loop */
261
    if( p_adec->p_fifo->b_error ) 
Sam Hocevar's avatar
Sam Hocevar committed
262
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
263
        ErrorThread( p_adec );
Sam Hocevar's avatar
Sam Hocevar committed
264
    }
265

Sam Hocevar's avatar
 
Sam Hocevar committed
266 267
    /* End of the audio decoder thread */
    EndThread( p_adec );
268
}
Michel Kaempf's avatar
Michel Kaempf committed
269

Sam Hocevar's avatar
 
Sam Hocevar committed
270 271 272 273 274 275 276 277
/*****************************************************************************
 * ErrorThread : audio decoder's RunThread() error loop
 *****************************************************************************
 * This function is called when an error occured during thread main's loop. The
 * thread can still receive feed, but must be ready to terminate as soon as
 * possible.
 *****************************************************************************/
static void ErrorThread ( adec_thread_t *p_adec )
Michel Lespinasse's avatar
 
Michel Lespinasse committed
278
{
Sam Hocevar's avatar
 
Sam Hocevar committed
279 280 281
    /* We take the lock, because we are going to read/write the start/end
     * indexes of the decoder fifo */
    vlc_mutex_lock ( &p_adec->p_fifo->data_lock );
Michel Kaempf's avatar
Michel Kaempf committed
282

Sam Hocevar's avatar
 
Sam Hocevar committed
283
    /* Wait until a `die' order is sent */
284
    while ( !p_adec->p_fifo->b_die ) 
Sam Hocevar's avatar
Sam Hocevar committed
285
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
286 287 288 289 290 291
        /* Trash all received PES packets */
        while ( !DECODER_FIFO_ISEMPTY(*p_adec->p_fifo) ) 
        {
            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 );
Sam Hocevar's avatar
Sam Hocevar committed
292
        }
Sam Hocevar's avatar
 
Sam Hocevar committed
293 294 295

        /* Waiting for the input thread to put new PES packets in the fifo */
        vlc_cond_wait ( &p_adec->p_fifo->data_wait, &p_adec->p_fifo->data_lock );
296 297
    }

Sam Hocevar's avatar
 
Sam Hocevar committed
298 299 300
    /* We can release the lock before leaving */
    vlc_mutex_unlock ( &p_adec->p_fifo->data_lock );
}
301

Sam Hocevar's avatar
 
Sam Hocevar committed
302 303 304 305 306 307 308 309 310
/*****************************************************************************
 * EndThread : audio decoder thread destruction
 *****************************************************************************
 * This function is called when the thread ends after a sucessful
 * initialization.
 *****************************************************************************/
static void EndThread ( adec_thread_t *p_adec )
{
    intf_DbgMsg ( "adec debug: destroying audio decoder thread %p\n", p_adec );
Sam Hocevar's avatar
Sam Hocevar committed
311

Sam Hocevar's avatar
 
Sam Hocevar committed
312 313
    /* If the audio output fifo was created, we destroy it */
    if ( p_adec->p_aout_fifo != NULL ) 
Sam Hocevar's avatar
Sam Hocevar committed
314
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
315
        aout_DestroyFifo ( p_adec->p_aout_fifo );
Michel Lespinasse's avatar
 
Michel Lespinasse committed
316

Sam Hocevar's avatar
 
Sam Hocevar committed
317 318 319 320
        /* Make sure the output thread leaves the NextFrame() function */
        vlc_mutex_lock (&(p_adec->p_aout_fifo->data_lock));
        vlc_cond_signal (&(p_adec->p_aout_fifo->data_wait));
        vlc_mutex_unlock (&(p_adec->p_aout_fifo->data_lock));
Sam Hocevar's avatar
Sam Hocevar committed
321
    }
Sam Hocevar's avatar
 
Sam Hocevar committed
322 323
    /* Destroy descriptor */
    free (p_adec);
Michel Kaempf's avatar
Michel Kaempf committed
324

Sam Hocevar's avatar
 
Sam Hocevar committed
325
    intf_DbgMsg ("adec debug: audio decoder thread %p destroyed\n", p_adec);
Michel Kaempf's avatar
Michel Kaempf committed
326 327
}

Sam Hocevar's avatar
 
Sam Hocevar committed
328
void adec_byte_stream_next ( adec_byte_stream_t * p_byte_stream )
Michel Kaempf's avatar
Michel Kaempf committed
329
{
Sam Hocevar's avatar
 
Sam Hocevar committed
330
    adec_thread_t * p_adec = p_byte_stream->info;
Michel Kaempf's avatar
Michel Kaempf committed
331

Sam Hocevar's avatar
 
Sam Hocevar committed
332 333 334
    /* We are looking for the next TS packet that contains real data,
     * and not just a PES header */
    do 
Sam Hocevar's avatar
Sam Hocevar committed
335
    {
Sam Hocevar's avatar
 
Sam Hocevar committed
336 337 338 339 340 341 342 343
        /* 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);
Sam Hocevar's avatar
Sam Hocevar committed
344

Sam Hocevar's avatar
 
Sam Hocevar committed
345 346
            /* Is the input thread dying ? */
            if (p_adec->p_fifo->b_die) 
Sam Hocevar's avatar
Sam Hocevar committed
347
            {
Sam Hocevar's avatar
 
Sam Hocevar committed
348 349
                vlc_mutex_unlock (&(p_adec->p_fifo->data_lock));
                return;
Sam Hocevar's avatar
Sam Hocevar committed
350
            }
Sam Hocevar's avatar
 
Sam Hocevar committed
351 352 353 354 355 356 357 358 359 360 361

            /* 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)) 
Sam Hocevar's avatar
Sam Hocevar committed
362
            {
Sam Hocevar's avatar
 
Sam Hocevar committed
363 364
                vlc_cond_wait (&p_adec->p_fifo->data_wait, &p_adec->p_fifo->data_lock);
                if (p_adec->p_fifo->b_die) 
Sam Hocevar's avatar
Sam Hocevar committed
365
                {
Sam Hocevar's avatar
 
Sam Hocevar committed
366 367
                    vlc_mutex_unlock (&(p_adec->p_fifo->data_lock));
                    return;
Sam Hocevar's avatar
Sam Hocevar committed
368 369
                }
            }
Michel Kaempf's avatar
Michel Kaempf committed
370

Sam Hocevar's avatar
 
Sam Hocevar committed
371 372
            /* The next byte could be found in the next PES packet */
            p_adec->p_data = DECODER_FIFO_START (*p_adec->p_fifo)->p_first;
Michel Kaempf's avatar
Michel Kaempf committed
373

Sam Hocevar's avatar
 
Sam Hocevar committed
374 375 376 377 378 379 380 381 382 383
            /* 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);
Michel Kaempf's avatar
Michel Kaempf committed
384

Sam Hocevar's avatar
 
Sam Hocevar committed
385 386 387
    /* 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;
Michel Kaempf's avatar
Michel Kaempf committed
388
}