diff options
author | Hugh Graham <hugh@cvs.openbsd.org> | 2001-07-03 07:41:54 +0000 |
---|---|---|
committer | Hugh Graham <hugh@cvs.openbsd.org> | 2001-07-03 07:41:54 +0000 |
commit | 56eef6d8bc66008e786d83aee225fea5e155b55a (patch) | |
tree | 284d1b077e6388ac078c5aa27c9d8fc0bce6008d /sys/dev/audio.c | |
parent | c484219af81f7a786e4c7afec093a81af5875470 (diff) |
Make the audio device play nice with revoke(2) by having it reset
both directions if neither read nor write flags are set on close.
Cleared by niklas and with some analysis by bjc.
Diffstat (limited to 'sys/dev/audio.c')
-rw-r--r-- | sys/dev/audio.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c index 0fcc80d79fc..f6a394042a4 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audio.c,v 1.25 2001/01/28 09:45:26 aaron Exp $ */ +/* $OpenBSD: audio.c,v 1.26 2001/07/03 07:41:53 hugh Exp $ */ /* $NetBSD: audio.c,v 1.105 1998/09/27 16:43:56 christos Exp $ */ /* @@ -1166,7 +1166,7 @@ audio_close(dev, flags, ifmt, p) struct audio_hw_if *hw = sc->hw_if; int s; - DPRINTF(("audio_close: unit=%d\n", unit)); + DPRINTF(("audio_close: unit=%d flags=0x%x\n", unit, flags)); s = splaudio(); /* Stop recording. */ @@ -1197,11 +1197,16 @@ audio_close(dev, flags, ifmt, p) hw->close(sc->hw_hdl); - if (flags & FREAD) { + /* + * If flags has neither read nor write then reset both + * directions. Encountered when someone runs revoke(2). + */ + + if ((flags & FREAD) || ((flags & (FREAD|FWRITE)) == 0)) { sc->sc_open &= ~AUOPEN_READ; sc->sc_mode &= ~AUMODE_RECORD; } - if (flags & FWRITE) { + if ((flags & FWRITE) || ((flags & (FREAD|FWRITE)) == 0)) { sc->sc_open &= ~AUOPEN_WRITE; sc->sc_mode &= ~(AUMODE_PLAY|AUMODE_PLAY_ALL); } |