Make the block size always a whole number of samples.

This commit is contained in:
mycroft 1996-01-07 06:21:02 +00:00
parent 6761817ae6
commit 0b6a86dfe5

View File

@ -1,4 +1,4 @@
/* $NetBSD: audio.c,v 1.13 1996/01/05 13:16:30 pk Exp $ */
/* $NetBSD: audio.c,v 1.14 1996/01/07 06:21:02 mycroft Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@ -808,18 +808,17 @@ audio_calc_blksize(sc)
struct audio_hw_if *hw = sc->hw_if;
int bs;
bs = hw->get_precision(sc->hw_hdl) / NBBY;
bs = hw->get_out_sr(sc->hw_hdl) * audio_blk_ms * bs / 1000;
bs = hw->get_out_sr(sc->hw_hdl) * audio_blk_ms / 1000;
if (bs == 0)
bs = 1;
bs *= hw->get_channels(sc->hw_hdl);
bs *= hw->get_precision(sc->hw_hdl) / NBBY;
if (bs > AU_RING_SIZE/2)
bs = AU_RING_SIZE/2;
bs = hw->round_blocksize(sc->hw_hdl, bs);
if (bs > AU_RING_SIZE)
bs = AU_RING_SIZE;
if (bs < 2) /* avoid zero blocksize */
bs = 2;
bs &= ~1; /* make it even, in case of stereo */
return(bs);
}