From 8a162b1a360d7a9c7849ca6da45bb66e523d4456 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Sun, 16 Apr 2006 03:24:28 +0000 Subject: Handle input interrupts in a better manner. It is only necessary to notify reading processes when the buffer is empty rather than on every input byte. From Alexandre Ratchov. --- sys/dev/midi.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'sys') diff --git a/sys/dev/midi.c b/sys/dev/midi.c index 9c2aaf04bf8..4f1cb931a9c 100644 --- a/sys/dev/midi.c +++ b/sys/dev/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.13 2006/04/07 22:41:32 jsg Exp $ */ +/* $OpenBSD: midi.c,v 1.14 2006/04/16 03:24:27 jsg Exp $ */ /* * Copyright (c) 2003, 2004 Alexandre Ratchov @@ -90,7 +90,6 @@ midi_iintr(void *addr, int data) { struct midi_softc *sc = (struct midi_softc *)addr; struct midi_buffer *mb = &sc->inbuf; - int s; if (sc->isdying || !sc->isopen || !(sc->flags & FREAD)) return; @@ -102,18 +101,16 @@ midi_iintr(void *addr, int data) #endif if (MIDIBUF_ISFULL(mb)) return; /* discard data */ - - s = splaudio(); + if (MIDIBUF_ISEMPTY(mb)) { + if (sc->rchan) { + sc->rchan = 0; + wakeup(&sc->rchan); + } + selwakeup(&sc->rsel); + if (sc->async) + psignal(sc->async, SIGIO); + } MIDIBUF_WRITE(mb, data); - splx(s); - - if (sc->rchan) { - sc->rchan = 0; - wakeup(&sc->rchan); - } - selwakeup(&sc->rsel); - if (sc->async) - psignal(sc->async, SIGIO); } -- cgit v1.2.3