From 64554569c5c7271e22829f84fdc17447a90dda0d Mon Sep 17 00:00:00 2001 From: hechaofan Date: Wed, 24 Apr 2024 14:51:07 +0800 Subject: [PATCH] add for audioEndpointDescriptor Signed-off-by: hechaofan --- services/native/src/usb_descriptor_parser.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/native/src/usb_descriptor_parser.cpp b/services/native/src/usb_descriptor_parser.cpp index be31f390..cb3d5e4b 100644 --- a/services/native/src/usb_descriptor_parser.cpp +++ b/services/native/src/usb_descriptor_parser.cpp @@ -23,6 +23,8 @@ #include "usb_interface.h" #include "usbd_type.h" +static constexpr uint8_t NORMAL_ENDPOINT_DESCRIPTOR = 7; +static constexpr uint8_t AUDIO_ENDPOINT_DESCRIPTOR = 9; namespace OHOS { namespace USB { enum class DescriptorType { @@ -210,7 +212,8 @@ int32_t UsbDescriptorParser::ParseEndpointDescriptor( } UsbdEndpointDescriptor endpointDescriptor = *(reinterpret_cast(buffer + cursor)); - if (endpointDescriptor.bLength != sizeof(UsbdEndpointDescriptor)) { + if (endpointDescriptor.bLength != NORMAL_ENDPOINT_DESCRIPTOR && + endpointDescriptor.bLength != AUDIO_ENDPOINT_DESCRIPTOR) { USB_HILOGE(MODULE_USB_SERVICE, "Endpoint descriptor size error, length=%{public}d", endpointDescriptor.bLength); return UEC_SERVICE_INVALID_VALUE; } -- Gitee