summaryrefslogtreecommitdiff
path: root/lib/libossaudio
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2007-10-08 01:00:14 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2007-10-08 01:00:14 +0000
commitd378ec7cb7f4a207fe5cc27974c79941f7c583d0 (patch)
treeb1988a0aca4beda50de91ea3d077347ab4869377 /lib/libossaudio
parentd803a5a240bde200a9a8c90cdf8eb96738d37afd (diff)
- make SNDCTL_DSP_GETOSPACE much more efficient by using AUDIO_GETPRINO
instead of AUDIO_GETINFO - make SNDCTL_DSP_GETISPACE return correct values by using AUDIO_GETRRINFO instead of AUDIO_GETINFO - remove calls to setblocksize() from SNDCTL_DSP_GET[IO]SPACE. changing the blocksize inside play or record loops, where these ioctls are most often used, can have serious negative consequences. the blocksize should be "fixed" to a power of 2 before these ioctls are called by using SNDCTL_DSP_SETFRAGMENT or SNDCTL_DSP_GETBLKSIZE. heavily tested by myself. no negative feedback from anyone else. ok ratchov
Diffstat (limited to 'lib/libossaudio')
-rw-r--r--lib/libossaudio/ossaudio.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/libossaudio/ossaudio.c b/lib/libossaudio/ossaudio.c
index c1718a2d236..2d40f0b3d89 100644
--- a/lib/libossaudio/ossaudio.c
+++ b/lib/libossaudio/ossaudio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ossaudio.c,v 1.10 2007/09/28 01:15:15 jakemsr Exp $ */
+/* $OpenBSD: ossaudio.c,v 1.11 2007/10/08 01:00:13 jakemsr Exp $ */
/* $NetBSD: ossaudio.c,v 1.14 2001/05/10 01:53:48 augustss Exp $ */
/*-
@@ -97,6 +97,7 @@ audio_ioctl(int fd, unsigned long com, void *argp)
struct audio_buf_info bufinfo;
struct count_info cntinfo;
struct audio_encoding tmpenc;
+ struct audio_bufinfo tmpab;
u_int u;
int idat, idata;
int retval;
@@ -343,27 +344,23 @@ audio_ioctl(int fd, unsigned long com, void *argp)
INTARG = idat;
break;
case SNDCTL_DSP_GETOSPACE:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+ retval = ioctl(fd, AUDIO_GETPRINFO, &tmpab);
if (retval < 0)
return retval;
- setblocksize(fd, &tmpinfo);
- 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;
+ bufinfo.fragsize = tmpab.blksize;
+ bufinfo.fragstotal = tmpab.hiwat;
+ bufinfo.bytes = tmpab.hiwat * tmpab.blksize - tmpab.seek;
+ bufinfo.fragments = bufinfo.bytes / tmpab.blksize;
*(struct audio_buf_info *)argp = bufinfo;
break;
case SNDCTL_DSP_GETISPACE:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+ retval = ioctl(fd, AUDIO_GETRRINFO, &tmpab);
if (retval < 0)
return retval;
- setblocksize(fd, &tmpinfo);
- bufinfo.fragsize = tmpinfo.blocksize;
- 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;
+ bufinfo.fragsize = tmpab.blksize;
+ bufinfo.fragstotal = tmpab.hiwat;
+ bufinfo.bytes = tmpab.seek;
+ bufinfo.fragments = bufinfo.bytes / tmpab.blksize;
*(struct audio_buf_info *)argp = bufinfo;
break;
case SNDCTL_DSP_NONBLOCK: