diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2007-10-03 21:49:14 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2007-10-03 21:49:14 +0000 |
commit | 54eeb77f25b00ad84144dbe0edc93b29171edd2f (patch) | |
tree | 6fef7b2dd89ffe730caeb77de1b38b046acb12f7 /sys/dev | |
parent | 631319f76280aee009fa12421aaf29432592924a (diff) |
add two new audio ioctls, AUDIO_GETPRINFO and AUDIO_GETRRINFO, and the
data structure these ioctls use, audio_bufinfo.
these ioctls return information about the play and record buffers
into the audio_bufinfo structure.
these are being added to aid in porting non-native audio applications
and libraries, and to fix issues in our OSS audio emulation. these
ioctls exist only on OpenBSD and should not be used in code intended
for distribution.
ok ratchov
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/audio.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c index 80af5a51a97..82c4fb09693 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audio.c,v 1.80 2007/09/24 19:45:03 ratchov Exp $ */ +/* $OpenBSD: audio.c,v 1.81 2007/10/03 21:49:13 jakemsr Exp $ */ /* $NetBSD: audio.c,v 1.119 1999/11/09 16:50:47 augustss Exp $ */ /* @@ -104,7 +104,7 @@ int audio_blk_ms = AUDIO_BLK_MS; int audiosetinfo(struct audio_softc *, struct audio_info *); int audiogetinfo(struct audio_softc *, struct audio_info *); - +int audiogetbufinfo(struct audio_softc *, struct audio_bufinfo *, int); int audio_open(dev_t, struct audio_softc *, int, int, struct proc *); int audio_close(dev_t, int, int, struct proc *); int audio_read(dev_t, struct uio *, int); @@ -1729,6 +1729,18 @@ audio_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) *(int *)addr = hw->get_props(sc->hw_hdl); break; + case AUDIO_GETPRINFO: + DPRINTF(("AUDIO_GETPRINFO\n")); + error = audiogetbufinfo(sc, (struct audio_bufinfo *)addr, + AUMODE_PLAY); + break; + + case AUDIO_GETRRINFO: + DPRINTF(("AUDIO_GETRRINFO\n")); + error = audiogetbufinfo(sc, (struct audio_bufinfo *)addr, + AUMODE_RECORD); + break; + default: DPRINTF(("audio_ioctl: unknown ioctl\n")); error = ENOTTY; @@ -2924,6 +2936,35 @@ audiogetinfo(struct audio_softc *sc, struct audio_info *ai) return (0); } +int +audiogetbufinfo(struct audio_softc *sc, struct audio_bufinfo *info, int mode) +{ + struct audio_ringbuffer *buf; + int factor; + + factor = 1; + if (mode == AUMODE_PLAY) { + buf = &sc->sc_pr; + factor = sc->sc_pparams.factor; + } else { + buf = &sc->sc_rr; + factor = sc->sc_rparams.factor; + } + + info->seek = buf->used / factor; + info->blksize = buf->blksize / factor; + if (buf->blksize != 0) { + info->hiwat = buf->usedhigh / buf->blksize; + info->lowat = buf->usedlow / buf->blksize; + } else { + info->hiwat = 0; + info->lowat = 0; + } + + return (0); +} + + /* * Mixer driver */ |