static int oss_run_in (HWVoiceIn *hw)

{

    OSSVoiceIn *oss = (OSSVoiceIn *) hw;

    int hwshift = hw->info.shift;

    int i;

    int live = audio_pcm_hw_get_live_in (hw);

    int dead = hw->samples - live;

    size_t read_samples = 0;

    struct {

        int add;

        int len;

    } bufs[2] = {

        { hw->wpos, 0 },

        { 0, 0 }

    };



    if (!dead) {

        return 0;

    }



    if (hw->wpos + dead > hw->samples) {

        bufs[0].len = (hw->samples - hw->wpos) << hwshift;

        bufs[1].len = (dead - (hw->samples - hw->wpos)) << hwshift;

    }

    else {

        bufs[0].len = dead << hwshift;

    }





    for (i = 0; i < 2; ++i) {

        ssize_t nread;



        if (bufs[i].len) {

            void *p = advance (oss->pcm_buf, bufs[i].add << hwshift);

            nread = read (oss->fd, p, bufs[i].len);



            if (nread > 0) {

                if (nread & hw->info.align) {

                    dolog ("warning: Misaligned read %zd (requested %d), "

                           "alignment %d\n", nread, bufs[i].add << hwshift,

                           hw->info.align + 1);

                }

                read_samples += nread >> hwshift;

                hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift,

                          &nominal_volume);

            }



            if (bufs[i].len - nread) {

                if (nread == -1) {

                    switch (errno) {

                    case EINTR:

                    case EAGAIN:

                        break;

                    default:

                        oss_logerr (

                            errno,

                            "Failed to read %d bytes of audio (to %p)\n",

                            bufs[i].len, p

                            );

                        break;

                    }

                }

                break;

            }

        }

    }



    hw->wpos = (hw->wpos + read_samples) % hw->samples;

    return read_samples;

}

static int oss_run_in (HWVoiceIn *hw)

{

    OSSVoiceIn *oss = (OSSVoiceIn *) hw;

    int hwshift = hw->info.shift;

    int i;

    int live = audio_pcm_hw_get_live_in (hw);

    int dead = hw->samples - live;

    size_t read_samples = 0;

    struct {

        int add;

        int len;

    } bufs[2] = {

        { hw->wpos, 0 },

        { 0, 0 }

    };



    if (!dead) {

        return 0;

    }



    if (hw->wpos + dead > hw->samples) {

        bufs[0].len = (hw->samples - hw->wpos) << hwshift;

        bufs[1].len = (dead - (hw->samples - hw->wpos)) << hwshift;

    }

    else {

        bufs[0].len = dead << hwshift;

    }





    for (i = 0; i < 2; ++i) {

        ssize_t nread;



        if (bufs[i].len) {

            void *p = advance (oss->pcm_buf, bufs[i].add << hwshift);

            nread = read (oss->fd, p, bufs[i].len);



            if (nread > 0) {

                if (nread & hw->info.align) {

                    dolog ("warning: Misaligned read %zd (requested %d), "

                           "alignment %d\n", nread, bufs[i].add << hwshift,

                           hw->info.align + 1);

                }

                read_samples += nread >> hwshift;

                hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift,

                          &nominal_volume);

            }



            if (bufs[i].len - nread) {

                if (nread == -1) {

                    switch (errno) {

                    case EINTR:

                    case EAGAIN:

                        break;

                    default:

                        oss_logerr (

                            errno,

                            "Failed to read %d bytes of audio (to %p)\n",

                            bufs[i].len, p

                            );

                        break;

                    }

                }

                break;

            }

        }

    }



    hw->wpos = (hw->wpos + read_samples) % hw->samples;

    return read_samples;

}

static int FUNC_0 (HWVoiceIn *VAR_0)

{

    OSSVoiceIn *oss = (OSSVoiceIn *) VAR_0;

    int VAR_1 = VAR_0->info.shift;

    int VAR_2;

    int VAR_3 = audio_pcm_hw_get_live_in (VAR_0);

    int VAR_4 = VAR_0->samples - VAR_3;

    size_t read_samples = 0;

    struct {

        int add;

        int len;

    } VAR_5[2] = {

        { VAR_0->wpos, 0 },

        { 0, 0 }

    };



    if (!VAR_4) {

        return 0;

    }



    if (VAR_0->wpos + VAR_4 > VAR_0->samples) {

        VAR_5[0].len = (VAR_0->samples - VAR_0->wpos) << VAR_1;

        VAR_5[1].len = (VAR_4 - (VAR_0->samples - VAR_0->wpos)) << VAR_1;

    }

    else {

        VAR_5[0].len = VAR_4 << VAR_1;

    }





    for (VAR_2 = 0; VAR_2 < 2; ++VAR_2) {

        ssize_t nread;



        if (VAR_5[VAR_2].len) {

            void *VAR_6 = advance (oss->pcm_buf, VAR_5[VAR_2].add << VAR_1);

            nread = read (oss->fd, VAR_6, VAR_5[VAR_2].len);



            if (nread > 0) {

                if (nread & VAR_0->info.align) {

                    dolog ("warning: Misaligned read %zd (requested %d), "

                           "alignment %d\n", nread, VAR_5[VAR_2].add << VAR_1,

                           VAR_0->info.align + 1);

                }

                read_samples += nread >> VAR_1;

                VAR_0->conv (VAR_0->conv_buf + VAR_5[VAR_2].add, VAR_6, nread >> VAR_1,

                          &nominal_volume);

            }



            if (VAR_5[VAR_2].len - nread) {

                if (nread == -1) {

                    switch (errno) {

                    case EINTR:

                    case EAGAIN:

                        break;

                    default:

                        oss_logerr (

                            errno,

                            "Failed to read %d bytes of audio (to %VAR_6)\n",

                            VAR_5[VAR_2].len, VAR_6

                            );

                        break;

                    }

                }

                break;

            }

        }

    }



    VAR_0->wpos = (VAR_0->wpos + read_samples) % VAR_0->samples;

    return read_samples;

}

static int FUNC_0 (HWVoiceIn *VAR_0)
{ OSSVoiceIn *oss = (OSSVoiceIn *) VAR_0; int VAR_1 = VAR_0->info.shift; int VAR_2; int VAR_3 = audio_pcm_hw_get_live_in (VAR_0); int VAR_4 = VAR_0->samples - VAR_3; size_t read_samples = 0; struct { int add; int len; } VAR_5[2] = { { VAR_0->wpos, 0 }, { 0, 0 } }; if (!VAR_4) { return 0; } if (VAR_0->wpos + VAR_4 > VAR_0->samples) { VAR_5[0].len = (VAR_0->samples - VAR_0->wpos) << VAR_1; VAR_5[1].len = (VAR_4 - (VAR_0->samples - VAR_0->wpos)) << VAR_1; } else { VAR_5[0].len = VAR_4 << VAR_1; } for (VAR_2 = 0; VAR_2 < 2; ++VAR_2) { ssize_t nread; if (VAR_5[VAR_2].len) { void *VAR_6 = advance (oss->pcm_buf, VAR_5[VAR_2].add << VAR_1); nread = read (oss->fd, VAR_6, VAR_5[VAR_2].len); if (nread > 0) { if (nread & VAR_0->info.align) { dolog ("warning: Misaligned read %zd (requested %d), "
"alignment %d\n", nread, VAR_5[VAR_2].add << VAR_1,
VAR_0->info.align + 1); } read_samples += nread >> VAR_1; VAR_0->conv (VAR_0->conv_buf + VAR_5[VAR_2].add, VAR_6, nread >> VAR_1,
&nominal_volume); } if (VAR_5[VAR_2].len - nread) { if (nread == -1) { switch (errno) { case EINTR:
case EAGAIN:
break; default:
oss_logerr (
errno,
"Failed to read %d bytes of audio (to %VAR_6)\n",
VAR_5[VAR_2].len, VAR_6
); break; } } break; } } } VAR_0->wpos = (VAR_0->wpos + read_samples) % VAR_0->samples; return read_samples; }