Source-Changes-HG archive

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

[src/trunk]: src/sys/dev round_blocksize is only used for the hardware ring b...



details:   https://anonhg.NetBSD.org/src/rev/7bb5ef1fbe48
branches:  trunk
changeset: 827522:7bb5ef1fbe48
user:      nat <nat%NetBSD.org@localhost>
date:      Tue Oct 31 21:09:26 2017 +0000

description:
round_blocksize is only used for the hardware ring buffer.  All other
buffers (mix ring, streams) are set to be a power of 2.

This allows for consistent latency where a static blocksize is enforced by
the underlying audio device driver.

Ok christos@.

diffstat:

 sys/dev/audio.c |  20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r 25b822cbf6f8 -r 7bb5ef1fbe48 sys/dev/audio.c
--- a/sys/dev/audio.c   Tue Oct 31 19:03:32 2017 +0000
+++ b/sys/dev/audio.c   Tue Oct 31 21:09:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.418 2017/10/28 03:34:26 riastradh Exp $    */
+/*     $NetBSD: audio.c,v 1.419 2017/10/31 21:09:26 nat Exp $  */
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -148,7 +148,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.418 2017/10/28 03:34:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.419 2017/10/31 21:09:26 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2004,9 +2004,21 @@
                blksize = rp->s.bufsize / AUMINNOBLK;
        ROUNDSIZE(blksize);
        DPRINTF(("audio_init_ringbuffer: MI blksize=%d\n", blksize));
-       if (sc->hw_if->round_blocksize)
+
+       struct virtual_channel *hwvc = sc->sc_hwvc;
+       if (sc->hw_if->round_blocksize &&
+           (rp == &hwvc->sc_mpr || rp == &hwvc->sc_mrr)) {
                blksize = sc->hw_if->round_blocksize(sc->hw_hdl, blksize,
-                                                    mode, &rp->s.param);
+                   mode, &rp->s.param);
+       } else {
+               int tmpblksize = 1;
+               /* round blocksize to a power of 2 */
+               while (tmpblksize < blksize)
+                       tmpblksize <<= 1;
+
+               blksize = tmpblksize;
+       }
+
        if (blksize <= 0)
                panic("audio_init_ringbuffer: blksize=%d", blksize);
        nblks = rp->s.bufsize / blksize;



Home | Main Index | Thread Index | Old Index