Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/audio audio_hw_probe:



details:   https://anonhg.NetBSD.org/src/rev/bfc4a9a9e194
branches:  trunk
changeset: 999028:bfc4a9a9e194
user:      nakayama <nakayama%NetBSD.org@localhost>
date:      Mon May 13 04:11:04 2019 +0000

description:
audio_hw_probe:
Return error if both play and record probes failed.

Avoid audio is disabled on devices with only play like USB speakers.

diffstat:

 sys/dev/audio/audio.c |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (46 lines):

diff -r 9a0a4e7691f6 -r bfc4a9a9e194 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Mon May 13 04:09:35 2019 +0000
+++ b/sys/dev/audio/audio.c     Mon May 13 04:11:04 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.4 2019/05/13 04:09:35 nakayama Exp $       */
+/*     $NetBSD: audio.c,v 1.5 2019/05/13 04:11:04 nakayama Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -149,7 +149,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.4 2019/05/13 04:09:35 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.5 2019/05/13 04:11:04 nakayama Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -6149,17 +6149,23 @@
            "invalid mode = %x", mode);
 
        if (is_indep) {
+               int errorp = 0, errorr = 0;
+
                /* On independent devices, probe separately. */
                if ((mode & AUMODE_PLAY) != 0) {
-                       error = audio_hw_probe_fmt(sc, phwfmt, AUMODE_PLAY);
-                       if (error)
+                       errorp = audio_hw_probe_fmt(sc, phwfmt, AUMODE_PLAY);
+                       if (errorp)
                                mode &= ~AUMODE_PLAY;
                }
                if ((mode & AUMODE_RECORD) != 0) {
-                       error = audio_hw_probe_fmt(sc, rhwfmt, AUMODE_RECORD);
-                       if (error)
+                       errorr = audio_hw_probe_fmt(sc, rhwfmt, AUMODE_RECORD);
+                       if (errorr)
                                mode &= ~AUMODE_RECORD;
                }
+
+               /* Return error if both play and record probes failed. */
+               if (errorp && errorr)
+                       error = errorp;
        } else {
                /* On non independent devices, probe simultaneously. */
                error = audio_hw_probe_fmt(sc, &fmt, mode);



Home | Main Index | Thread Index | Old Index