【发布时间】:2017-04-24 00:17:26
【问题描述】:
我正在开发一个装有 Android Kitkat 版本的 SBC。 (板确实有 USB 主机)。但是由于Android 5.0 之后才引入了官方的usb 音频原生支持,所以我不能直接使用带SBC 的USB 音频设备。 我正在使用 libusb 来达到这个目的。我能够打开特定的端点。但是在捕获时获取所有空数据。我在 libusb 调用中没有收到任何错误。
以下是所遵循步骤的简短伪代码:
libusb_init(NULL)
devId = libusb_open_device_with_vid_pid(NULL, VID, PID)
if(libusb_kernel_driver_active(devId, IFACE_NUM)->detachKernel)
libusb_claim_interface(devId, IFACE_NUM)
libusb_set_interface_alt_setting(devId, IFACE_NUM, ALT_SETTING)
Loop{libusb_alloc_transfer(numOfPackets)
libusb_fill_iso_transfer(callBack)
libusb_set_iso_packet_lengths
libusb_submit_transfer}:NumOfTransfer(10) times
Inside callback: uint8_t* data = libusb_get_iso_packet_buffer_simple()
当我尝试打印数据指向的缓冲区时,所有数据都将变为 NULL。当在回调中检查我的 libusb_transfer 结构元素时,它给出的缓冲区长度为 1960,但 实际长度为 0。
我正在使用带有麦克风并充当 USB 音频设备的 Logitech C310 网络摄像头。 我正在使用接口编号 3 和备用设置 4,因为从设备描述符的下方部分可以清楚地看到
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x03 bInterfaceNumber
0x04 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol
0x00 iInterface
AS Interface Descriptor:
------------------------------
0x07 bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x03 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x01 bNrChannels (1 Channels)
0x02 bSubframeSize
0x10 bBitResolution (16 Bits/sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x86 bEndpointAddress (IN Endpoint)
0x05 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Data)
0x00C4 wMaxPacketSize (196 Bytes)
0x01 bInterval
0x00 bRefresh
0x00 bSynchAddress
我不知道哪里出了问题?任何人都可以在 Android 较低版本上分享任何有关 USB 音频的工作参考吗?
【问题讨论】:
标签: android audio usb audio-recording libusb