summaryrefslogtreecommitdiff
path: root/sys/compat/ossaudio/ossaudio.c
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2001-05-24 04:21:04 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2001-05-24 04:21:04 +0000
commitbc4e57d7da104517213d33ff2667a9df6067cc7e (patch)
tree5ab157ea155c2daf824669190c8b828e3e3d176b /sys/compat/ossaudio/ossaudio.c
parent69f4177de66487b35e389c85a72f83874c873f36 (diff)
Fix fragment handling for SNDCTL_DSP_GETxSPACE ioctls; per NetBSD PR/12796.
The kernel part of this fixes sound emulation for version 1.37c of the Linux binary of Snes9x (Super Nintendo emulator). The userland equivalent fix should allow espie to remove his local audio hacks in the squeak port.
Diffstat (limited to 'sys/compat/ossaudio/ossaudio.c')
-rw-r--r--sys/compat/ossaudio/ossaudio.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/sys/compat/ossaudio/ossaudio.c b/sys/compat/ossaudio/ossaudio.c
index 873cf80a2dd..e61c0fd58eb 100644
--- a/sys/compat/ossaudio/ossaudio.c
+++ b/sys/compat/ossaudio/ossaudio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ossaudio.c,v 1.4 2001/04/11 01:30:24 aaron Exp $ */
+/* $OpenBSD: ossaudio.c,v 1.5 2001/05/24 04:21:02 aaron Exp $ */
/* $NetBSD: ossaudio.c,v 1.23 1997/10/19 07:41:52 augustss Exp $ */
/*
@@ -386,15 +386,33 @@ oss_ioctl_audio(p, uap, retval)
return error;
break;
case OSS_SNDCTL_DSP_GETOSPACE:
+ error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
+ if (error)
+ return error;
+ setblocksize(fp, &tmpinfo, p);
+ bufinfo.fragsize = tmpinfo.blocksize;
+ bufinfo.fragments = tmpinfo.hiwat -
+ (tmpinfo.play.seek + tmpinfo.blocksize - 1) /
+ tmpinfo.blocksize;
+ bufinfo.fragstotal = tmpinfo.hiwat;
+ bufinfo.bytes =
+ tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.play.seek;
+ error = copyout(&bufinfo, SCARG(uap, data), sizeof bufinfo);
+ if (error)
+ return error;
+ break;
case OSS_SNDCTL_DSP_GETISPACE:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
return error;
setblocksize(fp, &tmpinfo, p);
bufinfo.fragsize = tmpinfo.blocksize;
- bufinfo.fragments = /* XXX */
- bufinfo.fragstotal = tmpinfo.play.buffer_size / bufinfo.fragsize;
- bufinfo.bytes = tmpinfo.play.buffer_size;
+ bufinfo.fragments = tmpinfo.hiwat -
+ (tmpinfo.record.seek + tmpinfo.blocksize - 1) /
+ tmpinfo.blocksize;
+ bufinfo.fragstotal = tmpinfo.hiwat;
+ bufinfo.bytes =
+ tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.record.seek;
DPRINTF(("oss_sys_ioctl: SNDCTL_DSP_GETxSPACE = %d %d %d %d\n",
bufinfo.fragsize, bufinfo.fragments,
bufinfo.fragstotal, bufinfo.bytes));