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

{

    OSSVoiceIn *oss = (OSSVoiceIn *) hw;

    struct oss_params req, obt;

    int endianness;

    int err;

    int fd;

    audfmt_e effective_fmt;

    audsettings_t obt_as;



    oss->fd = -1;



    req.fmt = aud_to_ossfmt (as->fmt);

    req.freq = as->freq;

    req.nchannels = as->nchannels;

    req.fragsize = conf.fragsize;

    req.nfrags = conf.nfrags;

    if (oss_open (1, &req, &obt, &fd)) {

        return -1;

    }



    err = oss_to_audfmt (obt.fmt, &effective_fmt, &endianness);

    if (err) {

        oss_anal_close (&fd);

        return -1;

    }



    obt_as.freq = obt.freq;

    obt_as.nchannels = obt.nchannels;

    obt_as.fmt = effective_fmt;

    obt_as.endianness = endianness;



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

    oss->nfrags = obt.nfrags;

    oss->fragsize = obt.fragsize;



    if (obt.nfrags * obt.fragsize & hw->info.align) {

        dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n",

               obt.nfrags * obt.fragsize, hw->info.align + 1);

    }



    hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;

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

    if (!oss->pcm_buf) {

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

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

        oss_anal_close (&fd);

        return -1;

    }



    oss->fd = fd;

    return 0;

}

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

{

    OSSVoiceIn *oss = (OSSVoiceIn *) hw;

    struct oss_params req, obt;

    int endianness;

    int err;

    int fd;

    audfmt_e effective_fmt;

    audsettings_t obt_as;



    oss->fd = -1;



    req.fmt = aud_to_ossfmt (as->fmt);

    req.freq = as->freq;

    req.nchannels = as->nchannels;

    req.fragsize = conf.fragsize;

    req.nfrags = conf.nfrags;

    if (oss_open (1, &req, &obt, &fd)) {

        return -1;

    }



    err = oss_to_audfmt (obt.fmt, &effective_fmt, &endianness);

    if (err) {

        oss_anal_close (&fd);

        return -1;

    }



    obt_as.freq = obt.freq;

    obt_as.nchannels = obt.nchannels;

    obt_as.fmt = effective_fmt;

    obt_as.endianness = endianness;



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

    oss->nfrags = obt.nfrags;

    oss->fragsize = obt.fragsize;



    if (obt.nfrags * obt.fragsize & hw->info.align) {

        dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n",

               obt.nfrags * obt.fragsize, hw->info.align + 1);

    }



    hw->samples = (obt.nfrags * obt.fragsize) >> hw->info.shift;

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

    if (!oss->pcm_buf) {

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

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

        oss_anal_close (&fd);

        return -1;

    }



    oss->fd = fd;

    return 0;

}

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

{

    OSSVoiceIn *oss = (OSSVoiceIn *) VAR_0;

    struct oss_params VAR_2, VAR_3;

    int VAR_4;

    int VAR_5;

    int VAR_6;

    audfmt_e effective_fmt;

    audsettings_t obt_as;



    oss->VAR_6 = -1;



    VAR_2.fmt = aud_to_ossfmt (VAR_1->fmt);

    VAR_2.freq = VAR_1->freq;

    VAR_2.nchannels = VAR_1->nchannels;

    VAR_2.fragsize = conf.fragsize;

    VAR_2.nfrags = conf.nfrags;

    if (oss_open (1, &VAR_2, &VAR_3, &VAR_6)) {

        return -1;

    }



    VAR_5 = oss_to_audfmt (VAR_3.fmt, &effective_fmt, &VAR_4);

    if (VAR_5) {

        oss_anal_close (&VAR_6);

        return -1;

    }



    obt_as.freq = VAR_3.freq;

    obt_as.nchannels = VAR_3.nchannels;

    obt_as.fmt = effective_fmt;

    obt_as.VAR_4 = VAR_4;



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

    oss->nfrags = VAR_3.nfrags;

    oss->fragsize = VAR_3.fragsize;



    if (VAR_3.nfrags * VAR_3.fragsize & VAR_0->info.align) {

        dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n",

               VAR_3.nfrags * VAR_3.fragsize, VAR_0->info.align + 1);

    }



    VAR_0->samples = (VAR_3.nfrags * VAR_3.fragsize) >> VAR_0->info.shift;

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

    if (!oss->pcm_buf) {

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

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

        oss_anal_close (&VAR_6);

        return -1;

    }



    oss->VAR_6 = VAR_6;

    return 0;

}

static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)
{ OSSVoiceIn *oss = (OSSVoiceIn *) VAR_0; struct oss_params VAR_2, VAR_3; int VAR_4; int VAR_5; int VAR_6; audfmt_e effective_fmt; audsettings_t obt_as; oss->VAR_6 = -1; VAR_2.fmt = aud_to_ossfmt (VAR_1->fmt); VAR_2.freq = VAR_1->freq; VAR_2.nchannels = VAR_1->nchannels; VAR_2.fragsize = conf.fragsize; VAR_2.nfrags = conf.nfrags; if (oss_open (1, &VAR_2, &VAR_3, &VAR_6)) { return -1; } VAR_5 = oss_to_audfmt (VAR_3.fmt, &effective_fmt, &VAR_4); if (VAR_5) { oss_anal_close (&VAR_6); return -1; } obt_as.freq = VAR_3.freq; obt_as.nchannels = VAR_3.nchannels; obt_as.fmt = effective_fmt; obt_as.VAR_4 = VAR_4; audio_pcm_init_info (&VAR_0->info, &obt_as); oss->nfrags = VAR_3.nfrags; oss->fragsize = VAR_3.fragsize; if (VAR_3.nfrags * VAR_3.fragsize & VAR_0->info.align) { dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n",
VAR_3.nfrags * VAR_3.fragsize, VAR_0->info.align + 1); } VAR_0->samples = (VAR_3.nfrags * VAR_3.fragsize) >> VAR_0->info.shift; oss->pcm_buf = audio_calloc (AUDIO_FUNC, VAR_0->samples, 1 << VAR_0->info.shift); if (!oss->pcm_buf) { dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
VAR_0->samples, 1 << VAR_0->info.shift); oss_anal_close (&VAR_6); return -1; } oss->VAR_6 = VAR_6; return 0; }