summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2019-04-05 06:14:13 +0000
committerratchov <ratchov@openbsd.org>2019-04-05 06:14:13 +0000
commitbb43801786f1d97bae66be02079a9d280690d4a5 (patch)
tree507ce365239978b1ff8c896c26ffa8c1863a7e8a
parentZap two dead #defines that were unused since jsing deleted the (diff)
downloadwireguard-openbsd-bb43801786f1d97bae66be02079a9d280690d4a5.tar.xz
wireguard-openbsd-bb43801786f1d97bae66be02079a9d280690d4a5.zip
Try to start playback after play buffer pointers are advanced.
Allows playback to start automatically as soon as there's enough data, even if the AUDIO_START ioctl is not called. This is mainly useful to quickly test & debug low level drivers with simple shell commands.
-rw-r--r--sys/dev/audio.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index dcce535ed7e..b059c2ef209 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: audio.c,v 1.177 2019/03/31 17:55:09 ratchov Exp $ */
+/* $OpenBSD: audio.c,v 1.178 2019/04/05 06:14:13 ratchov Exp $ */
/*
* Copyright (c) 2015 Alexandre Ratchov <alex@caoua.org>
*
@@ -1555,15 +1555,17 @@ audio_write(struct audio_softc *sc, struct uio *uio, int ioflag)
if (sc->ops->copy_output)
sc->ops->copy_output(sc->arg, count);
+ mtx_enter(&audio_lock);
+ audio_buf_wcommit(&sc->play, count);
+
/* start automatically if audio_ioc_start() was never called */
if (audio_canstart(sc)) {
+ mtx_leave(&audio_lock);
error = audio_start(sc);
if (error)
return error;
+ mtx_enter(&audio_lock);
}
-
- mtx_enter(&audio_lock);
- audio_buf_wcommit(&sc->play, count);
}
mtx_leave(&audio_lock);
return 0;