Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Add all encoding supported by the mixer.



details:   https://anonhg.NetBSD.org/src/rev/bd137e92a376
branches:  trunk
changeset: 323618:bd137e92a376
user:      nat <nat%NetBSD.org@localhost>
date:      Sat Jun 23 03:18:49 2018 +0000

description:
Add all encoding supported by the mixer.

Addresses PR kern/52585.

diffstat:

 sys/dev/auconv.c |  128 +++++++++---------------------------------------------
 1 files changed, 21 insertions(+), 107 deletions(-)

diffs (167 lines):

diff -r 219c063ea6a0 -r bd137e92a376 sys/dev/auconv.c
--- a/sys/dev/auconv.c  Sat Jun 23 03:15:55 2018 +0000
+++ b/sys/dev/auconv.c  Sat Jun 23 03:18:49 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: auconv.c,v 1.35 2017/12/16 16:09:36 nat Exp $  */
+/*     $NetBSD: auconv.c,v 1.36 2018/06/23 03:18:49 nat Exp $  */
 
 /*
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.35 2017/12/16 16:09:36 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.36 2018/06/23 03:18:49 nat Exp $");
 
 #include <sys/types.h>
 #include <sys/audioio.h>
@@ -2340,8 +2340,9 @@
 {
        struct audio_encoding_set *buf;
        int capacity;
-       int i;
+       int i, j;
        int err;
+       static int enc_precision[] = { 16, 32 };
 
 #define        ADD_ENCODING(enc, prec, flags)  do { \
        err = auconv_add_encoding(enc, prec, flags, &buf, &capacity); \
@@ -2358,120 +2359,33 @@
        for (i = 0; i < nformats; i++) {
                if (!AUFMT_IS_VALID(&formats[i]))
                        continue;
-               switch (formats[i].encoding) {
-               case AUDIO_ENCODING_SLINEAR_LE:
-                       ADD_ENCODING(formats[i].encoding,
-                                    formats[i].precision, 0);
+
+               for (j = 0; j < __arraycount(enc_precision); j++) {
                        ADD_ENCODING(AUDIO_ENCODING_SLINEAR_BE,
-                                    formats[i].precision,
-                                    AUDIO_ENCODINGFLAG_EMULATED);
-                       ADD_ENCODING(AUDIO_ENCODING_ULINEAR_LE,
-                                    formats[i].precision,
-                                    AUDIO_ENCODINGFLAG_EMULATED);
-                       ADD_ENCODING(AUDIO_ENCODING_ULINEAR_BE,
-                                    formats[i].precision,
-                                    AUDIO_ENCODINGFLAG_EMULATED);
-#if NMULAW > 0
-                       if (formats[i].precision == 8
-                           || formats[i].precision == 16) {
-                               ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
-                                            AUDIO_ENCODINGFLAG_EMULATED);
-                               ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
-                                            AUDIO_ENCODINGFLAG_EMULATED);
-                       }
-#endif
-                       break;
-               case AUDIO_ENCODING_SLINEAR_BE:
-                       ADD_ENCODING(formats[i].encoding,
-                                    formats[i].precision, 0);
-                       ADD_ENCODING(AUDIO_ENCODING_SLINEAR_LE,
-                                    formats[i].precision,
-                                    AUDIO_ENCODINGFLAG_EMULATED);
-                       ADD_ENCODING(AUDIO_ENCODING_ULINEAR_LE,
-                                    formats[i].precision,
-                                    AUDIO_ENCODINGFLAG_EMULATED);
-                       ADD_ENCODING(AUDIO_ENCODING_ULINEAR_BE,
-                                    formats[i].precision,
-                                    AUDIO_ENCODINGFLAG_EMULATED);
-#if NMULAW > 0
-                       if (formats[i].precision == 8
-                           || formats[i].precision == 16) {
-                               ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
-                                            AUDIO_ENCODINGFLAG_EMULATED);
-                               ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
-                                            AUDIO_ENCODINGFLAG_EMULATED);
-                       }
-#endif
-                       break;
-               case AUDIO_ENCODING_ULINEAR_LE:
-                       ADD_ENCODING(formats[i].encoding,
-                                    formats[i].precision, 0);
-                       ADD_ENCODING(AUDIO_ENCODING_SLINEAR_BE,
-                                    formats[i].precision,
+                                    enc_precision[j],
                                     AUDIO_ENCODINGFLAG_EMULATED);
                        ADD_ENCODING(AUDIO_ENCODING_SLINEAR_LE,
-                                    formats[i].precision,
+                                    enc_precision[j],
                                     AUDIO_ENCODINGFLAG_EMULATED);
                        ADD_ENCODING(AUDIO_ENCODING_ULINEAR_BE,
-                                    formats[i].precision,
-                                    AUDIO_ENCODINGFLAG_EMULATED);
-#if NMULAW > 0
-                       if (formats[i].precision == 8
-                           || formats[i].precision == 16) {
-                               ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
-                                            AUDIO_ENCODINGFLAG_EMULATED);
-                               ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
-                                            AUDIO_ENCODINGFLAG_EMULATED);
-                       }
-#endif
-                       break;
-               case AUDIO_ENCODING_ULINEAR_BE:
-                       ADD_ENCODING(formats[i].encoding,
-                                    formats[i].precision, 0);
-                       ADD_ENCODING(AUDIO_ENCODING_SLINEAR_BE,
-                                    formats[i].precision,
+                                    enc_precision[j],
                                     AUDIO_ENCODINGFLAG_EMULATED);
                        ADD_ENCODING(AUDIO_ENCODING_ULINEAR_LE,
-                                    formats[i].precision,
+                                    enc_precision[j],
                                     AUDIO_ENCODINGFLAG_EMULATED);
-                       ADD_ENCODING(AUDIO_ENCODING_SLINEAR_LE,
-                                    formats[i].precision,
-                                    AUDIO_ENCODINGFLAG_EMULATED);
+               }
+               ADD_ENCODING(AUDIO_ENCODING_SLINEAR, 8,
+                            AUDIO_ENCODINGFLAG_EMULATED);
+               ADD_ENCODING(AUDIO_ENCODING_ULINEAR, 8,
+                            AUDIO_ENCODINGFLAG_EMULATED);
 #if NMULAW > 0
-                       if (formats[i].precision == 8
-                           || formats[i].precision == 16) {
-                               ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
-                                            AUDIO_ENCODINGFLAG_EMULATED);
-                               ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
-                                            AUDIO_ENCODINGFLAG_EMULATED);
-                       }
+               ADD_ENCODING(AUDIO_ENCODING_ULAW, 8,
+                            AUDIO_ENCODINGFLAG_EMULATED);
+               ADD_ENCODING(AUDIO_ENCODING_ALAW, 8,
+                            AUDIO_ENCODINGFLAG_EMULATED);
 #endif
-                       break;
-
-               case AUDIO_ENCODING_ULAW:
-               case AUDIO_ENCODING_ALAW:
-               case AUDIO_ENCODING_ADPCM:
-               case AUDIO_ENCODING_MPEG_L1_STREAM:
-               case AUDIO_ENCODING_MPEG_L1_PACKETS:
-               case AUDIO_ENCODING_MPEG_L1_SYSTEM:
-               case AUDIO_ENCODING_MPEG_L2_STREAM:
-               case AUDIO_ENCODING_MPEG_L2_PACKETS:
-               case AUDIO_ENCODING_MPEG_L2_SYSTEM:
-               case AUDIO_ENCODING_AC3:
-                       ADD_ENCODING(formats[i].encoding,
-                                    formats[i].precision, 0);
-                       break;
-
-               case AUDIO_ENCODING_SLINEAR:
-               case AUDIO_ENCODING_ULINEAR:
-               case AUDIO_ENCODING_LINEAR:
-               case AUDIO_ENCODING_LINEAR8:
-               default:
-                       printf("%s: invalid encoding value "
-                              "for audio_format: %d\n",
-                              __func__, formats[i].encoding);
-                       break;
-               }
+               ADD_ENCODING(formats[i].encoding,
+                            formats[i].precision, 0);
        }
        *encodings = buf;
        return 0;



Home | Main Index | Thread Index | Old Index