oss: Simplify mmap code

Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
malc 2009-09-13 08:47:30 +04:00
parent 0b3652bc70
commit 54762b7339

View File

@ -45,7 +45,6 @@ typedef struct OSSVoiceOut {
int nfrags; int nfrags;
int fragsize; int fragsize;
int mmapped; int mmapped;
int old_optr;
} OSSVoiceOut; } OSSVoiceOut;
typedef struct OSSVoiceIn { typedef struct OSSVoiceIn {
@ -54,7 +53,6 @@ typedef struct OSSVoiceIn {
int fd; int fd;
int nfrags; int nfrags;
int fragsize; int fragsize;
int old_optr;
} OSSVoiceIn; } OSSVoiceIn;
static struct { static struct {
@ -366,7 +364,7 @@ static int oss_run_out (HWVoiceOut *hw)
bufsize = hw->samples << hw->info.shift; bufsize = hw->samples << hw->info.shift;
if (oss->mmapped) { if (oss->mmapped) {
int bytes; int bytes, pos;
err = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo); err = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo);
if (err < 0) { if (err < 0) {
@ -374,20 +372,8 @@ static int oss_run_out (HWVoiceOut *hw)
return 0; return 0;
} }
if (cntinfo.ptr == oss->old_optr) { pos = hw->rpos << hw->info.shift;
if (abs (hw->samples - live) < 64) { bytes = audio_ring_dist (cntinfo.ptr, pos, bufsize);
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;
}
decr = audio_MIN (bytes >> hw->info.shift, live); decr = audio_MIN (bytes >> hw->info.shift, live);
} }
else { else {
@ -462,9 +448,6 @@ static int oss_run_out (HWVoiceOut *hw)
rpos = (rpos + convert_samples) % hw->samples; rpos = (rpos + convert_samples) % hw->samples;
samples -= convert_samples; samples -= convert_samples;
} }
if (oss->mmapped) {
oss->old_optr = cntinfo.ptr;
}
hw->rpos = rpos; hw->rpos = rpos;
return decr; return decr;
@ -550,7 +533,8 @@ static int oss_init_out (HWVoiceOut *hw, struct audsettings *as)
if (oss->pcm_buf == MAP_FAILED) { if (oss->pcm_buf == MAP_FAILED) {
oss_logerr (errno, "Failed to map %d bytes of DAC\n", oss_logerr (errno, "Failed to map %d bytes of DAC\n",
hw->samples << hw->info.shift); hw->samples << hw->info.shift);
} else { }
else {
int err; int err;
int trig = 0; int trig = 0;
if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) {
@ -749,7 +733,6 @@ static int oss_run_in (HWVoiceIn *hw)
bufs[0].len = dead << hwshift; bufs[0].len = dead << hwshift;
} }
for (i = 0; i < 2; ++i) { for (i = 0; i < 2; ++i) {
ssize_t nread; ssize_t nread;