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 that audio_open() didn't halt the recordin...



details:   https://anonhg.NetBSD.org/src/rev/0f5aa03c7fdf
branches:  trunk
changeset: 946789:0f5aa03c7fdf
user:      isaki <isaki%NetBSD.org@localhost>
date:      Wed Dec 09 04:24:08 2020 +0000

description:
Fix that audio_open() didn't halt the recording mixer correctly
if fd_allocfile() failed, since rev 1.65.
Will fix PR kern/55848.

diffstat:

 sys/dev/audio/audio.c |  24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diffs (78 lines):

diff -r a4dec24b5302 -r 0f5aa03c7fdf sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Wed Dec 09 04:02:20 2020 +0000
+++ b/sys/dev/audio/audio.c     Wed Dec 09 04:24:08 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.79 2020/09/07 03:36:11 isaki Exp $ */
+/*     $NetBSD: audio.c,v 1.80 2020/12/09 04:24:08 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.79 2020/09/07 03:36:11 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.80 2020/12/09 04:24:08 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2082,6 +2082,7 @@
        audio_file_t *af;
        audio_ring_t *hwbuf;
        bool fullduplex;
+       bool rmixer_started;
        int fd;
        int error;
 
@@ -2092,6 +2093,8 @@
            ISDEVSOUND(dev) ? "sound" : "audio",
            flags, sc->sc_popens, sc->sc_ropens);
 
+       rmixer_started = false;
+
        af = kmem_zalloc(sizeof(audio_file_t), KM_SLEEP);
        af->sc = sc;
        af->dev = dev;
@@ -2282,12 +2285,13 @@
                mutex_enter(sc->sc_lock);
                audio_rmixer_start(sc);
                mutex_exit(sc->sc_lock);
+               rmixer_started = true;
        }
 
        if (bellfile == NULL) {
                error = fd_allocfile(&fp, &fd);
                if (error)
-                       goto bad3;
+                       goto bad4;
        }
 
        /*
@@ -2314,10 +2318,12 @@
        TRACEF(3, af, "done");
        return error;
 
-       /*
-        * Since track here is not yet linked to sc_files,
-        * you can call track_destroy() without sc_intr_lock.
-        */
+bad4:
+       if (rmixer_started) {
+               mutex_enter(sc->sc_lock);
+               audio_rmixer_halt(sc);
+               mutex_exit(sc->sc_lock);
+       }
 bad3:
        if (sc->sc_popens + sc->sc_ropens == 0) {
                if (sc->hw_if->close) {
@@ -2329,6 +2335,10 @@
                }
        }
 bad2:
+       /*
+        * Since track here is not yet linked to sc_files,
+        * you can call track_destroy() without sc_intr_lock.
+        */
        if (af->rtrack) {
                audio_track_destroy(af->rtrack);
                af->rtrack = NULL;



Home | Main Index | Thread Index | Old Index