diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2007-10-19 15:31:03 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2007-10-19 15:31:03 +0000 |
commit | 93a9da244eb6b22328860a761ffdf9e83cfed40b (patch) | |
tree | 51536b57e1418c73c3dd4c7c204f6605eb8447dc | |
parent | f3a9569f09cb11fc25be17446b7ef93cd358fd20 (diff) |
fix audio_calc_blksize() not to return larger block sizes than
the buffer size
ok jakemsr
-rw-r--r-- | sys/dev/audio.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c index 82c4fb09693..5fbc48aa129 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audio.c,v 1.81 2007/10/03 21:49:13 jakemsr Exp $ */ +/* $OpenBSD: audio.c,v 1.82 2007/10/19 15:31:02 ratchov Exp $ */ /* $NetBSD: audio.c,v 1.119 1999/11/09 16:50:47 augustss Exp $ */ /* @@ -1300,7 +1300,7 @@ audio_calc_blksize(struct audio_softc *sc, int mode) struct audio_hw_if *hw = sc->hw_if; struct audio_params *parm; struct audio_ringbuffer *rb; - int bs; + int bs, maxbs, fs; if (sc->sc_blkset) return; @@ -1313,9 +1313,12 @@ audio_calc_blksize(struct audio_softc *sc, int mode) rb = &sc->sc_rr; } - bs = parm->sample_rate * audio_blk_ms / 1000 * - parm->channels * parm->precision / NBBY * - parm->factor; + fs = parm->channels * parm->precision / NBBY * parm->factor; + bs = parm->sample_rate * audio_blk_ms / 1000 * fs; + maxbs = rb->bufsize / 2; + if (bs > maxbs) + bs = (maxbs / fs) * fs; + ROUNDSIZE(bs); if (hw->round_blocksize) bs = hw->round_blocksize(sc->hw_hdl, bs); |