dispaud.c
上传用户:gzccxsp
上传日期:2015-07-14
资源大小:182k
文件大小:33k
源码类别:

MacOS编程

开发平台:

Visual C++

  1. /*++
  2. Copyright (c) 1997-1998 Microsoft Corporation
  3. Module Name:
  4. DISPAUD.C
  5. Abstract:
  6. This source file contains routines which update the edit control
  7. to display information about USB Audio descriptors.
  8. Environment:
  9. user mode
  10. Revision History:
  11. 03-07-1998 : created
  12. --*/
  13. //*****************************************************************************
  14. // I N C L U D E S
  15. //*****************************************************************************
  16. #include <windows.h>
  17. #include <basetyps.h>
  18. #include "usbview.h"
  19. //*****************************************************************************
  20. // D E F I N E S
  21. //*****************************************************************************
  22. //*****************************************************************************
  23. // T Y P E D E F S
  24. //*****************************************************************************
  25. typedef struct _TERMTYPE
  26. {
  27.     USHORT TermTypeCode;
  28.     PCHAR  TermTypeName;
  29. } TERMTYPE, *PTERMTYPE;
  30. typedef struct _FORMATTYPE
  31. {
  32.     USHORT FormatTypeCode;
  33.     PCHAR  FormatTypeName;
  34. } FORMATTYPE, *PFORMATTYPE;
  35. //*****************************************************************************
  36. // G L O B A L S    P R I V A T E    T O    T H I S    F I L E
  37. //*****************************************************************************
  38. //
  39. // USB Device Class Definition for Terminal Types  0.9 Draft Revision
  40. //
  41. TERMTYPE TermTypes[] =
  42. {
  43.     //
  44.     // 2.1 USB Terminal Types
  45.     //
  46.     {0x0100, "USB Undefined"},
  47.     {0x0101, "USB streaming"},
  48.     {0x01FF, "USB vendor specific"},
  49.     //
  50.     // 2.2 Input Terminal Types
  51.     //
  52.     {0x0200, "Input Undefined"},
  53.     {0x0201, "Microphone"},
  54.     {0x0202, "Desktop microphone"},
  55.     {0x0203, "Personal microphone"},
  56.     {0x0204, "Omni-directional microphone"},
  57.     {0x0205, "Microphone array"},
  58.     {0x0206, "Processing microphone array"},
  59.     //
  60.     // 2.3 Output Terminal Types
  61.     //
  62.     {0x0300, "Output Undefined"},
  63.     {0x0301, "Speaker"},
  64.     {0x0302, "Headphones"},
  65.     {0x0303, "Head Mounted Display Audio"},
  66.     {0x0304, "Desktop speaker"},
  67.     {0x0305, "Room speaker"},
  68.     {0x0306, "Communication speaker"},
  69.     {0x0307, "Low frequency effects speaker"},
  70.     //
  71.     // 2.4 Bi-directional Terminal Types
  72.     //
  73.     {0x0400, "Bi-directional Undefined"},
  74.     {0x0401, "Handset"},
  75.     {0x0402, "Headset"},
  76.     {0x0403, "Speakerphone, no echo reduction"},
  77.     {0x0404, "Echo-suppressing speakerphone"},
  78.     {0x0405, "Echo-canceling speakerphone"},
  79.     //
  80.     // 2.5 Telephony Terminal Types
  81.     //
  82.     {0x0500, "Telephony Undefined"},
  83.     {0x0501, "Phone line"},
  84.     {0x0502, "Telephone"},
  85.     {0x0503, "Down Line Phone"},
  86.     //
  87.     // 2.6 External Terminal Types
  88.     //
  89.     {0x0600, "External Undefined"},
  90.     {0x0601, "Analog connector"},
  91.     {0x0602, "Digital audio interface"},
  92.     {0x0603, "Line connector"},
  93.     {0x0604, "Legacy audio connector"},
  94.     {0x0605, "S/PDIF interface"},
  95.     {0x0606, "1394 DA stream"},
  96.     {0x0607, "1394 DV stream soundtrack"},
  97.     //
  98.     // Embedded Function Terminal Types
  99.     //
  100.     {0x0700, "Embedded Undefined"},
  101.     {0x0701, "Level Calibration Noise Source"},
  102.     {0x0702, "Equalization Noise"},
  103.     {0x0703, "CD player"},
  104.     {0x0704, "DAT"},
  105.     {0x0705, "DCC"},
  106.     {0x0706, "MiniDisk"},
  107.     {0x0707, "Analog Tape"},
  108.     {0x0708, "Phonograph"},
  109.     {0x0709, "VCR Audio"},
  110.     {0x070A, "Video Disc Audio"},
  111.     {0x070B, "DVD Audio"},
  112.     {0x070C, "TV Tuner Audio"},
  113.     {0x070D, "Satellite Receiver Audio"},
  114.     {0x070E, "Cable Tuner Audio"},
  115.     {0x070F, "DSS Audio"},
  116.     {0x0710, "Radio Receiver"},
  117.     {0x0711, "Radio Transmitter"},
  118.     {0x0712, "Multi-track Recorder"},
  119.     {0x0713, "Synthesizer"},
  120.     //
  121.     // Terminate List
  122.     //
  123.     {0xFFFF, NULL}
  124. };
  125. //
  126. // USB Device Class Definition for Audio Data Formats  0.9 Draft Revision
  127. //
  128. FORMATTYPE FormatTypes[] =
  129. {
  130.     //
  131.     // A.1.1 Audio Data Format Type I Codes
  132.     //
  133.     {0x0000, "TYPE_I_UNDEFINED"},
  134.     {0x0001, "PCM"},
  135.     {0x0002, "PCM8"},
  136.     {0x0003, "IEEE_FLOAT"},
  137.     {0x0004, "ALAW"},
  138.     {0x0005, "MULAW"},
  139.     //
  140.     // A.1.2 Audio Data Format Type II Codes
  141.     //
  142.     {0x1000, "TYPE_II_UNDEFINED"},
  143.     {0x1001, "MPEG"},
  144.     {0x1002, "AC-3"},
  145.     //
  146.     // A.1.3 Audio Data Format Type III Codes
  147.     //
  148.     {0x2000, "TYPE_III_UNDEFINED"},
  149.     {0x2001, "IEC1937_AC-3"},
  150.     {0x2002, "IEC1937_MPEG-1_Layer1"},
  151.     {0x2003, "IEC1937_MPEG-1_Layer2/3 or IEC1937_MPEG-2_NOEXT"},
  152.     {0x2004, "IEC1937_MPEG-2_EXT"},
  153.     {0x2005, "IEC1937_MPEG-2_Layer1_LS"},
  154.     {0x2006, "IEC1937_MPEG-2_Layer2/3_LS"},
  155.     //
  156.     // Terminate List
  157.     //
  158.     {0xFFFF, NULL}
  159. };
  160. //*****************************************************************************
  161. // L O C A L    F U N C T I O N    P R O T O T Y P E S
  162. //*****************************************************************************
  163. BOOL
  164. DisplayACHeader (
  165.     PUSB_AUDIO_AC_INTERFACE_HEADER_DESCRIPTOR HeaderDesc
  166. );
  167. BOOL
  168. DisplayACInputTerminal (
  169.     PUSB_AUDIO_INPUT_TERMINAL_DESCRIPTOR ITDesc
  170. );
  171. BOOL
  172. DisplayACOutputTerminal (
  173.     PUSB_AUDIO_OUTPUT_TERMINAL_DESCRIPTOR OTDesc
  174. );
  175. BOOL
  176. DisplayACMixerUnit (
  177.     PUSB_AUDIO_MIXER_UNIT_DESCRIPTOR MixerDesc
  178. );
  179. BOOL
  180. DisplayACSelectorUnit (
  181.     PUSB_AUDIO_SELECTOR_UNIT_DESCRIPTOR SelectorDesc
  182. );
  183. BOOL
  184. DisplayACFeatureUnit (
  185.     PUSB_AUDIO_FEATURE_UNIT_DESCRIPTOR FeatureDesc
  186. );
  187. BOOL
  188. DisplayACProcessingUnit (
  189.     PUSB_AUDIO_PROCESSING_UNIT_DESCRIPTOR ProcessingDesc
  190. );
  191. BOOL
  192. DisplayACExtensionUnit (
  193.     PUSB_AUDIO_EXTENSION_UNIT_DESCRIPTOR ExtensionDesc
  194. );
  195. BOOL
  196. DisplayASGeneral (
  197.     PUSB_AUDIO_GENERAL_DESCRIPTOR GeneralDesc
  198. );
  199. BOOL
  200. DisplayCSEndpoint (
  201.     PUSB_AUDIO_ENDPOINT_DESCRIPTOR EndpointDesc
  202. );
  203. BOOL
  204. DisplayASFormatType (
  205.     PUSB_AUDIO_COMMON_FORMAT_DESCRIPTOR FormatDesc
  206. );
  207. BOOL
  208. DisplayASFormatSpecific (
  209.     PUSB_AUDIO_COMMON_DESCRIPTOR CommonDesc
  210. );
  211. VOID
  212. DisplayBytes (
  213.     PUCHAR Data,
  214.     USHORT Len
  215. );
  216. PCHAR
  217. TermTypeCodeToName (
  218.     USHORT TermTypeCode
  219. );
  220. PCHAR
  221. FormatTypeCodeToName (
  222.     USHORT FormatTypeCode
  223. );
  224. //*****************************************************************************
  225. // L O C A L    F U N C T I O N S
  226. //*****************************************************************************
  227. //*****************************************************************************
  228. //
  229. // DisplayAudioDescriptor()
  230. //
  231. // CommonDesc - An Audio Class Descriptor
  232. //
  233. // bInterfaceSubClass - The SubClass of the Interface containing the descriptor
  234. //
  235. //*****************************************************************************
  236. BOOL
  237. DisplayAudioDescriptor (
  238.     PUSB_AUDIO_COMMON_DESCRIPTOR CommonDesc,
  239.     UCHAR                        bInterfaceSubClass
  240. )
  241. {
  242.     switch (CommonDesc->bDescriptorType)
  243.     {
  244.         case USB_AUDIO_CS_INTERFACE:
  245.             switch (bInterfaceSubClass)
  246.             {
  247.                 case USB_AUDIO_SUBCLASS_AUDIOCONTROL:
  248.                     switch (CommonDesc->bDescriptorSubtype)
  249.                     {
  250.                         case USB_AUDIO_AC_HEADER:
  251.                             return DisplayACHeader((PUSB_AUDIO_AC_INTERFACE_HEADER_DESCRIPTOR)CommonDesc);
  252.                         case USB_AUDIO_AC_INPUT_TERMINAL:
  253.                             return DisplayACInputTerminal((PUSB_AUDIO_INPUT_TERMINAL_DESCRIPTOR)CommonDesc);
  254.                         case USB_AUDIO_AC_OUTPUT_TERMINAL:
  255.                             return DisplayACOutputTerminal((PUSB_AUDIO_OUTPUT_TERMINAL_DESCRIPTOR)CommonDesc);
  256.                         case USB_AUDIO_AC_MIXER_UNIT:
  257.                             return DisplayACMixerUnit((PUSB_AUDIO_MIXER_UNIT_DESCRIPTOR)CommonDesc);
  258.                         case USB_AUDIO_AC_SELECTOR_UNIT:
  259.                             return DisplayACSelectorUnit((PUSB_AUDIO_SELECTOR_UNIT_DESCRIPTOR)CommonDesc);
  260.                         case USB_AUDIO_AC_FEATURE_UNIT:
  261.                             return DisplayACFeatureUnit((PUSB_AUDIO_FEATURE_UNIT_DESCRIPTOR)CommonDesc);
  262.                         case USB_AUDIO_AC_PROCESSING_UNIT:
  263.                             return DisplayACProcessingUnit((PUSB_AUDIO_PROCESSING_UNIT_DESCRIPTOR)CommonDesc);
  264.                         case USB_AUDIO_AC_EXTENSION_UNIT:
  265.                             return DisplayACExtensionUnit((PUSB_AUDIO_EXTENSION_UNIT_DESCRIPTOR)CommonDesc);
  266.                         default:
  267.                             break;
  268.                     }
  269.                     break;
  270.                 case USB_AUDIO_SUBCLASS_AUDIOSTREAMING:
  271.                     switch (CommonDesc->bDescriptorSubtype)
  272.                     {
  273.                         case USB_AUDIO_AS_GENERAL:
  274.                             return DisplayASGeneral((PUSB_AUDIO_GENERAL_DESCRIPTOR)CommonDesc);
  275.                         case USB_AUDIO_AS_FORMAT_TYPE:
  276.                             return DisplayASFormatType((PUSB_AUDIO_COMMON_FORMAT_DESCRIPTOR)CommonDesc);
  277.                             break;
  278.                         case USB_AUDIO_AS_FORMAT_SPECIFIC:
  279.                             return DisplayASFormatSpecific(CommonDesc);
  280.                         default:
  281.                             break;
  282.                     }
  283.                     break;
  284.                 default:
  285.                     break;
  286.             }
  287.             break;
  288.         case USB_AUDIO_CS_ENDPOINT:
  289.             return DisplayCSEndpoint((PUSB_AUDIO_ENDPOINT_DESCRIPTOR)CommonDesc);
  290.         default:
  291.             break;
  292.     }
  293.     return FALSE;
  294. }
  295. //*****************************************************************************
  296. //
  297. // DisplayACHeader()
  298. //
  299. //*****************************************************************************
  300. BOOL
  301. DisplayACHeader (
  302.     PUSB_AUDIO_AC_INTERFACE_HEADER_DESCRIPTOR HeaderDesc
  303. )
  304. {
  305.     UINT i;
  306.     if (HeaderDesc->bLength < sizeof(USB_AUDIO_AC_INTERFACE_HEADER_DESCRIPTOR))
  307.     {
  308.         OOPS();
  309.         return FALSE;
  310.     }
  311.     AppendTextBuffer("rnAudio Control Interface Header Descriptor:rn");
  312.     AppendTextBuffer("bLength:              0x%02Xrn",
  313.                      HeaderDesc->bLength);
  314.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  315.                      HeaderDesc->bDescriptorType);
  316.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  317.                      HeaderDesc->bDescriptorSubtype);
  318.     AppendTextBuffer("bcdADC:             0x%04Xrn",
  319.                      HeaderDesc->bcdADC);
  320.     AppendTextBuffer("wTotalLength:       0x%04Xrn",
  321.                      HeaderDesc->wTotalLength);
  322.     AppendTextBuffer("bInCollection:        0x%02Xrn",
  323.                      HeaderDesc->bInCollection);
  324.     for (i=0; i<HeaderDesc->bInCollection; i++)
  325.     {
  326.         AppendTextBuffer("baInterfaceNr[%d]:     0x%02Xrn",
  327.                          i+1,
  328.                          HeaderDesc->baInterfaceNr[i]);
  329.     }
  330.     return TRUE;
  331. }
  332. //*****************************************************************************
  333. //
  334. // DisplayACInputTerminal()
  335. //
  336. //*****************************************************************************
  337. BOOL
  338. DisplayACInputTerminal (
  339.     PUSB_AUDIO_INPUT_TERMINAL_DESCRIPTOR ITDesc
  340. )
  341. {
  342.     PCHAR pStr;
  343.     if (ITDesc->bLength != sizeof(USB_AUDIO_INPUT_TERMINAL_DESCRIPTOR))
  344.     {
  345.         OOPS();
  346.         return FALSE;
  347.     }
  348.     AppendTextBuffer("rnAudio Control Input Terminal Descriptor:rn");
  349.     AppendTextBuffer("bLength:              0x%02Xrn",
  350.                      ITDesc->bLength);
  351.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  352.                      ITDesc->bDescriptorType);
  353.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  354.                      ITDesc->bDescriptorSubtype);
  355.     AppendTextBuffer("bTerminalID:          0x%02Xrn",
  356.                      ITDesc->bTerminalID);
  357.     AppendTextBuffer("wTerminalType:      0x%04X",
  358.                      ITDesc->wTerminalType);
  359.     pStr = TermTypeCodeToName(ITDesc->wTerminalType);
  360.     if (pStr)
  361.     {
  362.         AppendTextBuffer(" (%s)rn",
  363.                          pStr);
  364.     }
  365.     else
  366.     {
  367.         AppendTextBuffer("rn");
  368.     }
  369.     AppendTextBuffer("bAssocTerminal:       0x%02Xrn",
  370.                      ITDesc->bAssocTerminal);
  371.     AppendTextBuffer("bNrChannels:          0x%02Xrn",
  372.                      ITDesc->bNrChannels);
  373.     AppendTextBuffer("wChannelConfig:     0x%04Xrn",
  374.                      ITDesc->wChannelConfig);
  375.     AppendTextBuffer("iChannelNames:        0x%02Xrn",
  376.                      ITDesc->iChannelNames);
  377.     AppendTextBuffer("iTerminal:            0x%02Xrn",
  378.                      ITDesc->iTerminal);
  379.     return TRUE;
  380. }
  381. //*****************************************************************************
  382. //
  383. // DisplayACOutputTerminal()
  384. //
  385. //*****************************************************************************
  386. BOOL
  387. DisplayACOutputTerminal (
  388.     PUSB_AUDIO_OUTPUT_TERMINAL_DESCRIPTOR OTDesc
  389. )
  390. {
  391.     PCHAR pStr;
  392.     if (OTDesc->bLength != sizeof(USB_AUDIO_OUTPUT_TERMINAL_DESCRIPTOR))
  393.     {
  394.         OOPS();
  395.         return FALSE;
  396.     }
  397.     AppendTextBuffer("rnAudio Control Output Terminal Descriptor:rn");
  398.     AppendTextBuffer("bLength:              0x%02Xrn",
  399.                      OTDesc->bLength);
  400.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  401.                      OTDesc->bDescriptorType);
  402.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  403.                      OTDesc->bDescriptorSubtype);
  404.     AppendTextBuffer("bTerminalID:          0x%02Xrn",
  405.                      OTDesc->bTerminalID);
  406.     AppendTextBuffer("wTerminalType:      0x%04X",
  407.                      OTDesc->wTerminalType);
  408.     pStr = TermTypeCodeToName(OTDesc->wTerminalType);
  409.     if (pStr)
  410.     {
  411.         AppendTextBuffer(" (%s)rn",
  412.                          pStr);
  413.     }
  414.     else
  415.     {
  416.         AppendTextBuffer("rn");
  417.     }
  418.     AppendTextBuffer("bAssocTerminal:       0x%02Xrn",
  419.                      OTDesc->bAssocTerminal);
  420.     AppendTextBuffer("bSoruceID:            0x%02Xrn",
  421.                      OTDesc->bSoruceID);
  422.     AppendTextBuffer("iTerminal:            0x%02Xrn",
  423.                      OTDesc->iTerminal);
  424.     return TRUE;
  425. }
  426. //*****************************************************************************
  427. //
  428. // DisplayACMixerUnit()
  429. //
  430. //*****************************************************************************
  431. BOOL
  432. DisplayACMixerUnit (
  433.     PUSB_AUDIO_MIXER_UNIT_DESCRIPTOR MixerDesc
  434. )
  435. {
  436.     UCHAR  i;
  437.     PUCHAR data;
  438.     if (MixerDesc->bLength < 10)
  439.     {
  440.         OOPS();
  441.         return FALSE;
  442.     }
  443.     AppendTextBuffer("rnAudio Control Mixer Unit Descriptor:rn");
  444.     AppendTextBuffer("bLength:              0x%02Xrn",
  445.                      MixerDesc->bLength);
  446.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  447.                      MixerDesc->bDescriptorType);
  448.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  449.                      MixerDesc->bDescriptorSubtype);
  450.     AppendTextBuffer("bUnitID:              0x%02Xrn",
  451.                      MixerDesc->bUnitID);
  452.     AppendTextBuffer("bNrInPins:            0x%02Xrn",
  453.                      MixerDesc->bNrInPins);
  454.     for (i=0; i<MixerDesc->bNrInPins; i++)
  455.     {
  456.         AppendTextBuffer("baSourceID[%d]:        0x%02Xrn",
  457.                         i+1,
  458.                         MixerDesc->baSourceID[i]);
  459.     }
  460.     data = &MixerDesc->baSourceID[MixerDesc->bNrInPins];
  461.     AppendTextBuffer("bNrChannels:          0x%02Xrn",
  462.                      *data++);
  463.     AppendTextBuffer("wChannelConfig:     0x%04Xrn",
  464.                      *((PUSHORT)data)++);
  465.     AppendTextBuffer("iChannelNames:        0x%02Xrn",
  466.                      *data++);
  467.     AppendTextBuffer("bmControls:rn");
  468.     i = MixerDesc->bLength - 10 - MixerDesc->bNrInPins;
  469.     DisplayBytes(data, i);
  470.     data += i;
  471.     AppendTextBuffer("iMixer:               0x%02Xrn",
  472.                      *data);
  473.     return TRUE;
  474. }
  475. //*****************************************************************************
  476. //
  477. // DisplayACSelectorUnit()
  478. //
  479. //*****************************************************************************
  480. BOOL
  481. DisplayACSelectorUnit (
  482.     PUSB_AUDIO_SELECTOR_UNIT_DESCRIPTOR SelectorDesc
  483. )
  484. {
  485.     UCHAR  i;
  486.     PUCHAR data;
  487.     if (SelectorDesc->bLength < 6)
  488.     {
  489.         OOPS();
  490.         return FALSE;
  491.     }
  492.     AppendTextBuffer("rnAudio Control Selector Unit Descriptor:rn");
  493.     AppendTextBuffer("bLength:              0x%02Xrn",
  494.                      SelectorDesc->bLength);
  495.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  496.                      SelectorDesc->bDescriptorType);
  497.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  498.                      SelectorDesc->bDescriptorSubtype);
  499.     AppendTextBuffer("bUnitID:              0x%02Xrn",
  500.                      SelectorDesc->bUnitID);
  501.     AppendTextBuffer("bNrInPins:            0x%02Xrn",
  502.                      SelectorDesc->bNrInPins);
  503.     for (i=0; i<SelectorDesc->bNrInPins; i++)
  504.     {
  505.         AppendTextBuffer("baSourceID[%d]:        0x%02Xrn",
  506.                         i+1,
  507.                         SelectorDesc->baSourceID[i]);
  508.     }
  509.     data = &SelectorDesc->baSourceID[SelectorDesc->bNrInPins];
  510.     AppendTextBuffer("iSelector:            0x%02Xrn",
  511.                      *data);
  512.     return TRUE;
  513. }
  514. //*****************************************************************************
  515. //
  516. // DisplayACFeatureUnit()
  517. //
  518. //*****************************************************************************
  519. BOOL
  520. DisplayACFeatureUnit (
  521.     PUSB_AUDIO_FEATURE_UNIT_DESCRIPTOR FeatureDesc
  522. )
  523. {
  524.     UCHAR  i, n, ch;
  525.     PUCHAR data;
  526.     if (FeatureDesc->bLength < 7)
  527.     {
  528.         OOPS();
  529.         return FALSE;
  530.     }
  531.     n = FeatureDesc->bControlSize;
  532.     ch = ((FeatureDesc->bLength - 7) / n) - 1;
  533.     if (FeatureDesc->bLength != (7 + (ch + 1) * n))
  534.     {
  535.         OOPS();
  536.         return FALSE;
  537.     }
  538.     AppendTextBuffer("rnAudio Control Feature Unit Descriptor:rn");
  539.     AppendTextBuffer("bLength:              0x%02Xrn",
  540.                      FeatureDesc->bLength);
  541.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  542.                      FeatureDesc->bDescriptorType);
  543.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  544.                      FeatureDesc->bDescriptorSubtype);
  545.     AppendTextBuffer("bUnitID:              0x%02Xrn",
  546.                      FeatureDesc->bUnitID);
  547.     AppendTextBuffer("bSourceID:            0x%02Xrn",
  548.                      FeatureDesc->bSourceID);
  549.     AppendTextBuffer("bControlSize:         0x%02Xrn",
  550.                      FeatureDesc->bControlSize);
  551.     data = &FeatureDesc->bmaControls[0];
  552.     for (i=0; i<=ch; i++)
  553.     {
  554.         AppendTextBuffer("bmaControls[%d]:rn",
  555.                          i);
  556.         DisplayBytes(data, n);
  557.         data += n;
  558.     }
  559.     AppendTextBuffer("iFeature:             0x%02Xrn",
  560.                      *data);
  561.     return TRUE;
  562. }
  563. //*****************************************************************************
  564. //
  565. // DisplayACProcessingUnit()
  566. //
  567. //*****************************************************************************
  568. BOOL
  569. DisplayACProcessingUnit (
  570.     PUSB_AUDIO_PROCESSING_UNIT_DESCRIPTOR ProcessingDesc
  571. )
  572. {
  573.     UCHAR  i;
  574.     PUCHAR data;
  575.     if (ProcessingDesc->bLength < sizeof(USB_AUDIO_PROCESSING_UNIT_DESCRIPTOR))
  576.     {
  577.         OOPS();
  578.         return FALSE;
  579.     }
  580.     AppendTextBuffer("rnAudio Control Processing Unit Descriptor:rn");
  581.     AppendTextBuffer("bLength:              0x%02Xrn",
  582.                      ProcessingDesc->bLength);
  583.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  584.                      ProcessingDesc->bDescriptorType);
  585.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  586.                      ProcessingDesc->bDescriptorSubtype);
  587.     AppendTextBuffer("bUnitID:              0x%02Xrn",
  588.                      ProcessingDesc->bUnitID);
  589.     AppendTextBuffer("wProcessType:       0x%04X",
  590.                      ProcessingDesc->wProcessType);
  591.     switch (ProcessingDesc->wProcessType)
  592.     {
  593.         case USB_AUDIO_PROCESS_UNDEFINED:
  594.             AppendTextBuffer("(Undefined Process)rn");
  595.             break;
  596.         case USB_AUDIO_PROCESS_UPDOWNMIX:
  597.             AppendTextBuffer("(Up / Down Mix Process)rn");
  598.             break;
  599.         case USB_AUDIO_PROCESS_DOLBYPROLOGIC:
  600.             AppendTextBuffer("(Dolby Prologic Process)rn");
  601.             break;
  602.         case USB_AUDIO_PROCESS_3DSTEREOEXTENDER:
  603.             AppendTextBuffer("(3D-Stereo Extender Process)rn");
  604.             break;
  605.         case USB_AUDIO_PROCESS_REVERBERATION:
  606.             AppendTextBuffer("(Reverberation Process)rn");
  607.             break;
  608.         case USB_AUDIO_PROCESS_CHORUS:
  609.             AppendTextBuffer("(Chorus Process)rn");
  610.             break;
  611.         case USB_AUDIO_PROCESS_DYNRANGECOMP:
  612.             AppendTextBuffer("(Dynamic Range Compressor Process)rn");
  613.             break;
  614.         default:
  615.             AppendTextBuffer("rn");
  616.             break;
  617.     }
  618.     AppendTextBuffer("bNrInPins:            0x%02Xrn",
  619.                      ProcessingDesc->bNrInPins);
  620.     for (i=0; i<ProcessingDesc->bNrInPins; i++)
  621.     {
  622.         AppendTextBuffer("baSourceID[%d]:        0x%02Xrn",
  623.                         i+1,
  624.                         ProcessingDesc->baSourceID[i]);
  625.     }
  626.     data = &ProcessingDesc->baSourceID[ProcessingDesc->bNrInPins];
  627.     AppendTextBuffer("bNrChannels:          0x%02Xrn",
  628.                      *data++);
  629.     AppendTextBuffer("wChannelConfig:     0x%04Xrn",
  630.                      *((PUSHORT)data)++);
  631.     AppendTextBuffer("iChannelNames:        0x%02Xrn",
  632.                      *data++);
  633.     i = *data++;
  634.     AppendTextBuffer("bControlSize:         0x%02Xrn",
  635.                      i);
  636.     AppendTextBuffer("bmControls:rn");
  637.     DisplayBytes(data, i);
  638.     data += i;
  639.     AppendTextBuffer("iProcessing:          0x%02Xrn",
  640.                      *data++);
  641.     i = ProcessingDesc->bLength - 13 - ProcessingDesc->bNrInPins - i;
  642.     if (i)
  643.     {
  644.         AppendTextBuffer("Process Specific:rn");
  645.         DisplayBytes(data, i);
  646.     }
  647.     return TRUE;
  648. }
  649. //*****************************************************************************
  650. //
  651. // DisplayACExtensionUnit()
  652. //
  653. //*****************************************************************************
  654. BOOL
  655. DisplayACExtensionUnit (
  656.     PUSB_AUDIO_EXTENSION_UNIT_DESCRIPTOR ExtensionDesc
  657. )
  658. {
  659.     UCHAR  i;
  660.     PUCHAR data;
  661.     if (ExtensionDesc->bLength < 13)
  662.     {
  663.         OOPS();
  664.         return FALSE;
  665.     }
  666.     AppendTextBuffer("rnAudio Control Extension Unit Descriptor:rn");
  667.     AppendTextBuffer("bLength:              0x%02Xrn",
  668.                      ExtensionDesc->bLength);
  669.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  670.                      ExtensionDesc->bDescriptorType);
  671.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  672.                      ExtensionDesc->bDescriptorSubtype);
  673.     AppendTextBuffer("bUnitID:              0x%02Xrn",
  674.                      ExtensionDesc->bUnitID);
  675.     AppendTextBuffer("wExtensionCode:     0x%04Xrn",
  676.                      ExtensionDesc->wExtensionCode);
  677.     AppendTextBuffer("bNrInPins:            0x%02Xrn",
  678.                      ExtensionDesc->bNrInPins);
  679.     for (i=0; i<ExtensionDesc->bNrInPins; i++)
  680.     {
  681.         AppendTextBuffer("baSourceID[%d]:        0x%02Xrn",
  682.                         i+1,
  683.                         ExtensionDesc->baSourceID[i]);
  684.     }
  685.     data = &ExtensionDesc->baSourceID[ExtensionDesc->bNrInPins];
  686.     AppendTextBuffer("bNrChannels:          0x%02Xrn",
  687.                      *data++);
  688.     AppendTextBuffer("wChannelConfig:     0x%04Xrn",
  689.                      *((PUSHORT)data)++);
  690.     AppendTextBuffer("iChannelNames:        0x%02Xrn",
  691.                      *data++);
  692.     i = *data++;
  693.     AppendTextBuffer("bControlSize:         0x%02Xrn",
  694.                      i);
  695.     AppendTextBuffer("bmControls:rn");
  696.     DisplayBytes(data, i);
  697.     data += i;
  698.     AppendTextBuffer("iExtension:           0x%02Xrn",
  699.                      *data);
  700.     return TRUE;
  701. }
  702. //*****************************************************************************
  703. //
  704. // DisplayASGeneral()
  705. //
  706. //*****************************************************************************
  707. BOOL
  708. DisplayASGeneral (
  709.     PUSB_AUDIO_GENERAL_DESCRIPTOR GeneralDesc
  710. )
  711. {
  712.     PCHAR pStr;
  713.     if (GeneralDesc->bLength != sizeof(USB_AUDIO_GENERAL_DESCRIPTOR))
  714.     {
  715.         OOPS();
  716.         return FALSE;
  717.     }
  718.     AppendTextBuffer("rnAudio Streaming Class Specific Interface Descriptor:rn");
  719.     AppendTextBuffer("bLength:              0x%02Xrn",
  720.                      GeneralDesc->bLength);
  721.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  722.                      GeneralDesc->bDescriptorType);
  723.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  724.                      GeneralDesc->bDescriptorSubtype);
  725.     AppendTextBuffer("bTerminalLink:        0x%02Xrn",
  726.                      GeneralDesc->bTerminalLink);
  727.     AppendTextBuffer("bDelay:               0x%02Xrn",
  728.                      GeneralDesc->bDelay);
  729.     AppendTextBuffer("wFormatTag:         0x%04X",
  730.                      GeneralDesc->wFormatTag);
  731.     pStr = FormatTypeCodeToName(GeneralDesc->wFormatTag);
  732.     if (pStr)
  733.     {
  734.         AppendTextBuffer(" (%s)rn",
  735.                          pStr);
  736.     }
  737.     else
  738.     {
  739.         AppendTextBuffer("rn");
  740.     }
  741.     return TRUE;
  742. }
  743. //*****************************************************************************
  744. //
  745. // DisplayCSEndpoint()
  746. //
  747. //*****************************************************************************
  748. BOOL
  749. DisplayCSEndpoint (
  750.     PUSB_AUDIO_ENDPOINT_DESCRIPTOR EndpointDesc
  751. )
  752. {
  753.     if (EndpointDesc->bLength != sizeof(USB_AUDIO_ENDPOINT_DESCRIPTOR))
  754.     {
  755.         OOPS();
  756.         return FALSE;
  757.     }
  758.     AppendTextBuffer("rnAudio Streaming Class Specific Audio Data Endpoint Descriptor:rn");
  759.     AppendTextBuffer("bLength:              0x%02Xrn",
  760.                      EndpointDesc->bLength);
  761.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  762.                      EndpointDesc->bDescriptorType);
  763.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  764.                      EndpointDesc->bDescriptorSubtype);
  765.     AppendTextBuffer("bmAttributes:         0x%02Xrn",
  766.                      EndpointDesc->bmAttributes);
  767.     AppendTextBuffer("bLockDelayUnits:      0x%02Xrn",
  768.                      EndpointDesc->bLockDelayUnits);
  769.     AppendTextBuffer("wLockDelay:         0x%04Xrn",
  770.                      EndpointDesc->wLockDelay);
  771.     return TRUE;
  772. }
  773. //*****************************************************************************
  774. //
  775. // DisplayASFormatType()
  776. //
  777. //*****************************************************************************
  778. BOOL
  779. DisplayASFormatType (
  780.     PUSB_AUDIO_COMMON_FORMAT_DESCRIPTOR FormatDesc
  781. )
  782. {
  783.     UCHAR  i, n;
  784.     ULONG  freq;
  785.     PUCHAR data;
  786.     if (FormatDesc->bLength < sizeof(USB_AUDIO_COMMON_FORMAT_DESCRIPTOR))
  787.     {
  788.         OOPS();
  789.         return FALSE;
  790.     }
  791.     AppendTextBuffer("rnAudio Streaming Format Type Descriptor:rn");
  792.     AppendTextBuffer("bLength:              0x%02Xrn",
  793.                      FormatDesc->bLength);
  794.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  795.                      FormatDesc->bDescriptorType);
  796.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  797.                      FormatDesc->bDescriptorSubtype);
  798.     AppendTextBuffer("bFormatType:          0x%02Xrn",
  799.                      FormatDesc->bFormatType);
  800.     if (FormatDesc->bFormatType == 0x01 ||
  801.         FormatDesc->bFormatType == 0x03)
  802.     {
  803.         PUSB_AUDIO_TYPE_I_OR_III_FORMAT_DESCRIPTOR FormatI_IIIDesc;
  804.         FormatI_IIIDesc = (PUSB_AUDIO_TYPE_I_OR_III_FORMAT_DESCRIPTOR)FormatDesc;
  805.         AppendTextBuffer("bNrChannels:          0x%02Xrn",
  806.                          FormatI_IIIDesc->bNrChannels);
  807.         AppendTextBuffer("bSubframeSize:        0x%02Xrn",
  808.                          FormatI_IIIDesc->bSubframeSize);
  809.         AppendTextBuffer("bBitResolution:       0x%02Xrn",
  810.                          FormatI_IIIDesc->bBitResolution);
  811.         AppendTextBuffer("bSamFreqType:         0x%02Xrn",
  812.                          FormatI_IIIDesc->bSamFreqType);
  813.         data = (PUCHAR)(FormatI_IIIDesc + 1);
  814.         n = FormatI_IIIDesc->bSamFreqType;
  815.     }
  816.     else if (FormatDesc->bFormatType == 0x02)
  817.     {
  818.         PUSB_AUDIO_TYPE_II_FORMAT_DESCRIPTOR FormatIIDesc;
  819.         FormatIIDesc = (PUSB_AUDIO_TYPE_II_FORMAT_DESCRIPTOR)FormatDesc;
  820.         AppendTextBuffer("wMaxBitRate:        0x%04Xrn",
  821.                          FormatIIDesc->wMaxBitRate);
  822.         AppendTextBuffer("wSamplesPerFrame:   0x%04Xrn",
  823.                          FormatIIDesc->wSamplesPerFrame);
  824.         AppendTextBuffer("bSamFreqType:         0x%02Xrn",
  825.                          FormatIIDesc->bSamFreqType);
  826.         data = (PUCHAR)(FormatIIDesc + 1);
  827.         n = FormatIIDesc->bSamFreqType;
  828.     }
  829.     else
  830.     {
  831.         data = NULL;
  832.     }
  833.     if (data != NULL)
  834.     {
  835.         if (n == 0)
  836.         {
  837.             freq = (data[0]) + (data[1] << 8) + (data[2] << 16);
  838.             data += 3;
  839.             AppendTextBuffer("tLowerSamFreq:    0x%06X (%d Hz)rn",
  840.                              freq,
  841.                              freq);
  842.             freq = (data[0]) + (data[1] << 8) + (data[2] << 16);
  843.             data += 3;
  844.             AppendTextBuffer("tUpperSamFreq:    0x%06X (%d Hz)rn",
  845.                              freq,
  846.                              freq);
  847.         }
  848.         else
  849.         {
  850.             for (i=0; i<n; i++)
  851.             {
  852.                 freq = (data[0]) + (data[1] << 8) + (data[2] << 16);
  853.                 data += 3;
  854.                 AppendTextBuffer("tSamFreq[%d]:      0x%06X (%d Hz)rn",
  855.                                  i+1,
  856.                                  freq,
  857.                                  freq);
  858.             }
  859.         }
  860.     }
  861.     return TRUE;
  862. }
  863. //*****************************************************************************
  864. //
  865. // DisplayASFormatSpecific()
  866. //
  867. //*****************************************************************************
  868. BOOL
  869. DisplayASFormatSpecific (
  870.     PUSB_AUDIO_COMMON_DESCRIPTOR CommonDesc
  871. )
  872. {
  873.     AppendTextBuffer("rnAudio Streaming Format Specific Descriptor:rn");
  874.     AppendTextBuffer("bLength:              0x%02Xrn",
  875.                      CommonDesc->bLength);
  876.     AppendTextBuffer("bDescriptorType:      0x%02Xrn",
  877.                      CommonDesc->bDescriptorType);
  878.     AppendTextBuffer("bDescriptorSubtype:   0x%02Xrn",
  879.                      CommonDesc->bDescriptorSubtype);
  880.     DisplayBytes((PUCHAR)(CommonDesc + 1),
  881.                  CommonDesc->bLength);
  882.     return TRUE;
  883. }
  884. //*****************************************************************************
  885. //
  886. // DisplayBytes()
  887. //
  888. //*****************************************************************************
  889. VOID
  890. DisplayBytes (
  891.     PUCHAR Data,
  892.     USHORT Len
  893. )
  894. {
  895.     USHORT i;
  896.     for (i = 0; i < Len; i++)
  897.     {
  898.         AppendTextBuffer("%02X ",
  899.                          Data[i]);
  900.         if (i % 16 == 15)
  901.         {
  902.             AppendTextBuffer("rn");
  903.         }
  904.     }
  905.     if (i % 16 != 0)
  906.     {
  907.         AppendTextBuffer("rn");
  908.     }
  909. }
  910. //*****************************************************************************
  911. //
  912. // TermTypeCodeToName()
  913. //
  914. //*****************************************************************************
  915. PCHAR
  916. TermTypeCodeToName (
  917.     USHORT TermTypeCode
  918. )
  919. {
  920.     PTERMTYPE termType;
  921.     for (termType=TermTypes; termType->TermTypeName; termType++)
  922.     {
  923.         if (termType->TermTypeCode == TermTypeCode)
  924.         {
  925.             break;
  926.         }
  927.     }
  928.     return termType->TermTypeName;
  929. }
  930. //*****************************************************************************
  931. //
  932. // FormatTypeCodeToName()
  933. //
  934. //*****************************************************************************
  935. PCHAR
  936. FormatTypeCodeToName (
  937.     USHORT FormatTypeCode
  938. )
  939. {
  940.     PFORMATTYPE formatType;
  941.     for (formatType=FormatTypes; formatType->FormatTypeName; formatType++)
  942.     {
  943.         if (formatType->FormatTypeCode == FormatTypeCode)
  944.         {
  945.             break;
  946.         }
  947.     }
  948.     return formatType->FormatTypeName;
  949. }