Module Name: src
Committed By: martin
Date: Mon May 18 18:02:23 UTC 2020
Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c
Log Message:
Pull up following revision(s) (requested by isaki in ticket #909):
sys/dev/audio/audio.c: revision 1.65
Fix to start recording immediately when open() with READ mode is
called (unless pause).
- Opening /dev/audio always initializes pause with false. Therefore
it always starts recording.
- Opening /dev/sound inherites pause from the sticky parameter.
Therefore whether /dev/sound starts recording or not depends on the
sticky pause parameter.
This fixes two problems:
- Opening /dev/audio didn't start recording after merging isaki-audio2.
- Opening /dev/sound didn't start recording regardless of the sticky
pause, probably since long time ago (at least netbsd-7).
To generate a diff of this commit:
cvs rdiff -u -r1.28.2.12 -r1.28.2.13 src/sys/dev/audio/audio.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.12 src/sys/dev/audio/audio.c:1.28.2.13
--- src/sys/dev/audio/audio.c:1.28.2.12 Thu Apr 30 16:05:18 2020
+++ src/sys/dev/audio/audio.c Mon May 18 18:02:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.28.2.12 2020/04/30 16:05:18 martin Exp $ */
+/* $NetBSD: audio.c,v 1.28.2.13 2020/05/18 18:02:23 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.12 2020/04/30 16:05:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.13 2020/05/18 18:02:23 martin Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -2224,7 +2224,10 @@ audio_open(dev_t dev, struct audio_softc
goto bad3;
}
}
- /* Call init_input if this is the first recording open. */
+ /*
+ * Call init_input and start rmixer, if this is the first recording
+ * open. See pause consideration notes.
+ */
if (af->rtrack && sc->sc_ropens == 0) {
if (sc->hw_if->init_input) {
hwbuf = &sc->sc_rmixer->hwbuf;
@@ -2239,6 +2242,10 @@ audio_open(dev_t dev, struct audio_softc
if (error)
goto bad3;
}
+
+ mutex_enter(sc->sc_lock);
+ audio_rmixer_start(sc);
+ mutex_exit(sc->sc_lock);
}
if (bellfile == NULL) {
@@ -2457,21 +2464,18 @@ audio_read(struct audio_softc *sc, struc
TRACET(2, track, "resid=%zd", uio->uio_resid);
+#ifdef AUDIO_PM_IDLE
error = audio_exlock_mutex_enter(sc);
if (error)
return error;
-#ifdef AUDIO_PM_IDLE
if (device_is_active(&sc->sc_dev) || sc->sc_idle)
device_active(&sc->sc_dev, DVA_SYSTEM);
-#endif
- /*
- * The first read starts rmixer.
- */
- if (sc->sc_rbusy == false)
- audio_rmixer_start(sc);
+ /* In recording, unlike playback, read() never operates rmixer. */
+
audio_exlock_mutex_exit(sc);
+#endif
usrbuf = &track->usrbuf;
input = track->input;
@@ -6672,10 +6676,22 @@ audio_mixers_get_format(struct audio_sof
/*
* Pause consideration:
*
- * The introduction of these two behavior makes pause/unpause operation
- * simple.
- * 1. The first read/write access of the first track makes mixer start.
- * 2. A pause of the last track doesn't make mixer stop.
+ * Pausing/unpausing never affect [pr]mixer. This single rule makes
+ * operation simple. Note that playback and recording are asymmetric.
+ *
+ * For playback,
+ * 1. Any playback open doesn't start pmixer regardless of initial pause
+ * state of this track.
+ * 2. The first write access among playback tracks only starts pmixer
+ * regardless of this track's pause state.
+ * 3. Even a pause of the last playback track doesn't stop pmixer.
+ * 4. The last close of all playback tracks only stops pmixer.
+ *
+ * For recording,
+ * 1. The first recording open only starts rmixer regardless of initial
+ * pause state of this track.
+ * 2. Even a pause of the last track doesn't stop rmixer.
+ * 3. The last close of all recording tracks only stops rmixer.
*/
/*