static int qpa_init_in (HWVoiceIn *hw, audsettings_t *as)

{

    int error;

    static pa_sample_spec ss;

    audsettings_t obt_as = *as;

    PAVoiceIn *pa = (PAVoiceIn *) hw;



    ss.format = audfmt_to_pa (as->fmt, as->endianness);

    ss.channels = as->nchannels;

    ss.rate = as->freq;



    obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);



    pa->s = pa_simple_new (

        conf.server,

        "qemu",

        PA_STREAM_RECORD,

        conf.source,

        "pcm.capture",

        &ss,

        NULL,                   /* channel map */

        NULL,                   /* buffering attributes */

        &error

        );

    if (!pa->s) {

        qpa_logerr (error, "pa_simple_new for capture failed\n");

        goto fail1;

    }



    audio_pcm_init_info (&hw->info, &obt_as);

    hw->samples = conf.samples;

    pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);

    if (!pa->pcm_buf) {

        dolog ("Could not allocate buffer (%d bytes)\n",

               hw->samples << hw->info.shift);

        goto fail2;

    }



    if (audio_pt_init (&pa->pt, qpa_thread_in, hw, AUDIO_CAP, AUDIO_FUNC)) {

        goto fail3;

    }



    return 0;



 fail3:

    free (pa->pcm_buf);

    pa->pcm_buf = NULL;

 fail2:

    pa_simple_free (pa->s);

    pa->s = NULL;

 fail1:

    return -1;

}

static int qpa_init_in (HWVoiceIn *hw, audsettings_t *as)

{

    int error;

    static pa_sample_spec ss;

    audsettings_t obt_as = *as;

    PAVoiceIn *pa = (PAVoiceIn *) hw;



    ss.format = audfmt_to_pa (as->fmt, as->endianness);

    ss.channels = as->nchannels;

    ss.rate = as->freq;



    obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);



    pa->s = pa_simple_new (

        conf.server,

        "qemu",

        PA_STREAM_RECORD,

        conf.source,

        "pcm.capture",

        &ss,

        NULL,                   

        NULL,                   

        &error

        );

    if (!pa->s) {

        qpa_logerr (error, "pa_simple_new for capture failed\n");

        goto fail1;

    }



    audio_pcm_init_info (&hw->info, &obt_as);

    hw->samples = conf.samples;

    pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);

    if (!pa->pcm_buf) {

        dolog ("Could not allocate buffer (%d bytes)\n",

               hw->samples << hw->info.shift);

        goto fail2;

    }



    if (audio_pt_init (&pa->pt, qpa_thread_in, hw, AUDIO_CAP, AUDIO_FUNC)) {

        goto fail3;

    }



    return 0;



 fail3:

    free (pa->pcm_buf);

    pa->pcm_buf = NULL;

 fail2:

    pa_simple_free (pa->s);

    pa->s = NULL;

 fail1:

    return -1;

}

static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)

{

    int VAR_2;

    static pa_sample_spec VAR_3;

    audsettings_t obt_as = *VAR_1;

    PAVoiceIn *pa = (PAVoiceIn *) VAR_0;



    VAR_3.format = audfmt_to_pa (VAR_1->fmt, VAR_1->endianness);

    VAR_3.channels = VAR_1->nchannels;

    VAR_3.rate = VAR_1->freq;



    obt_as.fmt = pa_to_audfmt (VAR_3.format, &obt_as.endianness);



    pa->s = pa_simple_new (

        conf.server,

        "qemu",

        PA_STREAM_RECORD,

        conf.source,

        "pcm.capture",

        &VAR_3,

        NULL,                   

        NULL,                   

        &VAR_2

        );

    if (!pa->s) {

        qpa_logerr (VAR_2, "pa_simple_new for capture failed\n");

        goto fail1;

    }



    audio_pcm_init_info (&VAR_0->info, &obt_as);

    VAR_0->samples = conf.samples;

    pa->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift);

    if (!pa->pcm_buf) {

        dolog ("Could not allocate buffer (%d bytes)\n",

               VAR_0->samples << VAR_0->info.shift);

        goto fail2;

    }



    if (audio_pt_init (&pa->pt, qpa_thread_in, VAR_0, AUDIO_CAP, AUDIO_FUNC)) {

        goto fail3;

    }



    return 0;



 fail3:

    free (pa->pcm_buf);

    pa->pcm_buf = NULL;

 fail2:

    pa_simple_free (pa->s);

    pa->s = NULL;

 fail1:

    return -1;

}

static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)
{ int VAR_2; static pa_sample_spec VAR_3; audsettings_t obt_as = *VAR_1; PAVoiceIn *pa = (PAVoiceIn *) VAR_0; VAR_3.format = audfmt_to_pa (VAR_1->fmt, VAR_1->endianness); VAR_3.channels = VAR_1->nchannels; VAR_3.rate = VAR_1->freq; obt_as.fmt = pa_to_audfmt (VAR_3.format, &obt_as.endianness); pa->s = pa_simple_new (
conf.server,
"qemu",
PA_STREAM_RECORD,
conf.source,
"pcm.capture",
&VAR_3,
NULL,
NULL,
&VAR_2
); if (!pa->s) { qpa_logerr (VAR_2, "pa_simple_new for capture failed\n"); goto fail1; } audio_pcm_init_info (&VAR_0->info, &obt_as); VAR_0->samples = conf.samples; pa->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift); if (!pa->pcm_buf) { dolog ("Could not allocate buffer (%d bytes)\n",
VAR_0->samples << VAR_0->info.shift); goto fail2; } if (audio_pt_init (&pa->pt, qpa_thread_in, VAR_0, AUDIO_CAP, AUDIO_FUNC)) { goto fail3; } return 0; fail3:
free (pa->pcm_buf); pa->pcm_buf = NULL; fail2:
pa_simple_free (pa->s); pa->s = NULL; fail1:
return -1; }