Improved fix of PR12796, from Frederick Bruckman <fb@enteract.com>

This commit is contained in:
augustss 2001-05-10 01:54:30 +00:00
parent 5a71cdbf26
commit f63784bfbe

View File

@ -1,4 +1,4 @@
/* $NetBSD: ossaudio.c,v 1.34 2001/05/09 21:50:50 augustss Exp $ */
/* $NetBSD: ossaudio.c,v 1.35 2001/05/10 01:54:30 augustss Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -397,16 +397,33 @@ oss_ioctl_audio(p, uap, retval)
goto out;
break;
case OSS_SNDCTL_DSP_GETOSPACE:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
goto out;
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)
goto out;
break;
case OSS_SNDCTL_DSP_GETISPACE:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
goto out;
setblocksize(fp, &tmpinfo, p);
bufinfo.fragsize = tmpinfo.blocksize;
bufinfo.fragments = tmpinfo.hiwat - tmpinfo.play.seek /
bufinfo.fragsize;
bufinfo.fragments = tmpinfo.hiwat -
(tmpinfo.record.seek + tmpinfo.blocksize - 1) /
tmpinfo.blocksize;
bufinfo.fragstotal = tmpinfo.hiwat;
bufinfo.bytes = tmpinfo.play.buffer_size;
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));