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 | |
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')
-rw-r--r-- | sys/dev/audio.c | 45 | ||||
-rw-r--r-- | sys/sys/audioio.h | 12 |
2 files changed, 54 insertions, 3 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 */ diff --git a/sys/sys/audioio.h b/sys/sys/audioio.h index 07412e76218..c4925661d4d 100644 --- a/sys/sys/audioio.h +++ b/sys/sys/audioio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: audioio.h,v 1.17 2007/09/17 13:46:11 jakemsr Exp $ */ +/* $OpenBSD: audioio.h,v 1.18 2007/10/03 21:49:13 jakemsr Exp $ */ /* $NetBSD: audioio.h,v 1.24 1998/08/13 06:28:41 mrg Exp $ */ /* @@ -86,6 +86,14 @@ typedef struct audio_info audio_info_t; #define AUDIO_INITINFO(p) \ (void)memset((void *)(p), 0xff, sizeof(struct audio_info)) +struct audio_bufinfo { + u_int blksize; /* block size */ + u_int hiwat; /* high water mark */ + u_int lowat; /* low water mark */ + u_int seek; /* current position */ +}; +typedef struct audio_bufinfo audio_bufinfo_t; + /* * Parameter for the AUDIO_GETDEV ioctl to determine current * audio devices. @@ -183,6 +191,8 @@ typedef struct audio_encoding { #define AUDIO_PROP_FULLDUPLEX 0x01 #define AUDIO_PROP_MMAP 0x02 #define AUDIO_PROP_INDEPENDENT 0x04 +#define AUDIO_GETPRINFO _IOR('A', 35, struct audio_bufinfo) +#define AUDIO_GETRRINFO _IOR('A', 36, struct audio_bufinfo) /* * Mixer device |