From 32f42fe1e92dd608ad6c8f0de0eed1833e979ae5 Mon Sep 17 00:00:00 2001 From: mycroft Date: Sun, 13 Sep 1998 04:41:34 +0000 Subject: [PATCH] Make sure all voices are deallocated on close. --- sys/dev/ic/opl.c | 11 ++++------- sys/dev/midisyn.c | 14 +++++++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sys/dev/ic/opl.c b/sys/dev/ic/opl.c index 926de8c92646..50ea1c09e13f 100644 --- a/sys/dev/ic/opl.c +++ b/sys/dev/ic/opl.c @@ -1,4 +1,4 @@ -/* $NetBSD: opl.c,v 1.4 1998/08/26 13:08:10 augustss Exp $ */ +/* $NetBSD: opl.c,v 1.5 1998/09/13 04:41:34 mycroft Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -183,12 +183,12 @@ opl_command(sc, offs, addr, data) if (sc->model == OPL_2) delay(10); else - delay(2); + delay(6); bus_space_write_1(sc->iot, sc->ioh, OPL_DATA+offs, data); if (sc->model == OPL_2) delay(30); else - delay(2); + delay(6); } int @@ -347,13 +347,10 @@ oplsyn_close(ms) midisyn *ms; { struct opl_softc *sc = ms->data; - int v; DPRINTFN(2, ("oplsyn_close:\n")); + /*opl_reset(ms->data);*/ - - for (v = 0; v < sc->syn.nvoice ; v++) - oplsyn_noteoff(ms, v, 0, 0); if (sc->spkrctl) sc->spkrctl(sc->spkrarg, 0); } diff --git a/sys/dev/midisyn.c b/sys/dev/midisyn.c index f9d2ae56e80f..c473c8c06049 100644 --- a/sys/dev/midisyn.c +++ b/sys/dev/midisyn.c @@ -1,4 +1,4 @@ -/* $NetBSD: midisyn.c,v 1.3 1998/08/17 21:16:12 augustss Exp $ */ +/* $NetBSD: midisyn.c,v 1.4 1998/09/13 04:41:34 mycroft Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -112,10 +112,18 @@ midisyn_close(addr) void *addr; { midisyn *ms = addr; + struct midisyn_methods *fs; + int v; DPRINTF(("midisyn_close: ms=%p ms->mets=%p\n", ms, ms->mets)); - if (ms->mets->close) - ms->mets->close(ms); + fs = ms->mets; + for (v = 0; v < ms->nvoice; v++) + if (ms->voices[v].inuse) { + fs->noteoff(ms, v, 0, 0); + midisyn_freevoice(ms, v); + } + if (fs->close) + fs->close(ms); } void