Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Simplify. Handle draining of vc[0] differently.



details:   https://anonhg.NetBSD.org/src/rev/be85f6615670
branches:  trunk
changeset: 349792:be85f6615670
user:      nat <nat%NetBSD.org@localhost>
date:      Fri Dec 23 21:01:00 2016 +0000

description:
Simplify.  Handle draining of vc[0] differently.

Addresses PR kern/51710 audio playback works only once.

diffstat:

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

diffs (102 lines):

diff -r ad80754d3631 -r be85f6615670 sys/dev/audio.c
--- a/sys/dev/audio.c   Fri Dec 23 20:49:02 2016 +0000
+++ b/sys/dev/audio.c   Fri Dec 23 21:01:00 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.285 2016/12/17 17:04:04 maya Exp $ */
+/*     $NetBSD: audio.c,v 1.286 2016/12/23 21:01:00 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.285 2016/12/17 17:04:04 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.286 2016/12/23 21:01:00 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -2094,6 +2094,7 @@
        KASSERT(mutex_owned(sc->sc_lock));
        KASSERT(mutex_owned(sc->sc_intr_lock));
        
+       error = 0;
        DPRINTF(("audio_drain: enter busy=%d\n", sc->sc_vchan[n]->sc_pbus));
        cb = &sc->sc_vchan[n]->sc_mpr;
        if (cb->mmapped)
@@ -2117,7 +2118,8 @@
                error = audiostartp(sc, n);
                if (error)
                        return error;
-       }
+       } else if (n == 0)
+               goto silence_buffer;
        /*
         * Play until a silence block has been played, then we
         * know all has been drained.
@@ -2144,6 +2146,8 @@
                        error = EIO;
        }
 
+silence_buffer:
+
        used = 0;
        if (sc->sc_opens == 1) {
                cb = &sc->sc_pr;
@@ -3266,6 +3270,8 @@
 
                if (sc->sc_trigger_started == false) {
                        mix_write(sc);
+                       mix_func(sc, &vc->sc_mpr, n);
+                       mix_write(sc);
 
                        cv_broadcast(&sc->sc_condvar);
                }
@@ -5243,9 +5249,6 @@
        blksize = vc->sc_mpr.blksize;
        cc = blksize;
 
-       if (sc->sc_trigger_started == false)
-               cc *= 2;
-
        cc1 = cc;
        if (vc->sc_pustream->inp + cc > vc->sc_pustream->end)
                cc1 = vc->sc_pustream->end - vc->sc_pustream->inp;
@@ -5283,10 +5286,6 @@
                        audio_clear(sc, 0);
                }
        }
-       if (sc->sc_trigger_started == false) {
-               vc->sc_mpr.s.outp = audio_stream_add_outp(&vc->sc_mpr.s,
-                   vc->sc_mpr.s.outp, blksize);
-       }
        sc->sc_trigger_started = true;
 }
 
@@ -5298,8 +5297,6 @@
 
        blksize = sc->sc_vchan[0]->sc_mpr.blksize;
        resid = blksize;
-       if (sc->sc_trigger_started == false)
-               resid *= 2;
 
        tomix = __UNCONST(cb->s.outp);
        orig = (int8_t *)(sc->sc_pr.s.start);
@@ -5336,8 +5333,6 @@
 
        blksize = sc->sc_vchan[0]->sc_mpr.blksize;
        resid = blksize;
-       if (sc->sc_trigger_started == false)
-               resid *= 2;
 
        tomix = __UNCONST(cb->s.outp);
        orig = (int16_t *)(sc->sc_pr.s.start);
@@ -5374,8 +5369,6 @@
 
        blksize = sc->sc_vchan[0]->sc_mpr.blksize;
        resid = blksize;
-       if (sc->sc_trigger_started == false)
-               resid *= 2;
 
        tomix = __UNCONST(cb->s.outp);
        orig = (int32_t *)(sc->sc_pr.s.start);



Home | Main Index | Thread Index | Old Index