Module Name: src Committed By: nat Date: Sat Jun 23 03:18:49 UTC 2018
Modified Files: src/sys/dev: auconv.c Log Message: Add all encoding supported by the mixer. Addresses PR kern/52585. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/dev/auconv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/auconv.c diff -u src/sys/dev/auconv.c:1.35 src/sys/dev/auconv.c:1.36 --- src/sys/dev/auconv.c:1.35 Sat Dec 16 16:09:36 2017 +++ src/sys/dev/auconv.c Sat Jun 23 03:18:49 2018 @@ -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 @@ auconv_create_encodings(const struct aud { 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 @@ auconv_create_encodings(const struct aud 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); - 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); + + for (j = 0; j < __arraycount(enc_precision); j++) { 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, - AUDIO_ENCODINGFLAG_EMULATED); - ADD_ENCODING(AUDIO_ENCODING_SLINEAR_LE, - formats[i].precision, + enc_precision[j], 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_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(AUDIO_ENCODING_SLINEAR, 8, + AUDIO_ENCODINGFLAG_EMULATED); + ADD_ENCODING(AUDIO_ENCODING_ULINEAR, 8, + AUDIO_ENCODINGFLAG_EMULATED); +#if NMULAW > 0 + ADD_ENCODING(AUDIO_ENCODING_ULAW, 8, + AUDIO_ENCODINGFLAG_EMULATED); + ADD_ENCODING(AUDIO_ENCODING_ALAW, 8, + AUDIO_ENCODINGFLAG_EMULATED); +#endif + ADD_ENCODING(formats[i].encoding, + formats[i].precision, 0); } *encodings = buf; return 0;