summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2007-07-06 03:20:08 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2007-07-06 03:20:08 +0000
commit19ac4b38b1b2fa83cc9e478145234597a626c578 (patch)
tree74b492c780d172884dbb39a2ddce5459a4e57bdf /sys
parenta1b8fc11bde2cfd94b330c92d7665f02e2f50c00 (diff)
The poll(2) syscall doesn't work correctly on audio(4) devices.
For instance, it may not set POLLIN when samples become available, or may set POLLOUT when write(2) will block. Fix this by making conditions used by poll (FILTREAD and FILTWRITE macros) match the blocking conditions in audio_read() and audio_write(). originally from Alexandre Ratchov, with a small tweak by me. "patches look correct to me" marco@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/audio.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index e1a0a858257..f275ae9de39 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: audio.c,v 1.55 2007/05/31 22:23:13 tedu Exp $ */
+/* $OpenBSD: audio.c,v 1.56 2007/07/06 03:20:07 jakemsr Exp $ */
/* $NetBSD: audio.c,v 1.119 1999/11/09 16:50:47 augustss Exp $ */
/*
@@ -1804,10 +1804,14 @@ audio_selwakeup(struct audio_softc *sc, int play)
KNOTE(&si->si_note, 0);
}
-#define AUDIO_FILTREAD(sc) ((sc->sc_mode & AUMODE_PLAY) ? \
+#define AUDIO_FILTREAD(sc) ( \
+ (!sc->sc_full_duplex && (sc->sc_mode & AUMODE_PLAY)) ? \
sc->sc_pr.stamp > sc->sc_wstamp : sc->sc_rr.used > sc->sc_rr.usedlow)
-#define AUDIO_FILTWRITE(sc) \
- (sc->sc_mode & AUMODE_RECORD || sc->sc_pr.used <= sc->sc_pr.usedlow)
+
+#define AUDIO_FILTWRITE(sc) ( \
+ (!sc->sc_full_duplex && (sc->sc_mode & AUMODE_RECORD)) || \
+ (!(sc->sc_mode & AUMODE_PLAY_ALL) && sc->sc_playdrop > 0) || \
+ (sc->sc_pr.used < sc->sc_pr.usedhigh))
int
audio_poll(dev, events, p)