static void test_function(const TestStruct test_sample)

{

    int ret, i;

    void **output_data  = NULL;

    AVAudioFifo *afifo  = av_audio_fifo_alloc(test_sample.format, test_sample.nb_ch,

                                            test_sample.nb_samples_pch);

    if (!afifo) {

        ERROR("ERROR: av_audio_fifo_alloc returned NULL!");

    }

    ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample.nb_samples_pch, 0);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_write failed!");

    }

    printf("written: %d\n", ret);



    ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample.nb_samples_pch, 0);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_write failed!");

    }

    printf("written: %d\n", ret);

    printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo));



    ret = read_samples_from_audio_fifo(afifo, &output_data, test_sample.nb_samples_pch);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_read failed!");

    }

    printf("read: %d\n", ret);

    print_audio_bytes(&test_sample, output_data, ret);

    printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo));



    /* test av_audio_fifo_peek */

    ret = av_audio_fifo_peek(afifo, output_data, afifo->nb_samples);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_peek failed!");

    }

    printf("peek:\n");

    print_audio_bytes(&test_sample, output_data, ret);

    printf("\n");



    /* test av_audio_fifo_peek_at */

    printf("peek_at:\n");

    for (i = 0; i < afifo->nb_samples; ++i){

        ret = av_audio_fifo_peek_at(afifo, output_data, 1, i);

        if (ret < 0){

            ERROR("ERROR: av_audio_fifo_peek_at failed!");

        }

        printf("%d:\n", i);

        print_audio_bytes(&test_sample, output_data, ret);

    }

    printf("\n");



    /* test av_audio_fifo_drain */

    ret = av_audio_fifo_drain(afifo, afifo->nb_samples);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_drain failed!");

    }

    if (afifo->nb_samples){

        ERROR("drain failed to flush all samples in audio_fifo!");

    }



    /* deallocate */

    for (i = 0; i < afifo->nb_buffers; ++i){

        av_freep(&output_data[i]);

    }

    av_freep(&output_data);

    av_audio_fifo_free(afifo);

}

static void test_function(const TestStruct test_sample)

{

    int ret, i;

    void **output_data  = NULL;

    AVAudioFifo *afifo  = av_audio_fifo_alloc(test_sample.format, test_sample.nb_ch,

                                            test_sample.nb_samples_pch);

    if (!afifo) {

        ERROR("ERROR: av_audio_fifo_alloc returned NULL!");

    }

    ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample.nb_samples_pch, 0);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_write failed!");

    }

    printf("written: %d\n", ret);



    ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample.nb_samples_pch, 0);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_write failed!");

    }

    printf("written: %d\n", ret);

    printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo));



    ret = read_samples_from_audio_fifo(afifo, &output_data, test_sample.nb_samples_pch);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_read failed!");

    }

    printf("read: %d\n", ret);

    print_audio_bytes(&test_sample, output_data, ret);

    printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo));



    

    ret = av_audio_fifo_peek(afifo, output_data, afifo->nb_samples);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_peek failed!");

    }

    printf("peek:\n");

    print_audio_bytes(&test_sample, output_data, ret);

    printf("\n");



    

    printf("peek_at:\n");

    for (i = 0; i < afifo->nb_samples; ++i){

        ret = av_audio_fifo_peek_at(afifo, output_data, 1, i);

        if (ret < 0){

            ERROR("ERROR: av_audio_fifo_peek_at failed!");

        }

        printf("%d:\n", i);

        print_audio_bytes(&test_sample, output_data, ret);

    }

    printf("\n");



    

    ret = av_audio_fifo_drain(afifo, afifo->nb_samples);

    if (ret < 0){

        ERROR("ERROR: av_audio_fifo_drain failed!");

    }

    if (afifo->nb_samples){

        ERROR("drain failed to flush all samples in audio_fifo!");

    }



    

    for (i = 0; i < afifo->nb_buffers; ++i){

        av_freep(&output_data[i]);

    }

    av_freep(&output_data);

    av_audio_fifo_free(afifo);

}

    for (i = 0; i < afifo->nb_buffers; ++i){         av_freep(&output_data[i]);     av_freep(&output_data);
static void FUNC_0(const TestStruct VAR_0)

{

    int VAR_1, VAR_2;

    void **VAR_3  = NULL;

    AVAudioFifo *afifo  = av_audio_fifo_alloc(VAR_0.format, VAR_0.nb_ch,

                                            VAR_0.nb_samples_pch);

    if (!afifo) {

        ERROR("ERROR: av_audio_fifo_alloc returned NULL!");

    }

    VAR_1 = write_samples_to_audio_fifo(afifo, VAR_0, VAR_0.nb_samples_pch, 0);

    if (VAR_1 < 0){

        ERROR("ERROR: av_audio_fifo_write failed!");

    }

    printf("written: %d\n", VAR_1);



    VAR_1 = write_samples_to_audio_fifo(afifo, VAR_0, VAR_0.nb_samples_pch, 0);

    if (VAR_1 < 0){

        ERROR("ERROR: av_audio_fifo_write failed!");

    }

    printf("written: %d\n", VAR_1);

    printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo));



    VAR_1 = read_samples_from_audio_fifo(afifo, &VAR_3, VAR_0.nb_samples_pch);

    if (VAR_1 < 0){

        ERROR("ERROR: av_audio_fifo_read failed!");

    }

    printf("read: %d\n", VAR_1);

    print_audio_bytes(&VAR_0, VAR_3, VAR_1);

    printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo));



    

    VAR_1 = av_audio_fifo_peek(afifo, VAR_3, afifo->nb_samples);

    if (VAR_1 < 0){

        ERROR("ERROR: av_audio_fifo_peek failed!");

    }

    printf("peek:\n");

    print_audio_bytes(&VAR_0, VAR_3, VAR_1);

    printf("\n");



    

    printf("peek_at:\n");

    for (VAR_2 = 0; VAR_2 < afifo->nb_samples; ++VAR_2){

        VAR_1 = av_audio_fifo_peek_at(afifo, VAR_3, 1, VAR_2);

        if (VAR_1 < 0){

            ERROR("ERROR: av_audio_fifo_peek_at failed!");

        }

        printf("%d:\n", VAR_2);

        print_audio_bytes(&VAR_0, VAR_3, VAR_1);

    }

    printf("\n");



    

    VAR_1 = av_audio_fifo_drain(afifo, afifo->nb_samples);

    if (VAR_1 < 0){

        ERROR("ERROR: av_audio_fifo_drain failed!");

    }

    if (afifo->nb_samples){

        ERROR("drain failed to flush all samples in audio_fifo!");

    }



    

    for (VAR_2 = 0; VAR_2 < afifo->nb_buffers; ++VAR_2){

        av_freep(&VAR_3[VAR_2]);

    }

    av_freep(&VAR_3);

    av_audio_fifo_free(afifo);

}

static void FUNC_0(const TestStruct VAR_0)
{ int VAR_1, VAR_2; void **VAR_3  = NULL; AVAudioFifo *afifo  = av_audio_fifo_alloc(VAR_0.format, VAR_0.nb_ch,
VAR_0.nb_samples_pch); if (!afifo) { ERROR("ERROR: av_audio_fifo_alloc returned NULL!"); } VAR_1 = write_samples_to_audio_fifo(afifo, VAR_0, VAR_0.nb_samples_pch, 0); if (VAR_1 < 0){ ERROR("ERROR: av_audio_fifo_write failed!"); } printf("written: %d\n", VAR_1); VAR_1 = write_samples_to_audio_fifo(afifo, VAR_0, VAR_0.nb_samples_pch, 0); if (VAR_1 < 0){ ERROR("ERROR: av_audio_fifo_write failed!"); } printf("written: %d\n", VAR_1); printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo)); VAR_1 = read_samples_from_audio_fifo(afifo, &VAR_3, VAR_0.nb_samples_pch); if (VAR_1 < 0){ ERROR("ERROR: av_audio_fifo_read failed!"); } printf("read: %d\n", VAR_1); print_audio_bytes(&VAR_0, VAR_3, VAR_1); printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo)); VAR_1 = av_audio_fifo_peek(afifo, VAR_3, afifo->nb_samples); if (VAR_1 < 0){ ERROR("ERROR: av_audio_fifo_peek failed!"); } printf("peek:\n"); print_audio_bytes(&VAR_0, VAR_3, VAR_1); printf("\n"); printf("peek_at:\n"); for (VAR_2 = 0; VAR_2 < afifo->nb_samples; ++VAR_2){ VAR_1 = av_audio_fifo_peek_at(afifo, VAR_3, 1, VAR_2); if (VAR_1 < 0){ ERROR("ERROR: av_audio_fifo_peek_at failed!"); } printf("%d:\n", VAR_2); print_audio_bytes(&VAR_0, VAR_3, VAR_1); } printf("\n"); VAR_1 = av_audio_fifo_drain(afifo, afifo->nb_samples); if (VAR_1 < 0){ ERROR("ERROR: av_audio_fifo_drain failed!"); } if (afifo->nb_samples){ ERROR("drain failed to flush all samples in audio_fifo!"); } for (VAR_2 = 0; VAR_2 < afifo->nb_buffers; ++VAR_2){ av_freep(&VAR_3[VAR_2]); } av_freep(&VAR_3); av_audio_fifo_free(afifo); }