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

{

    ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;

    struct alsa_params_req req;

    struct alsa_params_obt obt;

    snd_pcm_t *handle;

    struct audsettings obt_as;



    req.fmt = aud_to_alsafmt (as->fmt, as->endianness);

    req.freq = as->freq;

    req.nchannels = as->nchannels;

    req.period_size = conf.period_size_out;

    req.buffer_size = conf.buffer_size_out;

    req.size_in_usec = conf.size_in_usec_out;

    req.override_mask =

        (conf.period_size_out_overridden ? 1 : 0) |

        (conf.buffer_size_out_overridden ? 2 : 0);



    if (alsa_open (0, &req, &obt, &handle)) {

        return -1;

    }



    obt_as.freq = obt.freq;

    obt_as.nchannels = obt.nchannels;

    obt_as.fmt = obt.fmt;

    obt_as.endianness = obt.endianness;



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

    hw->samples = obt.samples;



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

    if (!alsa->pcm_buf) {

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

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

        alsa_anal_close1 (&handle);

        return -1;

    }



    alsa->handle = handle;

    return 0;

}

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

{

    ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;

    struct alsa_params_req req;

    struct alsa_params_obt obt;

    snd_pcm_t *handle;

    struct audsettings obt_as;



    req.fmt = aud_to_alsafmt (as->fmt, as->endianness);

    req.freq = as->freq;

    req.nchannels = as->nchannels;

    req.period_size = conf.period_size_out;

    req.buffer_size = conf.buffer_size_out;

    req.size_in_usec = conf.size_in_usec_out;

    req.override_mask =

        (conf.period_size_out_overridden ? 1 : 0) |

        (conf.buffer_size_out_overridden ? 2 : 0);



    if (alsa_open (0, &req, &obt, &handle)) {

        return -1;

    }



    obt_as.freq = obt.freq;

    obt_as.nchannels = obt.nchannels;

    obt_as.fmt = obt.fmt;

    obt_as.endianness = obt.endianness;



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

    hw->samples = obt.samples;



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

    if (!alsa->pcm_buf) {

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

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

        alsa_anal_close1 (&handle);

        return -1;

    }



    alsa->handle = handle;

    return 0;

}

static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
static int FUNC_0 (HWVoiceOut *VAR_0, struct audsettings *VAR_1)

{

    ALSAVoiceOut *alsa = (ALSAVoiceOut *) VAR_0;

    struct alsa_params_req VAR_2;

    struct alsa_params_obt VAR_3;

    snd_pcm_t *handle;

    struct audsettings VAR_4;



    VAR_2.fmt = aud_to_alsafmt (VAR_1->fmt, VAR_1->endianness);

    VAR_2.freq = VAR_1->freq;

    VAR_2.nchannels = VAR_1->nchannels;

    VAR_2.period_size = conf.period_size_out;

    VAR_2.buffer_size = conf.buffer_size_out;

    VAR_2.size_in_usec = conf.size_in_usec_out;

    VAR_2.override_mask =

        (conf.period_size_out_overridden ? 1 : 0) |

        (conf.buffer_size_out_overridden ? 2 : 0);



    if (alsa_open (0, &VAR_2, &VAR_3, &handle)) {

        return -1;

    }



    VAR_4.freq = VAR_3.freq;

    VAR_4.nchannels = VAR_3.nchannels;

    VAR_4.fmt = VAR_3.fmt;

    VAR_4.endianness = VAR_3.endianness;



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

    VAR_0->samples = VAR_3.samples;



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

    if (!alsa->pcm_buf) {

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

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

        alsa_anal_close1 (&handle);

        return -1;

    }



    alsa->handle = handle;

    return 0;

}

static int FUNC_0 (HWVoiceOut *VAR_0, struct audsettings *VAR_1)
{ ALSAVoiceOut *alsa = (ALSAVoiceOut *) VAR_0; struct alsa_params_req VAR_2; struct alsa_params_obt VAR_3; snd_pcm_t *handle; struct audsettings VAR_4; VAR_2.fmt = aud_to_alsafmt (VAR_1->fmt, VAR_1->endianness); VAR_2.freq = VAR_1->freq; VAR_2.nchannels = VAR_1->nchannels; VAR_2.period_size = conf.period_size_out; VAR_2.buffer_size = conf.buffer_size_out; VAR_2.size_in_usec = conf.size_in_usec_out; VAR_2.override_mask =
(conf.period_size_out_overridden ? 1 : 0) |
(conf.buffer_size_out_overridden ? 2 : 0); if (alsa_open (0, &VAR_2, &VAR_3, &handle)) { return -1; } VAR_4.freq = VAR_3.freq; VAR_4.nchannels = VAR_3.nchannels; VAR_4.fmt = VAR_3.fmt; VAR_4.endianness = VAR_3.endianness; audio_pcm_init_info (&VAR_0->info, &VAR_4); VAR_0->samples = VAR_3.samples; alsa->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_3.samples, 1 << VAR_0->info.shift); if (!alsa->pcm_buf) { dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\n",
VAR_0->samples, 1 << VAR_0->info.shift); alsa_anal_close1 (&handle); return -1; } alsa->handle = handle; return 0; }