Hi, Roger,
I tried your code, and it works very well. I estimated that the speed was about 2ms per irp(200bytes) and good enough for the standard audio sampling rate of 44.1k. There is one thing I am not clear. I send irp with 200 bytes, but each time I just get 192 bytes (actual length) back. I guess that is normal? Other thing bothering me is, when I record a pure sine wave sound signal, the data I captured show some periodic jitters (non-smooth points) on the sine curve. Have any idea where should I look to solve this problem?

Thanks for your help!
Charles

From: Roger Lindsjö <[EMAIL PROTECTED]>
To: Charles Chen <[EMAIL PROTECTED]>
CC: [email protected]
Subject: Re: [javax-usb-devel] speed of submitting UsbIrp to an iso pipe
Date: Fri, 08 Jul 2005 10:23:28 +0200

Charles Chen wrote:

Dan,
I pasted the specifications of my USB device below. And the time for submitting 40 and 80 Irps are approximately 480 and 960 ms. It looks like 12 ms is still needed per irp. I used one of the alternate interface settings, which has IN iso endpoint. And thanks to your help before, I can submit various audio class requests to the device to play with the settings of Mute, Volume, Automatic Gain, and Sampling Frequency. I am not sure what specific settings I have to make to make iso transfer work?

Could you show some more of your code? I use a xanboo device for video and with it i get close to 100% utilization of the USB capacity.

In my code I have two buffers of 20 IRPs each, built like this. (queue is an array of List with length 2).

    public void init() {
       int maxVideoPacketSize = pipe.getUsbEndpoint()
               .getUsbEndpointDescriptor().wMaxPacketSize();
       for (int i = 0; i < queue.length; i++) {
           queue[i] = new ArrayList(WORKING_PACKETS);
           for (int j = 0; j < WORKING_PACKETS; j++) {
               byte[] dataPacket = new byte[maxVideoPacketSize];
               UsbIrp irp = new DefaultUsbIrp(dataPacket, 0,
                       dataPacket.length, true);
               queue[i].add(irp);
           }
       }
   }

Then when running I start with submitting both lists and then wait for the IRPs of queue [0] and process them as they come back in. Once processed I resubmit the list and start processing queue[1]. Once all there is presessed I resubmit those IRPs and then restart with queue[0]. Something like:

   public void run() {
       for (int i = 0; i < queue.length; i++) {
           try {
               pipe.asyncSubmit(queue[i]);
           } catch (UsbException ue) {
               ue.printStackTrace();
           }
       }

       while (keepRunning) {
           try {
for (int index = 0; index < queue[queueIndex].size(); index++) {
                   DefaultUsbIrp irp = (DefaultUsbIrp) queue[queueIndex]
                           .get(index);
                   irp.waitUntilComplete();
                   consume(irp.getData(), irp.getActualLength());
                   irp.setComplete(false);
                   irp.setActualLength(0);
               }
               pipe.asyncSubmit(queue[queueIndex]);
               queueIndex++;
               queueIndex %= queue.length;
           } catch (UsbException ue) {
               ue.printStackTrace();
           }
       }
   }

//Roger Lindsjö


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
javax-usb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
javax-usb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to