diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-07-21 05:57:20 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-07-21 05:57:20 +0000 |
commit | f06de7574f988e1a98180c2c62e5b9d5c1f95292 (patch) | |
tree | fa30ca881df32760e5b4ba70a1c0dda3075bb009 /sys/dev/usb/uaudio.c | |
parent | b817784f121e994facf96a93ec63918abfb463ea (diff) |
* check that the bytes per frame the device is reporting isn't a
ridiculous value.
* encoding expansion factor is always 1.
Diffstat (limited to 'sys/dev/usb/uaudio.c')
-rw-r--r-- | sys/dev/usb/uaudio.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index c64b7e3172e..5e2ba965f3d 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.81 2010/07/21 05:54:42 jakemsr Exp $ */ +/* $OpenBSD: uaudio.c,v 1.82 2010/07/21 05:57:19 jakemsr Exp $ */ /* $NetBSD: uaudio.c,v 1.90 2004/10/29 17:12:53 kent Exp $ */ /* @@ -1602,7 +1602,7 @@ uaudio_process_as(struct uaudio_softc *sc, const char *buf, int *offsp, const usb_endpoint_descriptor_audio_t *ed; const usb_endpoint_descriptor_audio_t *epdesc1; const struct usb_audio_streaming_endpoint_descriptor *sed; - int format, chan, prec, enc; + int format, chan, prec, enc, bps; int dir, type, sync; struct as_info ai; const char *format_str; @@ -1727,9 +1727,10 @@ uaudio_process_as(struct uaudio_softc *sc, const char *buf, int *offsp, format = UGETW(asid->wFormatTag); chan = asf1d->bNrChannels; prec = asf1d->bBitResolution; - if (prec != 8 && prec != 16 && prec != 24) { - printf("%s: ignored setting with precision %d\n", - sc->sc_dev.dv_xname, prec); + bps = asf1d->bSubFrameSize; + if ((prec != 8 && prec != 16 && prec != 24) || (bps < 1 || bps > 4)) { + printf("%s: ignored setting with precision %d bps %d\n", + sc->sc_dev.dv_xname, prec, bps); return (USBD_NORMAL_COMPLETION); } switch (format) { @@ -3026,7 +3027,7 @@ uaudio_chan_init(struct chan *ch, int mode, int altidx, ch->altidx = altidx; ch->maxpktsize = UGETW(ai->edesc->wMaxPacketSize); ch->sample_rate = param->sample_rate; - ch->sample_size = param->factor * param->channels * param->bps; + ch->sample_size = param->channels * param->bps; ch->usb_fps = USB_FRAMES_PER_SECOND; ch->hi_speed = ch->sc->sc_udev->speed == USB_SPEED_HIGH; if (ch->hi_speed) { |