static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)

{

    int error;

    static pa_sample_spec ss;

    static pa_buffer_attr ba;

    struct audsettings obt_as = *as;

    PAVoiceOut *pa = (PAVoiceOut *) hw;



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

    ss.channels = as->nchannels;

    ss.rate = as->freq;



    /*

     * qemu audio tick runs at 250 Hz (by default), so processing

     * data chunks worth 4 ms of sound should be a good fit.

     */

    ba.tlength = pa_usec_to_bytes (4 * 1000, &ss);

    ba.minreq = pa_usec_to_bytes (2 * 1000, &ss);

    ba.maxlength = -1;

    ba.prebuf = -1;



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



    pa->s = pa_simple_new (

        conf.server,

        "qemu",

        PA_STREAM_PLAYBACK,

        conf.sink,

        "pcm.playback",

        &ss,

        NULL,                   /* channel map */

        &ba,                    /* buffering attributes */

        &error

        );

    if (!pa->s) {

        qpa_logerr (error, "pa_simple_new for playback 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);

    pa->rpos = hw->rpos;

    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_out, hw, AUDIO_CAP, AUDIO_FUNC)) {

        goto fail3;

    }



    return 0;



 fail3:

    g_free (pa->pcm_buf);

    pa->pcm_buf = NULL;

 fail2:

    pa_simple_free (pa->s);

    pa->s = NULL;

 fail1:

    return -1;

}

static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)

{

    int error;

    static pa_sample_spec ss;

    static pa_buffer_attr ba;

    struct audsettings obt_as = *as;

    PAVoiceOut *pa = (PAVoiceOut *) hw;



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

    ss.channels = as->nchannels;

    ss.rate = as->freq;



    







    ba.tlength = pa_usec_to_bytes (4 * 1000, &ss);

    ba.minreq = pa_usec_to_bytes (2 * 1000, &ss);

    ba.maxlength = -1;

    ba.prebuf = -1;



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



    pa->s = pa_simple_new (

        conf.server,

        "qemu",

        PA_STREAM_PLAYBACK,

        conf.sink,

        "pcm.playback",

        &ss,

        NULL,                   

        &ba,                    

        &error

        );

    if (!pa->s) {

        qpa_logerr (error, "pa_simple_new for playback 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);

    pa->rpos = hw->rpos;

    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_out, hw, AUDIO_CAP, AUDIO_FUNC)) {

        goto fail3;

    }



    return 0;



 fail3:

    g_free (pa->pcm_buf);

    pa->pcm_buf = NULL;

 fail2:

    pa_simple_free (pa->s);

    pa->s = NULL;

 fail1:

    return -1;

}

    pa->s = pa_simple_new (         conf.server,         conf.sink,     if (!pa->s) {     hw->samples = conf.samples;     pa_simple_free (pa->s);     pa->s = NULL;     pa->s = pa_simple_new (         conf.server,     if (!pa->s) {     hw->samples = conf.samples;     pa_simple_free (pa->s);     pa->s = NULL;
static int FUNC_0 (HWVoiceOut *VAR_0, struct audsettings *VAR_1)

{

    int VAR_2;

    static pa_sample_spec VAR_3;

    static pa_buffer_attr VAR_4;

    struct audsettings VAR_5 = *VAR_1;

    PAVoiceOut *pa = (PAVoiceOut *) 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;



    







    VAR_4.tlength = pa_usec_to_bytes (4 * 1000, &VAR_3);

    VAR_4.minreq = pa_usec_to_bytes (2 * 1000, &VAR_3);

    VAR_4.maxlength = -1;

    VAR_4.prebuf = -1;



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



    pa->s = pa_simple_new (

        conf.server,

        "qemu",

        PA_STREAM_PLAYBACK,

        conf.sink,

        "pcm.playback",

        &VAR_3,

        NULL,                   

        &VAR_4,                    

        &VAR_2

        );

    if (!pa->s) {

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

        goto fail1;

    }



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

    VAR_0->samples = conf.samples;

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

    pa->rpos = VAR_0->rpos;

    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_out, VAR_0, AUDIO_CAP, AUDIO_FUNC)) {

        goto fail3;

    }



    return 0;



 fail3:

    g_free (pa->pcm_buf);

    pa->pcm_buf = NULL;

 fail2:

    pa_simple_free (pa->s);

    pa->s = NULL;

 fail1:

    return -1;

}

static int FUNC_0 (HWVoiceOut *VAR_0, struct audsettings *VAR_1)
{ int VAR_2; static pa_sample_spec VAR_3; static pa_buffer_attr VAR_4; struct audsettings VAR_5 = *VAR_1; PAVoiceOut *pa = (PAVoiceOut *) 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; VAR_4.tlength = pa_usec_to_bytes (4 * 1000, &VAR_3); VAR_4.minreq = pa_usec_to_bytes (2 * 1000, &VAR_3); VAR_4.maxlength = -1; VAR_4.prebuf = -1; VAR_5.fmt = pa_to_audfmt (VAR_3.format, &VAR_5.endianness); pa->s = pa_simple_new (
conf.server,
"qemu",
PA_STREAM_PLAYBACK,
conf.sink,
"pcm.playback",
&VAR_3,
NULL,
&VAR_4,
&VAR_2
); if (!pa->s) { qpa_logerr (VAR_2, "pa_simple_new for playback failed\n"); goto fail1; } audio_pcm_init_info (&VAR_0->info, &VAR_5); VAR_0->samples = conf.samples; pa->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift); pa->rpos = VAR_0->rpos; 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_out, VAR_0, AUDIO_CAP, AUDIO_FUNC)) { goto fail3; } return 0; fail3:
g_free (pa->pcm_buf); pa->pcm_buf = NULL; fail2:
pa_simple_free (pa->s); pa->s = NULL; fail1:
return -1; }