summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormickey <mickey@openbsd.org>2001-11-26 18:16:02 +0000
committermickey <mickey@openbsd.org>2001-11-26 18:16:02 +0000
commite1b3ac9b7683815832cfc9726e45b87a40d67092 (patch)
tree53d60f68976437cad3c4db142ed1f7aafd8d0c98
parentremove static on functions. (diff)
downloadwireguard-openbsd-e1b3ac9b7683815832cfc9726e45b87a40d67092.tar.xz
wireguard-openbsd-e1b3ac9b7683815832cfc9726e45b87a40d67092.zip
cache the last deallocated voice and reuse on the next open.
this is to preserve the dac settings in between the openings, by the mp3 playing software, in particular. ho@ help and testing.
-rw-r--r--sys/dev/pci/emuxki.c55
-rw-r--r--sys/dev/pci/emuxkivar.h4
2 files changed, 36 insertions, 23 deletions
diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c
index 2675e85b30c..f6c741a4671 100644
--- a/sys/dev/pci/emuxki.c
+++ b/sys/dev/pci/emuxki.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emuxki.c,v 1.5 2001/11/20 12:22:59 mickey Exp $ */
+/* $OpenBSD: emuxki.c,v 1.6 2001/11/26 18:16:02 mickey Exp $ */
/* $NetBSD: emuxki.c,v 1.1 2001/10/17 18:39:41 jdolecek Exp $ */
/*-
@@ -1284,24 +1284,31 @@ emuxki_voice_new(struct emuxki_softc *sc, u_int8_t use)
struct emuxki_voice *voice;
int s;
- if ((voice = malloc(sizeof(*voice), M_DEVBUF, M_WAITOK)) == NULL)
- return (NULL);
- voice->sc = sc;
+ s = splaudio();
+ voice = sc->lvoice;
+ sc->lvoice = NULL;
+ splx(s);
+
+ if (!voice) {
+ if (!(voice = malloc(sizeof(*voice), M_DEVBUF, M_WAITOK)))
+ return (NULL);
+ voice->sc = sc;
+ voice->state = !EMU_VOICE_STATE_STARTED;
+ voice->stereo = EMU_VOICE_STEREO_NOTSET;
+ voice->b16 = 0;
+ voice->sample_rate = 0;
+ if (use & EMU_VOICE_USE_PLAY)
+ voice->dataloc.chan[0] = voice->dataloc.chan[0] = NULL;
+ else
+ voice->dataloc.source = EMU_RECSRC_NOTSET;
+ voice->buffer = NULL;
+ voice->blksize = 0;
+ voice->trigblk = 0;
+ voice->blkmod = 0;
+ voice->inth = NULL;
+ voice->inthparam = NULL;
+ }
voice->use = use;
- voice->state = !EMU_VOICE_STATE_STARTED;
- voice->stereo = EMU_VOICE_STEREO_NOTSET;
- voice->b16 = 0;
- voice->sample_rate = 0;
- if (use & EMU_VOICE_USE_PLAY)
- voice->dataloc.chan[0] = voice->dataloc.chan[0] = NULL;
- else
- voice->dataloc.source = EMU_RECSRC_NOTSET;
- voice->buffer = NULL;
- voice->blksize = 0;
- voice->trigblk = 0;
- voice->blkmod = 0;
- voice->inth = NULL;
- voice->inthparam = NULL;
s = splaudio();
LIST_INSERT_HEAD((&sc->voices), voice, next);
@@ -1313,17 +1320,23 @@ emuxki_voice_new(struct emuxki_softc *sc, u_int8_t use)
void
emuxki_voice_delete(struct emuxki_voice *voice)
{
- int s;
+ struct emuxki_softc *sc;
+ struct emuxki_voice *lvoice;
+ int s;
if (voice->state & EMU_VOICE_STATE_STARTED)
emuxki_voice_halt(voice);
s = splaudio();
LIST_REMOVE(voice, next);
+ lvoice = sc->lvoice;
+ sc->lvoice = voice;
splx(s);
- emuxki_voice_dataloc_destroy(voice);
- free(voice, M_DEVBUF);
+ if (lvoice) {
+ emuxki_voice_dataloc_destroy(lvoice);
+ free(lvoice, M_DEVBUF);
+ }
}
int
diff --git a/sys/dev/pci/emuxkivar.h b/sys/dev/pci/emuxkivar.h
index 35f603da0ad..c51eecbaf27 100644
--- a/sys/dev/pci/emuxkivar.h
+++ b/sys/dev/pci/emuxkivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: emuxkivar.h,v 1.2 2001/10/24 15:09:28 brad Exp $ */
+/* $OpenBSD: emuxkivar.h,v 1.3 2001/11/26 18:16:02 mickey Exp $ */
/* $NetBSD: emuxkivar.h,v 1.1 2001/10/17 18:39:41 jdolecek Exp $ */
/*-
@@ -254,7 +254,7 @@ struct emuxki_softc {
struct ac97_codec_if *codecif;
struct device *sc_audev;
- struct emuxki_voice *pvoice, *rvoice;
+ struct emuxki_voice *pvoice, *rvoice, *lvoice;
};
#endif /* !_DEV_PCI_EMU10K1VAR_H_ */