Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Make sure buffer sizes are initialized correctly eve...



details:   https://anonhg.NetBSD.org/src/rev/3885206e6219
branches:  trunk
changeset: 581942:3885206e6219
user:      is <is%NetBSD.org@localhost>
date:      Sat Jun 11 08:14:19 2005 +0000

description:
Make sure buffer sizes are initialized correctly even when the pause state
is explicitly set. Without this, the machine would crash in the audio interupt when the driver
needs to divide by the block size (e.g., cs4281.c/cs4280.c).
Idea for the fix by yamt.

diffstat:

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

diffs (73 lines):

diff -r 15e1c14cb27e -r 3885206e6219 sys/dev/audio.c
--- a/sys/dev/audio.c   Fri Jun 10 23:48:24 2005 +0000
+++ b/sys/dev/audio.c   Sat Jun 11 08:14:19 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.195 2005/05/18 20:10:25 augustss Exp $     */
+/*     $NetBSD: audio.c,v 1.196 2005/06/11 08:14:19 is Exp $   */
 
 /*
  * Copyright (c) 1991-1993 Regents of the University of California.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.195 2005/05/18 20:10:25 augustss Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.196 2005/06/11 08:14:19 is Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -3082,7 +3082,7 @@
        int oldpblksize, oldrblksize;
        u_int gain;
        boolean_t rbus, pbus;
-       boolean_t cleared, modechange;
+       boolean_t cleared, modechange, pausechange;
        u_char balance;
 
        hw = sc->hw_if;
@@ -3097,6 +3097,7 @@
        error = 0;
        cleared = FALSE;
        modechange = FALSE;
+       pausechange = FALSE;
 
        pp = sc->sc_pparams;    /* Temporary encoding storage in */
        rp = sc->sc_rparams;    /* case setting the modes fails. */
@@ -3319,24 +3320,13 @@
 
        if (SPECIFIED_CH(p->pause)) {
                sc->sc_pr.pause = p->pause;
-               if (!p->pause && !sc->sc_pbus && (sc->sc_mode & AUMODE_PLAY)) {
-                       s = splaudio();
-                       error = audiostartp(sc);
-                       splx(s);
-                       if (error)
-                               return error;
-               }
+               pbus = !p->pause;
+               pausechange = TRUE;
        }
        if (SPECIFIED_CH(r->pause)) {
                sc->sc_rr.pause = r->pause;
-               if (!r->pause && !sc->sc_rbus &&
-                   (sc->sc_mode & AUMODE_RECORD)) {
-                       s = splaudio();
-                       error = audiostartr(sc);
-                       splx(s);
-                       if (error)
-                               return error;
-               }
+               rbus = !r->pause;
+               pausechange = TRUE;
        }
 
        if (SPECIFIED(ai->blocksize)) {
@@ -3392,7 +3382,7 @@
                        return error;
        }
 
-       if (cleared) {
+       if (cleared || pausechange) {
                s = splaudio();
                error = audio_initbufs(sc);
                if (error) goto err;



Home | Main Index | Thread Index | Old Index