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(4): Revert revision 1.96 and redo it ano...



details:   https://anonhg.NetBSD.org/src/rev/608298363507
branches:  trunk
changeset: 1021605:608298363507
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Jun 08 09:46:04 2021 +0000

description:
audio(4): Revert revision 1.96 and redo it another way.

Instead of refusing to open /dev/audioN for writes when the device
doesn't support playback, just refuse to issue writes.

Although it seems more sensible to me to reject writable opens early
on, and it seems Solaris does so, this makes querying device
properties a little trickier and is a change to the NetBSD semantics.

diffstat:

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

diffs (51 lines):

diff -r 6d1623db2b22 -r 608298363507 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Tue Jun 08 09:09:28 2021 +0000
+++ b/sys/dev/audio/audio.c     Tue Jun 08 09:46:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.103 2021/06/04 08:57:05 riastradh Exp $    */
+/*     $NetBSD: audio.c,v 1.104 2021/06/08 09:46:04 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.103 2021/06/04 08:57:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.104 2021/06/08 09:46:04 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2255,20 +2255,10 @@
        af = kmem_zalloc(sizeof(*af), KM_SLEEP);
        af->sc = sc;
        af->dev = dev;
-       if (flags & FWRITE) {
-               if (!audio_can_playback(sc)) {
-                       error = ENXIO;
-                       goto bad;
-               }
+       if ((flags & FWRITE) != 0 && audio_can_playback(sc))
                af->mode |= AUMODE_PLAY | AUMODE_PLAY_ALL;
-       }
-       if (flags & FREAD) {
-               if (!audio_can_capture(sc)) {
-                       error = ENXIO;
-                       goto bad;
-               }
+       if ((flags & FREAD) != 0 && audio_can_capture(sc))
                af->mode |= AUMODE_RECORD;
-       }
        if (af->mode == 0) {
                error = ENXIO;
                goto bad;
@@ -2821,7 +2811,8 @@
        int error;
 
        track = file->ptrack;
-       KASSERT(track);
+       if (track == NULL)
+               return EPERM;
 
        /* I think it's better than EINVAL. */
        if (track->mmapped)



Home | Main Index | Thread Index | Old Index