On Mon, Aug 25, 2014 at 10:52 PM, Jassi Brar <jassisinghbrar@xxxxxxxxx> wrote: > On Mon, Aug 25, 2014 at 9:30 PM, Daniel Mack <zonque@xxxxxxxxx> wrote: >> The UAC2 function driver currently responds to all packets at all times >> with wMaxPacketSize packets. That results in way too fast audio >> playback as the function driver (which is in fact supposed to define >> the audio stream pace) delivers as fast as it can. >> >> Fix this by pre-calculating the size of each packet to meet the >> requested sample rate and format. This won't be 100% accurate, but >> that's acceptable. >> > For rates like 44100 we will always hear clicks because we can not > transfer 176400bytes by packets of equal size over duration of 1 > second. The inaccuracy here is due to the way we program, and not due > to system/bus load. > > Have you tried the approach I suggested - {4x176, 1x178} pattern > packets, and does that not work? Please let me know if I am > overlooking something. Otherwise let us do the best we can (If you > want me to give that a try, I can in a day or two). > >> @@ -187,7 +189,7 @@ agdev_iso_complete(struct usb_ep *ep, struct usb_request *req) >> >> if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { >> src = prm->dma_area + prm->hw_ptr; >> - req->actual = req->length; >> + req->length = req->actual = uac2->c_pktsize; >> > This doesn't seem right. > We asked req->length to be transmitted by the udc which shouldn't > return until that is done. So at this point setting 'length' doesn't > mean much. The original assignment to 'actual' is only because we want > to ignore any issue that caused the udc to transmit fewer bytes (we > drop that data). > > I believe you want to do the following in afunc_set_alt(). > - req->length = prm->max_psize; > + req->length = uac2->c_pktsize; > Sorry I intended... - prm->max_psize = hs_epin_desc.wMaxPacketSize; + prm->max_psize = agdev->uac2.c_pktsize; Also USB-IN is capture for host, but in f_uac2 it is playback. So you may want to do - rate = opts->c_srate * opts->c_ssize * num_channels(opts->c_chmask); - rate = opts->p_srate * opts->p_ssize * num_channels(opts->p_chmask); BTW, why not do the same for USB-OUT as well? it shouldn't hurt. Thanks Jassi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html