aboutsummaryrefslogtreecommitdiff
path: root/audio/ossaudio.c
diff options
context:
space:
mode:
authormalc <av1474@comtv.ru>2009-09-13 08:47:30 +0400
committermalc <av1474@comtv.ru>2009-09-13 11:15:32 +0400
commit54762b7339dc234a3ded6d0162b1676304933824 (patch)
treea4c1e83fd29330436e7e6d13de8ff10ec9d9dad8 /audio/ossaudio.c
parent0b3652bc70891940f2c7142d39576d17c4d07196 (diff)
downloadqemu-54762b7339dc234a3ded6d0162b1676304933824.zip
qemu-54762b7339dc234a3ded6d0162b1676304933824.tar.gz
qemu-54762b7339dc234a3ded6d0162b1676304933824.tar.bz2
oss: Simplify mmap code
Signed-off-by: malc <av1474@comtv.ru>
Diffstat (limited to 'audio/ossaudio.c')
-rw-r--r--audio/ossaudio.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 559c442..ecb8839 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -45,7 +45,6 @@ typedef struct OSSVoiceOut {
int nfrags;
int fragsize;
int mmapped;
- int old_optr;
} OSSVoiceOut;
typedef struct OSSVoiceIn {
@@ -54,7 +53,6 @@ typedef struct OSSVoiceIn {
int fd;
int nfrags;
int fragsize;
- int old_optr;
} OSSVoiceIn;
static struct {
@@ -366,7 +364,7 @@ static int oss_run_out (HWVoiceOut *hw)
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) {
@@ -374,20 +372,8 @@ static int oss_run_out (HWVoiceOut *hw)
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 {
@@ -462,9 +448,6 @@ static int oss_run_out (HWVoiceOut *hw)
rpos = (rpos + convert_samples) % hw->samples;
samples -= convert_samples;
}
- if (oss->mmapped) {
- oss->old_optr = cntinfo.ptr;
- }
hw->rpos = rpos;
return decr;
@@ -550,7 +533,8 @@ static int oss_init_out (HWVoiceOut *hw, struct audsettings *as)
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) {
@@ -749,7 +733,6 @@ static int oss_run_in (HWVoiceIn *hw)
bufs[0].len = dead << hwshift;
}
-
for (i = 0; i < 2; ++i) {
ssize_t nread;