int nfrags;
int fragsize;
int mmapped;
- int old_optr;
} OSSVoiceOut;
typedef struct OSSVoiceIn {
int fd;
int nfrags;
int fragsize;
- int old_optr;
} OSSVoiceIn;
static struct {
bufsize = hw->samples << hw->info.shift;
if (oss->mmapped) {
- int bytes;
+ int bytes, pos;
err = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo);
if (err < 0) {
return 0;
}
- if (cntinfo.ptr == oss->old_optr) {
- if (abs (hw->samples - live) < 64) {
- dolog ("warning: Overrun\n");
- }
- return 0;
- }
-
- if (cntinfo.ptr > oss->old_optr) {
- bytes = cntinfo.ptr - oss->old_optr;
- }
- else {
- bytes = bufsize + cntinfo.ptr - oss->old_optr;
- }
-
+ pos = hw->rpos << hw->info.shift;
+ bytes = audio_ring_dist (cntinfo.ptr, pos, bufsize);
decr = audio_MIN (bytes >> hw->info.shift, live);
}
else {
rpos = (rpos + convert_samples) % hw->samples;
samples -= convert_samples;
}
- if (oss->mmapped) {
- oss->old_optr = cntinfo.ptr;
- }
hw->rpos = rpos;
return decr;
if (oss->pcm_buf == MAP_FAILED) {
oss_logerr (errno, "Failed to map %d bytes of DAC\n",
hw->samples << hw->info.shift);
- } else {
+ }
+ else {
int err;
int trig = 0;
if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
bufs[0].len = dead << hwshift;
}
-
for (i = 0; i < 2; ++i) {
ssize_t nread;