Reputation: 2520
I am communicating with a UCG102 (Guitar Link) USB device using libusb and am getting -9 (LIBUSB_ERROR_PIPE which means the parameters are not supported) when setting the sampling rate using a synchronous control request. Here is the basic request details as logged by LIBUSB, you can't see the actual sample rate because it is in a 3-byte buffer as per the spec:
03-02 14:33:13.173: I/LIBUSB(9480): bmRequestType=22, bRequest=01, wValue=0100, wIndex=0084, wLength=0003
Code to set the sampleRate value
byte[] param2 = new byte[3];
param2[2] = (byte)(sampleRate >> 16); //0x44;
param2[1] = (byte)(sampleRate >> 8); // 0xAC;
param2[0] = (byte) (sampleRate & 0xff); //0x00;
The same code works for a number of other USB audio devices. I then go on to do isochronous audio (which kind of works on the UCG102 -- but not at the rate I want).
I should point out that the sampling rate has been selected from the device descriptors so I know that it is supported by this device.
So the question is how can I set the sample rate? Is there something I need to do before this (yes I already detached all the other interfaces and then claimed the ones I want). Do some devices expect the sample rate expressed in a way other then the USB audio spec suggests?
If you can't answer directly, maybe someone can point me at a Windows or Fedora library/application that will talk to my USB device (for audio purposes) and log out all the LIBUSB calls so I can see it working (or open source so I can put my own debug into it).
Your assistance is appreciated.
Upvotes: 1
Views: 877
Reputation: 2520
It turns out you can't do this with a set request on the input or output endpoints. You can effectively set the input sample rate by selecting the appropriate alternate setting on the interface as there is only one sample rate per alternate setting. On the output it has three sample rates per alternate setting and it just adapts to the rate that turns up. This is not really typical USB Audio 1.0 behavior, but it works.
Upvotes: 1