summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorjoerg <joerg@NetBSD.org>2007-06-11 13:05:46 +0000
committerjoerg <joerg@NetBSD.org>2007-06-11 13:05:46 +0000
commit5ccf1c578a0cb04698a7fd4322e8426583aacaa3 (patch)
treed4f350ec7d53ddd29fce2ba0a6023f776b0d4193 /sys/dev
parented180c85a356b74b5d7fb1df790a148624517125 (diff)
Add a new ioctl AUDIO_GETBUFINFO. It works like AUDIO_GETINFO, but
doesn't obtain the ports, gain and balance related parameters. Those generally require reading from the hardware and therefore are much more expensive to obtain. Modify OSS emulation to use the new ioctl where possible. This reduces CPU usage of mplayer during mp3 playback with my Thinkpad from 20% to < 1% and from 50% to 20% during Xvid playback. Review and comments from jmcneill@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/audio.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index 81cc5bed23f..3c3828c0093 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.221 2007/03/09 13:20:12 kent Exp $ */
+/* $NetBSD: audio.c,v 1.222 2007/06/11 13:05:46 joerg Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.221 2007/03/09 13:20:12 kent Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.222 2007/06/11 13:05:46 joerg Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -104,7 +104,7 @@ int audiodebug = AUDIO_DEBUG;
int audio_blk_ms = AUDIO_BLK_MS;
int audiosetinfo(struct audio_softc *, struct audio_info *);
-int audiogetinfo(struct audio_softc *, struct audio_info *);
+int audiogetinfo(struct audio_softc *, struct audio_info *, int);
int audio_open(dev_t, struct audio_softc *, int, int, struct lwp *);
int audio_close(struct audio_softc *, int, int, struct lwp *);
@@ -2131,7 +2131,12 @@ audio_ioctl(struct audio_softc *sc, u_long cmd, void *addr, int flag,
case AUDIO_GETINFO:
DPRINTF(("AUDIO_GETINFO\n"));
- error = audiogetinfo(sc, (struct audio_info *)addr);
+ error = audiogetinfo(sc, (struct audio_info *)addr, 0);
+ break;
+
+ case AUDIO_GETBUFINFO:
+ DPRINTF(("AUDIO_GETBUFINFO\n"));
+ error = audiogetinfo(sc, (struct audio_info *)addr, 1);
break;
case AUDIO_DRAIN:
@@ -3533,7 +3538,7 @@ cleanup:
}
int
-audiogetinfo(struct audio_softc *sc, struct audio_info *ai)
+audiogetinfo(struct audio_softc *sc, struct audio_info *ai, int buf_only_mode)
{
struct audio_prinfo *r, *p;
const struct audio_hw_if *hw;
@@ -3553,16 +3558,30 @@ audiogetinfo(struct audio_softc *sc, struct audio_info *ai)
p->encoding = sc->sc_pparams.encoding;
r->encoding = sc->sc_rparams.encoding;
- r->port = au_get_port(sc, &sc->sc_inports);
- p->port = au_get_port(sc, &sc->sc_outports);
+ if (buf_only_mode) {
+ r->port = 0;
+ p->port = 0;
- r->avail_ports = sc->sc_inports.allports;
- p->avail_ports = sc->sc_outports.allports;
+ r->avail_ports = 0;
+ p->avail_ports = 0;
- au_get_gain(sc, &sc->sc_inports, &r->gain, &r->balance);
- au_get_gain(sc, &sc->sc_outports, &p->gain, &p->balance);
+ r->gain = 0;
+ r->balance = 0;
+
+ p->gain = 0;
+ p->balance = 0;
+ } else {
+ r->port = au_get_port(sc, &sc->sc_inports);
+ p->port = au_get_port(sc, &sc->sc_outports);
+
+ r->avail_ports = sc->sc_inports.allports;
+ p->avail_ports = sc->sc_outports.allports;
+
+ au_get_gain(sc, &sc->sc_inports, &r->gain, &r->balance);
+ au_get_gain(sc, &sc->sc_outports, &p->gain, &p->balance);
+ }
- if (sc->sc_monitor_port != -1) {
+ if (sc->sc_monitor_port != -1 && buf_only_mode == 0) {
mixer_ctrl_t ct;
ct.dev = sc->sc_monitor_port;