Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/dev/audio Pull up following revision(s) (requested by...



details:   https://anonhg.NetBSD.org/src/rev/0af8d52dedd1
branches:  netbsd-9
changeset: 1001760:0af8d52dedd1
user:      martin <martin%NetBSD.org@localhost>
date:      Mon May 18 18:02:23 2020 +0000

description:
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).

diffstat:

 sys/dev/audio/audio.c |  46 +++++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 15 deletions(-)

diffs (96 lines):

diff -r f070501310ac -r 0af8d52dedd1 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Mon May 18 17:52:22 2020 +0000
+++ b/sys/dev/audio/audio.c     Mon May 18 18:02:23 2020 +0000
@@ -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 @@
                                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 @@
                        if (error)
                                goto bad3;
                }
+
+               mutex_enter(sc->sc_lock);
+               audio_rmixer_start(sc);
+               mutex_exit(sc->sc_lock);
        }
 
        if (bellfile == NULL) {
@@ -2457,22 +2464,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;
@@ -6672,10 +6676,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