簡單的UAC2.0設備的Audio Function Topology以下:git
下面描述了一個立體聲的USB輸入數據流的輸入終端bash
AUDIO_20_IT_DESC_SIZE, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_INPUT_TERMINAL, /* bDescriptorSubtype */ AUDIO_IT_ID, /* bTerminalID */ 0x01, /* wTerminalType AUDIO_TERMINAL_USB_STREAMING 0x0101 */ 0x01, 0x00, /* bAssocTerminal */ AUDIO_CLK_ID, /* bCSourceID*/ 0x02, /* bNrChannels */ 0x03, /* wChannelConfig 0x00000003 Stereo */ 0x00, 0x00, 0x00, 0x00, /* iChannelNames */ 0x00, /* bmControls */ 0x00, 0x00, /* iTerminal */
主通道支持音量和mute控制.net
0x12, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_FEATURE_UNIT, /* bDescriptorSubtype */ AUDIO_FU_ID, /* bUnitID */ AUDIO_IT_ID, /* bSourceID */ AUDIO_20_CTL_MUTE(CONTROL_BITMAP_PROG)/* bmaControls(0) */ | AUDIO_20_CTL_VOLUME(CONTROL_BITMAP_PROG), 0x00, 0x00, 0x00, 0x00, /* bmaControls(1) */ 0x00, 0x00, 0x00, 0x00, /* bmaControls(2) */ 0x00, 0x00, 0x00, 0x00, /* iFeature */
這裏有個細節,若是OT的wTerminalType爲0x0101(即USB Streaming),在Mac OSX 10.12.5上是沒法進行音量控制的code
AUDIO_20_OT_DESC_SIZE, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */ AUDIO_OT_ID, /* bTerminalID */ 0x02, /* wTerminalType 0x0301: Speaker, 0x0302: Headphone*/ 0x03, 0x00, /* bAssocTerminal */ AUDIO_FU_ID, /* bSourceID */ AUDIO_CLK_ID, /* bCSourceID */ 0x00, /* bmControls */ 0x00, 0x00, /* iTerminal */
時鐘域的概念是UAC2.0裏新提出的,經過時鐘域的改變進行採樣率的更新。ip
AUDIO_20_CLK_SOURCE_DESC_SIZE, /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_CLOCK_SOURCE, /* bDescriptorSubtype */ AUDIO_CLK_ID, /* bClockID */ 0x01, /* bmAttributes */ 0x07, /* bmControls TODO */ 0x00, /* bAssocTerminal */ 0x00, /* iClockSource */
細節可參考我基於STM32F4Discovery實現了一個簡單的UAC2.0設備(https://git.oschina.net/crouchggj/STM32F4_USB_SoundCard.git)。get