static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, double *pts_ptr)

{

    AVPacket *pkt = &is->audio_pkt;

    int n, len1, data_size;

    double pts;



    for(;;) {

        /* NOTE: the audio packet can contain several frames */

        while (is->audio_pkt_size > 0) {

            len1 = avcodec_decode_audio(&is->audio_st->codec, 

                                        (int16_t *)audio_buf, &data_size, 

                                        is->audio_pkt_data, is->audio_pkt_size);

            if (len1 < 0) {

                /* if error, we skip the frame */

                is->audio_pkt_size = 0;

                break;

            }

            

            is->audio_pkt_data += len1;

            is->audio_pkt_size -= len1;

            if (data_size <= 0)

                continue;

            /* if no pts, then compute it */

            pts = is->audio_clock;

            *pts_ptr = pts;

            n = 2 * is->audio_st->codec.channels;

printf("%f %d %d %d\n", is->audio_clock, is->audio_st->codec.channels, data_size, is->audio_st->codec.sample_rate);

            is->audio_clock += (double)data_size / 

                (double)(n * is->audio_st->codec.sample_rate);

#if defined(DEBUG_SYNC)

            {

                static double last_clock;

                printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n",

                       is->audio_clock - last_clock,

                       is->audio_clock, pts);

                last_clock = is->audio_clock;

            }

#endif

            return data_size;

        }



        /* free the current packet */

        if (pkt->data)

            av_free_packet(pkt);

        

        if (is->paused || is->audioq.abort_request) {

            return -1;

        }

        

        /* read next packet */

        if (packet_queue_get(&is->audioq, pkt, 1) < 0)

            return -1;

        is->audio_pkt_data = pkt->data;

        is->audio_pkt_size = pkt->size;

        

        /* if update the audio clock with the pts */

        if (pkt->pts != AV_NOPTS_VALUE) {

            is->audio_clock = (double)pkt->pts / AV_TIME_BASE;

        }

    }

}

static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, double *pts_ptr)

{

    AVPacket *pkt = &is->audio_pkt;

    int n, len1, data_size;

    double pts;



    for(;;) {

        

        while (is->audio_pkt_size > 0) {

            len1 = avcodec_decode_audio(&is->audio_st->codec, 

                                        (int16_t *)audio_buf, &data_size, 

                                        is->audio_pkt_data, is->audio_pkt_size);

            if (len1 < 0) {

                

                is->audio_pkt_size = 0;

                break;

            }

            

            is->audio_pkt_data += len1;

            is->audio_pkt_size -= len1;

            if (data_size <= 0)

                continue;

            

            pts = is->audio_clock;

            *pts_ptr = pts;

            n = 2 * is->audio_st->codec.channels;

printf("%f %d %d %d\n", is->audio_clock, is->audio_st->codec.channels, data_size, is->audio_st->codec.sample_rate);

            is->audio_clock += (double)data_size / 

                (double)(n * is->audio_st->codec.sample_rate);

#if defined(DEBUG_SYNC)

            {

                static double last_clock;

                printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n",

                       is->audio_clock - last_clock,

                       is->audio_clock, pts);

                last_clock = is->audio_clock;

            }

#endif

            return data_size;

        }



        

        if (pkt->data)

            av_free_packet(pkt);

        

        if (is->paused || is->audioq.abort_request) {

            return -1;

        }

        

        

        if (packet_queue_get(&is->audioq, pkt, 1) < 0)

            return -1;

        is->audio_pkt_data = pkt->data;

        is->audio_pkt_size = pkt->size;

        

        

        if (pkt->pts != AV_NOPTS_VALUE) {

            is->audio_clock = (double)pkt->pts / AV_TIME_BASE;

        }

    }

}

static int FUNC_0(VideoState *VAR_0, uint8_t *VAR_1, double *VAR_2)

{

    AVPacket *pkt = &VAR_0->audio_pkt;

    int VAR_3, VAR_4, VAR_5;

    double VAR_6;



    for(;;) {

        

        while (VAR_0->audio_pkt_size > 0) {

            VAR_4 = avcodec_decode_audio(&VAR_0->audio_st->codec, 

                                        (int16_t *)VAR_1, &VAR_5, 

                                        VAR_0->audio_pkt_data, VAR_0->audio_pkt_size);

            if (VAR_4 < 0) {

                

                VAR_0->audio_pkt_size = 0;

                break;

            }

            

            VAR_0->audio_pkt_data += VAR_4;

            VAR_0->audio_pkt_size -= VAR_4;

            if (VAR_5 <= 0)

                continue;

            

            VAR_6 = VAR_0->audio_clock;

            *VAR_2 = VAR_6;

            VAR_3 = 2 * VAR_0->audio_st->codec.channels;

printf("%f %d %d %d\VAR_3", VAR_0->audio_clock, VAR_0->audio_st->codec.channels, VAR_5, VAR_0->audio_st->codec.sample_rate);

            VAR_0->audio_clock += (double)VAR_5 / 

                (double)(VAR_3 * VAR_0->audio_st->codec.sample_rate);

#if defined(DEBUG_SYNC)

            {

                static double last_clock;

                printf("audio: delay=%0.3f clock=%0.3f VAR_6=%0.3f\VAR_3",

                       VAR_0->audio_clock - last_clock,

                       VAR_0->audio_clock, VAR_6);

                last_clock = VAR_0->audio_clock;

            }

#endif

            return VAR_5;

        }



        

        if (pkt->data)

            av_free_packet(pkt);

        

        if (VAR_0->paused || VAR_0->audioq.abort_request) {

            return -1;

        }

        

        

        if (packet_queue_get(&VAR_0->audioq, pkt, 1) < 0)

            return -1;

        VAR_0->audio_pkt_data = pkt->data;

        VAR_0->audio_pkt_size = pkt->size;

        

        

        if (pkt->VAR_6 != AV_NOPTS_VALUE) {

            VAR_0->audio_clock = (double)pkt->VAR_6 / AV_TIME_BASE;

        }

    }

}

static int FUNC_0(VideoState *VAR_0, uint8_t *VAR_1, double *VAR_2)
{ AVPacket *pkt = &VAR_0->audio_pkt; int VAR_3, VAR_4, VAR_5; double VAR_6; for(;;) { while (VAR_0->audio_pkt_size > 0) { VAR_4 = avcodec_decode_audio(&VAR_0->audio_st->codec,
(int16_t *)VAR_1, &VAR_5,
VAR_0->audio_pkt_data, VAR_0->audio_pkt_size); if (VAR_4 < 0) { VAR_0->audio_pkt_size = 0; break; } VAR_0->audio_pkt_data += VAR_4; VAR_0->audio_pkt_size -= VAR_4; if (VAR_5 <= 0)
continue; VAR_6 = VAR_0->audio_clock; *VAR_2 = VAR_6; VAR_3 = 2 * VAR_0->audio_st->codec.channels; printf("%f %d %d %d\VAR_3", VAR_0->audio_clock, VAR_0->audio_st->codec.channels, VAR_5, VAR_0->audio_st->codec.sample_rate); VAR_0->audio_clock += (double)VAR_5 /
(double)(VAR_3 * VAR_0->audio_st->codec.sample_rate); #if defined(DEBUG_SYNC)
{ static double last_clock; printf("audio: delay=%0.3f clock=%0.3f VAR_6=%0.3f\VAR_3",
VAR_0->audio_clock - last_clock,
VAR_0->audio_clock, VAR_6); last_clock = VAR_0->audio_clock; } #endif
return VAR_5; } if (pkt->data)
av_free_packet(pkt); if (VAR_0->paused || VAR_0->audioq.abort_request) { return -1; } if (packet_queue_get(&VAR_0->audioq, pkt, 1) < 0)
return -1; VAR_0->audio_pkt_data = pkt->data; VAR_0->audio_pkt_size = pkt->size; if (pkt->VAR_6 != AV_NOPTS_VALUE) { VAR_0->audio_clock = (double)pkt->VAR_6 / AV_TIME_BASE; } } }