* uaudio_round_blocksize()
calculate playing blocksize and recording blocksize independently
This commit is contained in:
parent
55940f7c4e
commit
9dd560ddf7
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: uaudio.c,v 1.95 2005/01/16 06:02:19 dsainty Exp $ */
|
/* $NetBSD: uaudio.c,v 1.96 2005/01/16 12:46:00 kent Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.95 2005/01/16 06:02:19 dsainty Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.96 2005/01/16 12:46:00 kent Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -2220,26 +2220,35 @@ uaudio_round_blocksize(void *addr, int blk,
|
||||||
int mode, const audio_params_t *param)
|
int mode, const audio_params_t *param)
|
||||||
{
|
{
|
||||||
struct uaudio_softc *sc;
|
struct uaudio_softc *sc;
|
||||||
int bpf;
|
int b;
|
||||||
|
|
||||||
sc = addr;
|
sc = addr;
|
||||||
DPRINTF(("uaudio_round_blocksize: p.bpf=%d r.bpf=%d\n",
|
DPRINTF(("uaudio_round_blocksize: blk=%d mode=%s\n", blk,
|
||||||
sc->sc_playchan.bytes_per_frame,
|
mode == AUMODE_PLAY ? "AUMODE_PLAY" : "AUMODE_RECORD"));
|
||||||
sc->sc_recchan.bytes_per_frame));
|
|
||||||
if (sc->sc_playchan.bytes_per_frame > sc->sc_recchan.bytes_per_frame) {
|
/* chan.bytes_per_frame can be 0. */
|
||||||
bpf = sc->sc_playchan.bytes_per_frame
|
if (mode == AUMODE_PLAY || sc->sc_recchan.bytes_per_frame <= 0) {
|
||||||
+ sc->sc_playchan.sample_size;
|
b = param->sample_rate * UAUDIO_NFRAMES * UAUDIO_NCHANBUFS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This does not make accurate value in the case
|
||||||
|
* of b % USB_FRAMES_PER_SECOND != 0
|
||||||
|
*/
|
||||||
|
b /= USB_FRAMES_PER_SECOND;
|
||||||
|
|
||||||
|
b *= param->precision / 8 * param->channels;
|
||||||
} else {
|
} else {
|
||||||
bpf = sc->sc_recchan.bytes_per_frame
|
/*
|
||||||
+ sc->sc_recchan.sample_size;
|
* use wMaxPacketSize in bytes_per_frame.
|
||||||
|
* See uaudio_set_params() and uaudio_chan_init()
|
||||||
|
*/
|
||||||
|
b = sc->sc_recchan.bytes_per_frame
|
||||||
|
* UAUDIO_NFRAMES * UAUDIO_NCHANBUFS;
|
||||||
}
|
}
|
||||||
/* XXX */
|
|
||||||
bpf *= UAUDIO_NFRAMES * UAUDIO_NCHANBUFS;
|
|
||||||
|
|
||||||
bpf = (bpf + 15) &~ 15;
|
if (b <= 0)
|
||||||
|
b = 1;
|
||||||
if (blk < bpf)
|
blk = blk <= b ? b : blk / b * b;
|
||||||
blk = bpf;
|
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
if (blk <= 0) {
|
if (blk <= 0) {
|
||||||
|
@ -2248,7 +2257,7 @@ uaudio_round_blocksize(void *addr, int blk,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DPRINTFN(1,("uaudio_round_blocksize: blk=%d\n", blk));
|
DPRINTF(("uaudio_round_blocksize: resultant blk=%d\n", blk));
|
||||||
return blk;
|
return blk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue