summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2017-11-23 06:07:55 +0000
committerratchov <ratchov@openbsd.org>2017-11-23 06:07:55 +0000
commit4dd057665965de1cf3ad292b1e472099acb03814 (patch)
tree5892e6142c01eb8b5d1351838ee811b5283d7cff
parentRemove useless variable assignments in .au header parsing code. From (diff)
downloadwireguard-openbsd-4dd057665965de1cf3ad292b1e472099acb03814.tar.xz
wireguard-openbsd-4dd057665965de1cf3ad292b1e472099acb03814.zip
No need to grab the audio lock to call audio_canstart() as it checks
whether the device is started before using structures shared with the interrupt handler. From Michael W. Bombardieri, tested by me.
-rw-r--r--sys/dev/audio.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index 079ce7a215d..f8a94bb414e 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: audio.c,v 1.165 2017/06/26 07:02:16 ratchov Exp $ */
+/* $OpenBSD: audio.c,v 1.166 2017/11/23 06:07:55 ratchov Exp $ */
/*
* Copyright (c) 2015 Alexandre Ratchov <alex@caoua.org>
*
@@ -1358,15 +1358,14 @@ audio_read(struct audio_softc *sc, struct uio *uio, int ioflag)
tsleep(&sc->quiesce, 0, "au_qrd", 0);
/* start automatically if audio_ioc_start() was never called */
- mtx_enter(&audio_lock);
if (audio_canstart(sc)) {
- mtx_leave(&audio_lock);
error = audio_start(sc);
if (error)
return error;
- mtx_enter(&audio_lock);
}
+ mtx_enter(&audio_lock);
+
/* if there is no data then sleep */
while (sc->rec.used == 0) {
if (ioflag & IO_NDELAY) {