Modify audio_fill_silence() to take an encoding number rather than a softc*

and mode.
This commit is contained in:
mycroft 1997-03-13 02:45:07 +00:00
parent ac3b8b13b7
commit b0c4e068d0
1 changed files with 11 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: audio.c,v 1.35 1997/03/13 02:19:44 mycroft Exp $ */ /* $NetBSD: audio.c,v 1.36 1997/03/13 02:45:07 mycroft Exp $ */
/* /*
* Copyright (c) 1991-1993 Regents of the University of California. * Copyright (c) 1991-1993 Regents of the University of California.
@ -142,7 +142,7 @@ void audio_pint __P((void *));
void audio_rpint __P((void *)); void audio_rpint __P((void *));
int audio_calc_blksize __P((struct audio_softc *)); int audio_calc_blksize __P((struct audio_softc *));
void audio_fill_silence __P((struct audio_softc *, int, u_char *, int)); void audio_fill_silence __P((int, u_char *, int));
int audio_silence_copyout __P((struct audio_softc *, int, struct uio *)); int audio_silence_copyout __P((struct audio_softc *, int, struct uio *));
void audio_alloc_auzero __P((struct audio_softc *, int)); void audio_alloc_auzero __P((struct audio_softc *, int));
@ -838,16 +838,15 @@ audio_calc_blksize(sc)
} }
void void
audio_fill_silence(sc, mode, p, n) audio_fill_silence(encoding, p, n)
struct audio_softc *sc; int encoding;
int mode;
u_char *p; u_char *p;
int n; int n;
{ {
u_int auzero; u_int auzero;
u_char *q; u_char *q;
switch (mode == AUMODE_PLAY ? sc->sc_pencoding : sc->sc_rencoding) { switch (encoding) {
case AUDIO_ENCODING_ULAW: case AUDIO_ENCODING_ULAW:
auzero = 0x7f; auzero = 0x7f;
break; break;
@ -866,7 +865,7 @@ audio_fill_silence(sc, mode, p, n)
*q++ = auzero; *q++ = auzero;
} }
#define NSILENCE 16 /* An arbitrary even constant >= 2 */ #define NSILENCE 128 /* An arbitrary even constant >= 2 */
int int
audio_silence_copyout(sc, n, uio) audio_silence_copyout(sc, n, uio)
struct audio_softc *sc; struct audio_softc *sc;
@ -878,7 +877,7 @@ audio_silence_copyout(sc, n, uio)
u_char zerobuf[NSILENCE]; u_char zerobuf[NSILENCE];
int k; int k;
audio_fill_silence(sc, AUMODE_RECORD, zerobuf, NSILENCE); audio_fill_silence(sc->sc_rencoding, zerobuf, NSILENCE);
while (n > 0 && uio->uio_resid) { while (n > 0 && uio->uio_resid) {
iov = uio->uio_iov; iov = uio->uio_iov;
@ -924,7 +923,7 @@ audio_alloc_auzero(sc, bs)
panic("audio_alloc_auzero: malloc auzero_block failed"); panic("audio_alloc_auzero: malloc auzero_block failed");
} }
#endif #endif
audio_fill_silence(sc, AUMODE_PLAY, sc->auzero_block, bs); audio_fill_silence(sc->sc_pencoding, sc->auzero_block, bs);
if (hw->sw_encode) if (hw->sw_encode)
hw->sw_encode(sc->hw_hdl, sc->sc_pencoding, sc->auzero_block, bs); hw->sw_encode(sc->hw_hdl, sc->sc_pencoding, sc->auzero_block, bs);
} }
@ -992,7 +991,7 @@ audio_write(dev, uio, ioflag)
cb->nblk = sc->sc_backlog; cb->nblk = sc->sc_backlog;
cb->tp = cb->hp + sc->sc_backlog * blocksize; cb->tp = cb->hp + sc->sc_backlog * blocksize;
splx(s); splx(s);
audio_fill_silence(sc, AUMODE_PLAY, cb->hp, sc->sc_backlog * blocksize); audio_fill_silence(sc->sc_pencoding, cb->hp, sc->sc_backlog * blocksize);
} }
#endif #endif
/* Calculate sample number of first sample in block we write */ /* Calculate sample number of first sample in block we write */
@ -1029,7 +1028,7 @@ audio_write(dev, uio, ioflag)
/* fill with audio silence */ /* fill with audio silence */
tp += cc; tp += cc;
cc = blocksize - cc; cc = blocksize - cc;
audio_fill_silence(sc, AUMODE_PLAY, tp, cc); audio_fill_silence(sc->sc_pencoding, tp, cc);
DPRINTF(("audio_write: auzero 0x%x %d 0x%x\n", DPRINTF(("audio_write: auzero 0x%x %d 0x%x\n",
tp, cc, *(int *)tp)); tp, cc, *(int *)tp));
tp += cc; tp += cc;