Index: uaudio.c =================================================================== RCS file: /home/ncvs/src/sys/dev/sound/usb/uaudio.c,v retrieving revision 1.7 diff -u -r1.7 uaudio.c --- uaudio.c 25 Aug 2002 01:32:22 -0000 1.7 +++ uaudio.c 31 May 2004 01:23:16 -0000 @@ -2769,18 +2769,52 @@ return; } -void +uint32_t uaudio_chan_set_param_speed(device_t dev, u_int32_t speed) { struct uaudio_softc *sc; struct chan *ch; + int realspeed = 0; + int i,j; sc = device_get_softc(dev); ch = &sc->sc_chan; - ch->sample_rate = speed; + for (i = 0; i < sc->sc_nalts; i++) { + struct usb_audio_streaming_type1_descriptor *a1d = + sc->sc_alts[i].asf1desc; + if (a1d->bSamFreqType == UA_SAMP_CONTNUOUS) { + DPRINTFN(2,("uaudio_set_params: cont %d-%d\n", + UA_SAMP_LO(a1d), UA_SAMP_HI(a1d))); + if (UA_SAMP_LO(a1d) < speed && + speed < UA_SAMP_HI(a1d)){ + realspeed = speed; + goto found; + } + else + realspeed = (realspeed >UA_SAMP_HI(a1d))? + realspeed: UA_SAMP_HI(a1d) ; + } else { + for (j = 0; j < a1d->bSamFreqType; j++) { + DPRINTFN(2,("uaudio_set_params: disc #" + "%d: %d\n", j, UA_GETSAMP(a1d, j))); + /* XXX allow for some slack */ + if (UA_GETSAMP(a1d, j) == + speed){ + realspeed = speed; + goto found; + } + realspeed = + (realspeed > UA_GETSAMP(a1d,j))? + realspeed : UA_GETSAMP(a1d,j); + } + } + } + + found: + ch->sample_rate = realspeed; - return; + return realspeed; } int Index: uaudio.h =================================================================== RCS file: /home/ncvs/src/sys/dev/sound/usb/uaudio.h,v retrieving revision 1.1 diff -u -r1.1 uaudio.h --- uaudio.h 21 Jul 2002 17:28:50 -0000 1.1 +++ uaudio.h 31 May 2004 01:21:58 -0000 @@ -39,7 +39,7 @@ #endif void uaudio_chan_set_param(device_t, u_char *, u_char *); void uaudio_chan_set_param_blocksize(device_t dev, u_int32_t blocksize); -void uaudio_chan_set_param_speed(device_t dev, u_int32_t speed); +uint32_t uaudio_chan_set_param_speed(device_t dev, u_int32_t speed); void uaudio_chan_set_param_format(device_t dev, u_int32_t format); int uaudio_chan_getptr(device_t dev); void uaudio_mixer_set(device_t dev, unsigned type, unsigned left, Index: uaudio_pcm.c =================================================================== RCS file: /home/ncvs/src/sys/dev/sound/usb/uaudio_pcm.c,v retrieving revision 1.3 diff -u -r1.3 uaudio_pcm.c --- uaudio_pcm.c 1 Jul 2003 15:52:02 -0000 1.3 +++ uaudio_pcm.c 31 May 2004 01:24:43 -0000 @@ -126,11 +126,10 @@ struct ua_info *ua; struct ua_chinfo *ch = data; - ch->spd = speed; ua = ch->parent; pa_dev = device_get_parent(ua->sc_dev); - uaudio_chan_set_param_speed(pa_dev, speed); + ch->spd = uaudio_chan_set_param_speed(pa_dev, speed); return ch->spd; }