diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2009-12-04 20:51:00 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2009-12-04 20:51:00 +0000 |
commit | 0b50a4099fc32fd37a510bd1f34b71199d9373d4 (patch) | |
tree | 035e7f9eccf606100aa8fff1a3e4d1ffd4953ae4 /sys/dev | |
parent | c8bbf87ce742472bb08bf1a2a223ec2a1dfe0979 (diff) |
calculate the number of frames per usb xfer only once, and take into
account possible "fractional samples" which occur when the usb frame
rate is not a whole number factor of the audio sample rate, such as
with 44.1 kHz audio sample rate and full-speed usb (1 kHz frame rate).
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/uaudio.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index 038687ee64c..5d64bf555d4 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.72 2009/12/04 20:38:43 jakemsr Exp $ */ +/* $OpenBSD: uaudio.c,v 1.73 2009/12/04 20:50:59 jakemsr Exp $ */ /* $NetBSD: uaudio.c,v 1.90 2004/10/29 17:12:53 kent Exp $ */ /* @@ -2954,15 +2954,11 @@ uaudio_chan_set_param(struct chan *ch, u_char *start, u_char *end, int blksize) /* * Recompute nframes based on blksize, but make sure nframes - * is not longer in time duration than blksize. Rounding helps. + * is not longer in time duration than blksize. */ - if (ch->maxpktsize) { - ch->nframes = ch->blksize / ch->maxpktsize; - } else { - ch->nframes = (ch->blksize / ch->sample_size) * - ch->usb_fps / ch->sample_rate; - } - ch->nframes = ch->blksize / ch->bytes_per_frame; + ch->nframes = ch->blksize * ch->usb_fps / + (ch->bytes_per_frame * ch->usb_fps + + ch->sample_size * ch->fraction); if (ch->nframes > UAUDIO_MAX_FRAMES) ch->nframes = UAUDIO_MAX_FRAMES; else if (ch->nframes < 1) |