Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/audio Fix to start recording immediately when open()...
details: https://anonhg.NetBSD.org/src/rev/0d3b0196a508
branches: trunk
changeset: 1008548:0d3b0196a508
user: isaki <isaki%NetBSD.org@localhost>
date: Thu Mar 26 13:32:03 2020 +0000
description:
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).
diffstat:
sys/dev/audio/audio.c | 46 +++++++++++++++++++++++++++++++---------------
1 files changed, 31 insertions(+), 15 deletions(-)
diffs (96 lines):
diff -r b7edca997e3f -r 0d3b0196a508 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c Thu Mar 26 10:38:16 2020 +0000
+++ b/sys/dev/audio/audio.c Thu Mar 26 13:32:03 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.64 2020/03/07 06:27:19 isaki Exp $ */
+/* $NetBSD: audio.c,v 1.65 2020/03/26 13:32:03 isaki Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.64 2020/03/07 06:27:19 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.65 2020/03/26 13:32:03 isaki Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -2229,7 +2229,10 @@
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;
@@ -2244,6 +2247,10 @@
if (error)
goto bad3;
}
+
+ mutex_enter(sc->sc_lock);
+ audio_rmixer_start(sc);
+ mutex_exit(sc->sc_lock);
}
if (bellfile == NULL) {
@@ -2462,22 +2469,19 @@
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);
+
+ /* In recording, unlike playback, read() never operates rmixer. */
+
+ audio_exlock_mutex_exit(sc);
#endif
- /*
- * The first read starts rmixer.
- */
- if (sc->sc_rbusy == false)
- audio_rmixer_start(sc);
- audio_exlock_mutex_exit(sc);
-
usrbuf = &track->usrbuf;
input = track->input;
error = 0;
@@ -6680,10 +6684,22 @@
/*
* 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.
*/
/*
Home |
Main Index |
Thread Index |
Old Index