Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using the USB Audio Class Driver – Best Practices and Common Pitfalls

Similar presentations


Presentation on theme: "Using the USB Audio Class Driver – Best Practices and Common Pitfalls"— Presentation transcript:

1 Using the USB Audio Class Driver – Best Practices and Common Pitfalls
By Daniel “DJ” Sisolak (USBAudio.sys owner/developer)

2 Common Pitfalls in Creating USB Audio Class Compliant Devices
Descriptor errors or missing descriptors (Vista much more stringent than XP) Units that do not support required controls Bad/Unreasonable Control Ranges Interface/Endpoint descriptor values unusable Endian problems

3 Feature Unit: Most Common Error
Number of Controls MUST match channel count PLUS one control for Master. Example (from actual device): INPUT TERMINAL: BYTE Length: x0c BYTE DescriptorType: 0x24 BYTE DescriptorSubtype: 0x02 BYTE bUnitID: x01 SHORT wTerminalType: 0x0603 BYTE bAssocTerminal: 0x00 BYTE bNrChannels: x02 SHORT wChannelConfig: 0x0003 BYTE iChannelNames: 0x00 BYTE iTerminal: x00 FEATURE UNIT: BYTE Length: BYTE DescriptorType: 0x24 BYTE DescriptorSubtype: 0x06 BYTE bUnitID: x02 BYTE bSourceID: x01 BYTE bControlSize: x01 BYTE bmaControls: 0x03 0x00 BYTE iFeature: x00 0x09 0x0a Missing Control 0x00 Corollary: All required Feature Unit controls (GETMIN, GETMAX, GETRES, GETCUR and SETCUR) MUST be supported

4 Channel Configuration Does Not Match Channel Count
Usually found in (but not confined to) Input Terminal Channel Configuration CAN be 0 (no set configuration) If the ChannelConfig field is used it MUST match the number of channels Example (again from actual device): INPUT TERMINAL: BYTE Length: x0c BYTE DescriptorType: 0x24 BYTE DescriptorSubtype: 0x02 BYTE bUnitID: x01 SHORT wTerminalType: 0x0201 BYTE bAssocTerminal: 0x00 BYTE bNrChannels: x02 SHORT wChannelConfig: 0x0001 BYTE iChannelNames: 0x00 BYTE iTerminal: x00 Missing Channel Location

5 Selector Unit CANNOT take inputs with different Channel Counts or Configurations
Channel Count/Configuration at output becomes nebulous Use Mixer Unit if necessary INPUT TERMINAL: BYTE Length: x0c BYTE DescriptorType: 0x24 BYTE DescriptorSubtype: 0x02 BYTE bUnitID: x01 SHORT wTerminalType: 0x0201 BYTE bAssocTerminal: 0x00 BYTE bNrChannels: x08 SHORT wChannelConfig: 0x063f BYTE iChannelNames: 0x00 BYTE iTerminal: x00 INPUT TERMINAL: BYTE Length: x0c BYTE DescriptorType: 0x24 BYTE DescriptorSubtype: 0x02 BYTE bUnitID: x04 SHORT wTerminalType: 0x0201 BYTE bAssocTerminal: 0x00 BYTE bNrChannels: x02 SHORT wChannelConfig: 0x0003 BYTE iChannelNames: 0x00 BYTE iTerminal: x00 Incompatible SELECTOR UNIT: BYTE Length: x08 BYTE DescriptorType: 0x24 BYTE DescriptorSubtype: 0x05 BYTE bUnitID: x07 BYTE bNrInPins: x01 BYTE baSourceID[0]: 0x01 BYTE baSourceID[1]: 0x04 BYTE iSelector x00

6 Formula for byte count from Specification:
Mixer Unit MUST have Control Bits in its Bitmap for Each Input Channel to Mix into Each Output Channel Formula for byte count from Specification: IF ((n x m) MOD 8) <> 0 THEN N = ((n x m) DIV 8) + 1 ELSE N = ((n x m) DIV 8) Where: N is the number of necessary bytes to represent the mix. n is the total number of input channels from all input sources m is the total number of output channels from the mixer All Controls represented with “programmable” Bit (1) must support a query for Current, Minimum, Maximum and Step Resolution values. All Controls represented with “not programmable” Bit (0) must support a query for Current value.

7 Selector Units Must Support Queries for Current Value
Even if there is only a single input to the Unit Corollary: Selector Unit should NOT be necessary if it only has a single input source. Should also support a query for Maximum value. (Minimum should always be 1)

8 MIDI Only Devices Are Required by the Specification to Include a Control Interface
Some confusion created by a bug in the MIDI portion of the USB Audio driver in Windows XP. (Send mail to for further discussion about this compatibility issue) From the USB MIDI Specification (unfortunately somewhat hidden in Appendix B): “…the AudioControl interface is mandatory and therefore both the standard AC interface descriptor and the class specific AC interface descriptor must be present…”

9 Units Should Have “Reasonable” Controls and Ranges
Volume controls should have a range of more than a few dB and would usually max out at 0 dB. (-96db to 0db common) Selector Maximum value should not exceed number of inputs Microphone probably should not have a Bass control

10 Interfaces and Endpoints Should Have “Reasonable” Values
Lock Delay should not be a reasonable value (ie not 1) Corollary: Lock delay implies stream start delay If Endpoint indicates a sample rate control, the interface must support more than one sample rate. Every Streaming interface must have one and only one associated Terminal Unit. There MUST be a Zero Bandwidth Alternate Setting for every streaming interface (except MIDI) Entering a non-zero Delay value is helpful (Class Specific Interface Descriptor) to determine the delay through the system as a whole and to give accurate audio position information. (most often this is set to 0).

11 Best Practices When Developing a Class Compliant USB Audio Device
MaxPacketSize match to Sample Rates/Multiple Alternate Settings “Communications” oriented devices Microphone Array Support Asynchronous Render Endpoint (does work in XP, better in Vista) Follow guidelines laid out on Web Page (will be updated soon). Tools are being developed to help validate descriptors/devices.

12 MaxPacketSize Match to Sample Rates/Multiple Alternate Settings
If you have a device that supports multiple sample rates consider using Alternate Settings if the rates are disparate. Consider breaking up contiguous ranges as well. This saves bus bandwidth. Example: MaxPacketSize set to accommodate largest rate (864 bytes) CS FORMAT TYPE DESCRIPTOR: BYTE Length: x11 BYTE DescriptorType: 0x24 BYTE DescriptorSubType: 0x02 BYTE bFormatType: x01 BYTE bNumberOfChannels: 0x06 BYTE bSlotSize: x03 BYTE bBitsPerSample: 0x18 BYTE bSampleFreqType: 0x03 3BYTE SampleRate[0] x001f40 (8000) 3BYTE SampleRate[1] x00ac44 (44100) 3BYTE SampleRate[2] x00bb80 (48000) Alternate Setting?

13 “Communications” Oriented Devices
Recommend 16kHz Sample Rate support New code (Vista SP1 and XP QFE) will prevent devices from becoming preferred audio devices when plugged in to the PC if they have the correct terminal type: 0x306 - Communication speaker Section 2.4 – Bi-Directional Terminal Types Section 2.5 – Telephony Terminal Types ( Sections from USB Device Class Definition for Terminal Types V 1.0)

14 Microphone Array Support
Implemented in the device via a GetMemory request to the Input Terminal that represents the ADC for the array. Specifications are posted for the descriptor that should be retrieved from the terminal:

15 Asynchronous Render Endpoint (does work in XP, better in Vista)
Don’t specify a refresh rate value less than 4 (16ms) in the endpoint descriptor for the feedback endpoint Example: ENDPOINT DESCRIPTOR: BYTE Length: x09 BYTE DescriptorType: 0x05 BYTE EndpointAddress: 0x81 BYTE bmAttributes: 0x01 SHORT MaxPacketSize: 0x0003 BYTE Interval: x01 BYTE Refresh: x05 BYTE SynchAddress: 0x00 Good Value (32ms)

16 Follow Guidelines laid out in UAA Document
This document should be updated soon (mostly with the info found in this presentation)

17 Tools are Being Developed to Help Create/Validate Descriptors/Devices
Descriptor Validation/Topology Generator Descriptor Generator (built from graphic input tool) Test Driver (?) driver that will enumerate the errors instead of failing to load at all. Tools are USB Audio 1.0 based (for now)

18 Future of USB Audio USB Audio 2.0 specification has been completed but at this time we are still trying to determine how it would fit into our development plan. If you have plans to implement USB Audio 2.0 please let us know. Currently it is possible to stream audio using the USB Audio 1.0 specification/Class driver on a USB 2.0. (Requires specific behavior and descriptor values)

19 QUESTIONS???


Download ppt "Using the USB Audio Class Driver – Best Practices and Common Pitfalls"

Similar presentations


Ads by Google