static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)

{

    AudioData *s = s1->priv_data;

    AVStream *st;

    int ret;



    if (!ap || ap->sample_rate <= 0 || ap->channels <= 0)

        return -1;



    st = av_new_stream(s1, 0);

    if (!st) {

        return -ENOMEM;

    }

    s->sample_rate = ap->sample_rate;

    s->channels = ap->channels;



    ret = audio_open(s, 0, ap->device);

    if (ret < 0) {

        av_free(st);

        return AVERROR_IO;

    }



    /* take real parameters */

    st->codec->codec_type = CODEC_TYPE_AUDIO;

    st->codec->codec_id = s->codec_id;

    st->codec->sample_rate = s->sample_rate;

    st->codec->channels = s->channels;



    av_set_pts_info(st, 64, 1, 1000000);  /* 64 bits pts in us */

    return 0;

}

static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)

{

    AudioData *s = s1->priv_data;

    AVStream *st;

    int ret;



    if (!ap || ap->sample_rate <= 0 || ap->channels <= 0)

        return -1;



    st = av_new_stream(s1, 0);

    if (!st) {

        return -ENOMEM;

    }

    s->sample_rate = ap->sample_rate;

    s->channels = ap->channels;



    ret = audio_open(s, 0, ap->device);

    if (ret < 0) {

        av_free(st);

        return AVERROR_IO;

    }



    

    st->codec->codec_type = CODEC_TYPE_AUDIO;

    st->codec->codec_id = s->codec_id;

    st->codec->sample_rate = s->sample_rate;

    st->codec->channels = s->channels;



    av_set_pts_info(st, 64, 1, 1000000);  

    return 0;

}

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

{

    AudioData *s = VAR_0->priv_data;

    AVStream *st;

    int VAR_2;



    if (!VAR_1 || VAR_1->sample_rate <= 0 || VAR_1->channels <= 0)

        return -1;



    st = av_new_stream(VAR_0, 0);

    if (!st) {

        return -ENOMEM;

    }

    s->sample_rate = VAR_1->sample_rate;

    s->channels = VAR_1->channels;



    VAR_2 = audio_open(s, 0, VAR_1->device);

    if (VAR_2 < 0) {

        av_free(st);

        return AVERROR_IO;

    }



    

    st->codec->codec_type = CODEC_TYPE_AUDIO;

    st->codec->codec_id = s->codec_id;

    st->codec->sample_rate = s->sample_rate;

    st->codec->channels = s->channels;



    av_set_pts_info(st, 64, 1, 1000000);  

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)
{ AudioData *s = VAR_0->priv_data; AVStream *st; int VAR_2; if (!VAR_1 || VAR_1->sample_rate <= 0 || VAR_1->channels <= 0)
return -1; st = av_new_stream(VAR_0, 0); if (!st) { return -ENOMEM; } s->sample_rate = VAR_1->sample_rate; s->channels = VAR_1->channels; VAR_2 = audio_open(s, 0, VAR_1->device); if (VAR_2 < 0) { av_free(st); return AVERROR_IO; } st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_id = s->codec_id; st->codec->sample_rate = s->sample_rate; st->codec->channels = s->channels; av_set_pts_info(st, 64, 1, 1000000); return 0; }