|
From: Tim R. <ti...@pr...> - 2016-03-18 17:34:03
|
Matías Araujo wrote: > I'm using an iso_transfer to record audio from an usb device. The device is > working at 48000 Hz, 2 channels and 16 bits. Why on earth are you doing this directly to USB, instead of using your system's normal audio APIs? They are designed to handle all of this kind of thing, and then you don't have to rewrite your application completely when you move to a system with a PCI-based audio device. > I'm not sure how the data is distributed in the iso packet buffer because > the function "libusb_get_iso_packet_buffer_simple" returns an unsigned char* > and the size of the unsigned char is 1 byte (8 bits), but my device is > working with 2 channels with words of 16 bits (2 bytes). (I'm going to do some scolding here. I apologize in advance if you are thin-skinned.) Come on. You can't be serious. This is a fundamental C programming concept. This is a generic buffer. To the library, it's just a collection of bytes. It doesn't know how to interpret the data, so it simply declares it as a generic array of bytes. It's up to you to provide the interpretation. "unsigned char *" is an easy solution for generic buffers, because the address arithmetic is simple. Adding 3 advances by 3 bytes. That's not so for more complicated types. If you need to treat that buffer as an array of unsigned shorts, then you cast it to an "unsigned short *". Did you really not know that? Isochronous data is not straightforward. Remember that not every packet will have data in it, and the packets that DO have data might not be full. You MUST look at the packet lengths in the libusb_iso_packet_descriptor structure to know how much data is actually present. -- Tim Roberts, ti...@pr... Providenza & Boekelheide, Inc. |