From: Tim R. <ti...@pr...> - 2014-04-02 18:13:14
|
CF - Studelec wrote: > I'm currently trying to play/record simultaneous. Basically, i have > isochronous 1 IN and 1 OUT. > OUT is from a file, while IN goes to a file. performing a single > function is working flawlessly. > > I have hard time to figure how i must sequence IN and OUT, because > lib_usb_handle_events_completed(null, null) makes my sound jerky. > I have tryed to run it into a separate thread, fastest possible, while > i'm feeding via 2 callbacks my iso in and iso out, i have very jerky sounds. Your code here will never work. You cannot possibly use one request at a time on each pipe. To do isochronous streaming, you need to GUARANTEE that there is always a request waiting, even if the HCD has just completed a request. That means you MUST have at least two transfers in motion at all times, so USB can be processing #2 while you are handling #1. That presents a buffering problem, since you will be two buffers ahead. You have to decide how to handle that. Probably, it means you need to add latency. That is, you shove your incoming data into a circular buffer of some kind, and you don't start sending anything out until you have enough to fill two buffers. So prepare_iso_in(); libusb_submit_transfer(); prepare_iso_in(); libusb_submit_transfer(); prepare_iso_out(); libusb_submit_transfer(); prepare_iso_out(); libusb_submit_transfer(); while( !stop ) { libusb_handle_events(ctx); } Then, the callback handlers do the real work. -- Tim Roberts, ti...@pr... Providenza & Boekelheide, Inc. |