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/f1083eae3f4f
branches:  trunk
changeset: 983821:f1083eae3f4f
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 3e4266416625 -r f1083eae3f4f 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 @@
        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