Source-Changes-HG archive

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

[src/trunk]: src/lib/libossaudio ossaudio(3): continue getting capabilities i...



details:   https://anonhg.NetBSD.org/src/rev/1f1edc6d63d4
branches:  trunk
changeset: 379580:1f1edc6d63d4
user:      nia <nia%NetBSD.org@localhost>
date:      Wed Jun 09 14:49:13 2021 +0000

description:
ossaudio(3): continue getting capabilities if AUDIO_GETFORMAT fails

we want this to work on mixer devices too

diffstat:

 lib/libossaudio/oss_caps.c |  31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diffs (51 lines):

diff -r 25dc616fcbd8 -r 1f1edc6d63d4 lib/libossaudio/oss_caps.c
--- a/lib/libossaudio/oss_caps.c        Wed Jun 09 06:00:16 2021 +0000
+++ b/lib/libossaudio/oss_caps.c        Wed Jun 09 14:49:13 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: oss_caps.c,v 1.1 2021/06/08 18:43:54 nia Exp $ */
+/*     $NetBSD: oss_caps.c,v 1.2 2021/06/09 14:49:13 nia Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -41,27 +41,26 @@ oss_private int
        if (ioctl(fd, AUDIO_GETPROPS, &props) < 0)
                return -1;
 
-       if (ioctl(fd, AUDIO_GETFORMAT, &info) < 0)
-               return -1;
-
        caps = 0;
        caps |= PCM_CAP_TRIGGER;
        caps |= PCM_CAP_MULTI;
        caps |= PCM_CAP_FREERATE;
 
-       nchannels = (props & AUDIO_PROP_PLAYBACK) ?
-           info.play.channels : info.record.channels;
+       if (ioctl(fd, AUDIO_GETFORMAT, &info) != -1) {
+               nchannels = (props & AUDIO_PROP_PLAYBACK) ?
+                   info.play.channels : info.record.channels;
 
-       switch (nchannels) {
-       case 2:
-               caps |= DSP_CH_STEREO;
-               break;
-       case 1:
-               caps |= DSP_CH_MONO;
-               break;
-       default:
-               caps |= DSP_CH_MULTI;
-               break;
+               switch (nchannels) {
+               case 2:
+                       caps |= DSP_CH_STEREO;
+                       break;
+               case 1:
+                       caps |= DSP_CH_MONO;
+                       break;
+               default:
+                       caps |= DSP_CH_MULTI;
+                       break;
+               }
        }
 
        if (props & AUDIO_PROP_FULLDUPLEX)



Home | Main Index | Thread Index | Old Index