Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pad Write slinear_le 16bit samples, independent from...



details:   https://anonhg.NetBSD.org/src/rev/ebcd4cfb80ff
branches:  trunk
changeset: 374199:ebcd4cfb80ff
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Mon Apr 10 15:04:49 2023 +0000

description:
Write slinear_le 16bit samples, independent from platform and
AUDIO_INTERNAL_BITS.

diffstat:

 sys/dev/pad/pad.c |  31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r 69120fbd6da2 -r ebcd4cfb80ff sys/dev/pad/pad.c
--- a/sys/dev/pad/pad.c Mon Apr 10 06:08:55 2023 +0000
+++ b/sys/dev/pad/pad.c Mon Apr 10 15:04:49 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.79 2023/01/24 08:17:11 mlelstv Exp $ */
+/* $NetBSD: pad.c,v 1.80 2023/04/10 15:04:49 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.79 2023/01/24 08:17:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.80 2023/04/10 15:04:49 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -745,7 +745,7 @@ pad_swvol_codec(audio_filter_arg_t *arg)
 {
        struct pad_softc *sc = arg->context;
        const aint_t *src;
-       aint_t *dst;
+       uint8_t *dst;
        u_int sample_count;
        u_int i;
 
@@ -755,7 +755,30 @@ pad_swvol_codec(audio_filter_arg_t *arg)
        for (i = 0; i < sample_count; i++) {
                aint2_t v = (aint2_t)(*src++);
                v = v * sc->sc_swvol / 255;
-               *dst++ = (aint_t)v;
+
+               CTASSERT(PADPREC <= AUDIO_INTERNAL_BITS * 2);
+#if PADPREC > AUDIO_INTERNAL_BITS
+               v = v << (PADPREC - AUDIO_INTERNAL_BITS);
+#elif PADPREC < AUDIO_INTERNAL_BITS
+               v = v >> (AUDIO_INTERNAL_BITS - PADPREC);
+#endif
+
+               /* AUDIO_ENCODING_SLINEAR_LE */
+#if PADPREC > 0
+               *dst++ = v;
+#endif
+#if PADPREC > 8
+               v >>= 8;
+               *dst++ = v;
+#endif
+#if PADPREC > 16
+               v >>= 8;
+               *dst++ = v;
+#endif
+#if PADPREC > 24
+               v >>= 8;
+               *dst++ = v;
+#endif
        }
 }
 



Home | Main Index | Thread Index | Old Index