Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Improved draining function for when the mixer is and...



details:   https://anonhg.NetBSD.org/src/rev/c0c9ac06eeda
branches:  trunk
changeset: 827850:c0c9ac06eeda
user:      nat <nat%NetBSD.org@localhost>
date:      Wed Nov 15 01:55:45 2017 +0000

description:
Improved draining function for when the mixer is and is not enabled.

One block of silence is also played in audio drivers using start_output
when draining the hardware, this helps playback of short (less than
blocksize) samples.

diffstat:

 sys/dev/audio.c |  17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diffs (51 lines):

diff -r 753bbe556472 -r c0c9ac06eeda sys/dev/audio.c
--- a/sys/dev/audio.c   Wed Nov 15 01:49:59 2017 +0000
+++ b/sys/dev/audio.c   Wed Nov 15 01:55:45 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.433 2017/11/15 01:49:59 nat Exp $  */
+/*     $NetBSD: audio.c,v 1.434 2017/11/15 01:55:45 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.433 2017/11/15 01:49:59 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.434 2017/11/15 01:55:45 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2402,13 +2402,13 @@
                return 0;
 
        used = audio_stream_get_used(&cb->s);
-       if (vc == sc->sc_hwvc) {
+       if (vc == sc->sc_hwvc && sc->sc_usemixer) {
                hw = true;
                used += audio_stream_get_used(&sc->sc_mixring.sc_mpr.s);
        }
        for (i = 0; i < vc->sc_npfilters; i++)
                used += audio_stream_get_used(&vc->sc_pstreams[i]);
-       if (used <= 0 || (hw == true && sc->hw_if->trigger_output == NULL))
+       if (used <= 0)
                return 0;
 
        if (hw == false && !vc->sc_pbus) {
@@ -2457,9 +2457,14 @@
 #endif
        vc->sc_draining = true;
 
-       drops = cb->drops + (cb->blksize * PREFILL_BLOCKS);
+       drops = cb->drops;
+       if (vc == sc->sc_hwvc)
+               drops += cb->blksize;
+       else if (sc->sc_usemixer)
+               drops += sc->sc_mixring.sc_mpr.blksize * PREFILL_BLOCKS;
+
        error = 0;
-       while (cb->drops < drops && !error) {
+       while (cb->drops <= drops && !error) {
                DPRINTF(("audio_drain: vc=%p used=%d, drops=%ld\n",
                        vc,
                        audio_stream_get_used(&vc->sc_mpr.s),



Home | Main Index | Thread Index | Old Index