static int read_packet(AVFormatContext* ctx, AVPacket *pkt)

{

    al_data *ad = ctx->priv_data;

    int error=0;

    const char *error_msg;

    ALCint nb_samples;



    /* Get number of samples available */

    alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);

    if (error = al_get_error(ad->device, &error_msg)) goto fail;



    /* Create a packet of appropriate size */

    av_new_packet(pkt, nb_samples*ad->sample_step);

    pkt->pts = av_gettime();



    /* Fill the packet with the available samples */

    alcCaptureSamples(ad->device, pkt->data, nb_samples);

    if (error = al_get_error(ad->device, &error_msg)) goto fail;



    return pkt->size;

fail:

    /* Handle failure */

    if (pkt->data)

        av_destruct_packet(pkt);

    if (error_msg)

        av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg);

    return error;

}

static int read_packet(AVFormatContext* ctx, AVPacket *pkt)

{

    al_data *ad = ctx->priv_data;

    int error=0;

    const char *error_msg;

    ALCint nb_samples;



    

    alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);

    if (error = al_get_error(ad->device, &error_msg)) goto fail;



    

    av_new_packet(pkt, nb_samples*ad->sample_step);

    pkt->pts = av_gettime();



    

    alcCaptureSamples(ad->device, pkt->data, nb_samples);

    if (error = al_get_error(ad->device, &error_msg)) goto fail;



    return pkt->size;

fail:

    

    if (pkt->data)

        av_destruct_packet(pkt);

    if (error_msg)

        av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg);

    return error;

}

static int FUNC_0(AVFormatContext* VAR_0, AVPacket *VAR_1)

{

    al_data *ad = VAR_0->priv_data;

    int VAR_2=0;

    const char *VAR_3;

    ALCint nb_samples;



    

    alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);

    if (VAR_2 = al_get_error(ad->device, &VAR_3)) goto fail;



    

    av_new_packet(VAR_1, nb_samples*ad->sample_step);

    VAR_1->pts = av_gettime();



    

    alcCaptureSamples(ad->device, VAR_1->data, nb_samples);

    if (VAR_2 = al_get_error(ad->device, &VAR_3)) goto fail;



    return VAR_1->size;

fail:

    

    if (VAR_1->data)

        av_destruct_packet(VAR_1);

    if (VAR_3)

        av_log(VAR_0, AV_LOG_ERROR, "Error: %s\n", VAR_3);

    return VAR_2;

}

static int FUNC_0(AVFormatContext* VAR_0, AVPacket *VAR_1)
{ al_data *ad = VAR_0->priv_data; int VAR_2=0; const char *VAR_3; ALCint nb_samples; alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples); if (VAR_2 = al_get_error(ad->device, &VAR_3)) goto fail; av_new_packet(VAR_1, nb_samples*ad->sample_step); VAR_1->pts = av_gettime(); alcCaptureSamples(ad->device, VAR_1->data, nb_samples); if (VAR_2 = al_get_error(ad->device, &VAR_3)) goto fail; return VAR_1->size; fail:
if (VAR_1->data)
av_destruct_packet(VAR_1); if (VAR_3)
av_log(VAR_0, AV_LOG_ERROR, "Error: %s\n", VAR_3); return VAR_2; }