From 7d924d702066ea00645cade86e30846361b45b8a Mon Sep 17 00:00:00 2001 From: wangtao Date: Mon, 19 Aug 2024 08:42:49 +0000 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E9=83=A8=E4=BD=BF=E7=94=A8arm=5Fusb?= =?UTF-8?q?=E7=9A=84deviceType=EF=BC=8C=E5=AF=B9=E5=A4=96=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangtao Change-Id: Idf7af9c92878fc0a5b127b0cb70a2af71e66c15d --- .../audiocommon/include/audio_device_info.h | 12 +- .../native/audiocommon/include/audio_effect.h | 2 + .../include/audio_policy_manager_stub.h | 1 + .../src/audio_policy_callback_proxy.cpp | 105 ++++++++++++++++ .../client/src/audio_policy_proxy.cpp | 103 --------------- .../server/include/audio_policy_server.h | 2 + .../include/service/audio_device_manager.h | 1 + .../include/service/audio_policy_service.h | 5 +- .../service/routers/privacy_priority_router.h | 2 + .../server/src/audio_policy_manager_stub.cpp | 19 +++ .../server/src/audio_policy_server.cpp | 8 ++ .../src/service/audio_device_manager.cpp | 9 ++ .../src/service/audio_policy_service.cpp | 118 ++++++++---------- .../routers/privacy_priority_router.cpp | 18 +++ .../client/src/audio_device_descriptor.cpp | 2 +- .../server/src/renderer_in_server.cpp | 4 - 16 files changed, 226 insertions(+), 185 deletions(-) diff --git a/interfaces/inner_api/native/audiocommon/include/audio_device_info.h b/interfaces/inner_api/native/audiocommon/include/audio_device_info.h index 1434d79104..5e057fd310 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_device_info.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_device_info.h @@ -187,10 +187,10 @@ inline bool IsInputDevice(DeviceType deviceType) return INPUT_DEVICE_TYPE_SET.count(deviceType) > 0; } -inline bool IsInputDevice(DeviceType deviceType, DeviceRole deviceRole, bool isArmUsb) +inline bool IsInputDevice(DeviceType deviceType, DeviceRole deviceRole) { // Arm usb device distinguishes input and output through device roles. - if ((deviceType == DEVICE_TYPE_USB_HEADSET && isArmUsb) || deviceType == DEVICE_TYPE_USB_ARM_HEADSET) { + if (deviceType == DEVICE_TYPE_USB_ARM_HEADSET) { return deviceRole == INPUT_DEVICE || deviceRole == DEVICE_ROLE_MAX; } else { return INPUT_DEVICE_TYPE_SET.count(deviceType) > 0; @@ -216,10 +216,10 @@ inline bool IsOutputDevice(DeviceType deviceType) return OUTPUT_DEVICE_TYPE_SET.count(deviceType) > 0; } -inline bool IsOutputDevice(DeviceType deviceType, DeviceRole deviceRole, bool isArmUsb) +inline bool IsOutputDevice(DeviceType deviceType, DeviceRole deviceRole) { // Arm usb device distinguishes input and output through device roles. - if ((deviceType == DEVICE_TYPE_USB_HEADSET && isArmUsb) || deviceType == DEVICE_TYPE_USB_ARM_HEADSET) { + if (deviceType == DEVICE_TYPE_USB_ARM_HEADSET) { return deviceRole == OUTPUT_DEVICE || deviceRole == DEVICE_ROLE_MAX; } else { return OUTPUT_DEVICE_TYPE_SET.count(deviceType) > 0; @@ -397,7 +397,6 @@ public: int32_t interruptGroupId; int32_t volumeGroupId; bool isLowLatencyDevice; - bool isArmUsbDevice; int32_t a2dpOffloadFlag; ConnectState connectState = CONNECTED; DeviceCategory deviceCategory = CATEGORY_DEFAULT; @@ -419,7 +418,6 @@ public: && parcel.WriteInt32(interruptGroupId) && parcel.WriteInt32(volumeGroupId) && parcel.WriteBool(isLowLatencyDevice) - && parcel.WriteBool(isArmUsbDevice) && parcel.WriteInt32(a2dpOffloadFlag) && parcel.WriteInt32(static_cast(deviceCategory)); } @@ -465,7 +463,6 @@ public: && parcel.WriteInt32(hasSystemPermission ? interruptGroupId : INVALID_GROUP_ID) && parcel.WriteInt32(hasSystemPermission ? volumeGroupId : INVALID_GROUP_ID) && parcel.WriteBool(isLowLatencyDevice) - && parcel.WriteBool(isArmUsbDevice) && parcel.WriteInt32(a2dpOffloadFlag) && parcel.WriteInt32(static_cast(deviceCategory)); } @@ -484,7 +481,6 @@ public: interruptGroupId = parcel.ReadInt32(); volumeGroupId = parcel.ReadInt32(); isLowLatencyDevice = parcel.ReadBool(); - isArmUsbDevice = parcel.ReadBool(); a2dpOffloadFlag = parcel.ReadInt32(); deviceCategory = static_cast(parcel.ReadInt32()); } diff --git a/interfaces/inner_api/native/audiocommon/include/audio_effect.h b/interfaces/inner_api/native/audiocommon/include/audio_effect.h index e55d7add3a..72e4ddaf64 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_effect.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_effect.h @@ -219,6 +219,8 @@ const std::unordered_map SUPPORTED_DEVICE_TYPE { {DEVICE_TYPE_MIC, "DEVICE_TYPE_MIC"}, {DEVICE_TYPE_WAKEUP, "DEVICE_TYPE_WAKEUP"}, {DEVICE_TYPE_USB_HEADSET, "DEVICE_TYPE_USB_HEADSET"}, + {DEVICE_TYPE_USB_ARM_HEADSET, "DEVICE_TYPE_USB_ARM_HEADSET"}, + {DEVICE_TYPE_DP, "DEVICE_TYPE_DP"}, {DEVICE_TYPE_FILE_SINK, "DEVICE_TYPE_FILE_SINK"}, {DEVICE_TYPE_FILE_SOURCE, "DEVICE_TYPE_FILE_SOURCE"}, {DEVICE_TYPE_EXTERN_CABLE, "DEVICE_TYPE_EXTERN_CABLE"}, diff --git a/services/audio_policy/client/include/audio_policy_manager_stub.h b/services/audio_policy/client/include/audio_policy_manager_stub.h index 7c060b2480..4caeb79a65 100644 --- a/services/audio_policy/client/include/audio_policy_manager_stub.h +++ b/services/audio_policy/client/include/audio_policy_manager_stub.h @@ -24,6 +24,7 @@ class AudioPolicyManagerStub : public IRemoteStub { public: virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + virtual bool IsArmUsbDevice(const AudioDeviceDescriptor &desc) = 0; private: void GetMaxVolumeLevelInternal(MessageParcel &data, MessageParcel &reply); diff --git a/services/audio_policy/client/src/audio_policy_callback_proxy.cpp b/services/audio_policy/client/src/audio_policy_callback_proxy.cpp index 6a1ceb4731..e7355a0ca8 100644 --- a/services/audio_policy/client/src/audio_policy_callback_proxy.cpp +++ b/services/audio_policy/client/src/audio_policy_callback_proxy.cpp @@ -187,5 +187,110 @@ int32_t AudioPolicyProxy::UnsetAudioConcurrencyCallback(const uint32_t sessionID return reply.ReadInt32(); } + +int32_t AudioPolicyProxy::SetDistributedRoutingRoleCallback(const sptr &object) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + CHECK_AND_RETURN_RET_LOG(object != nullptr, ERR_NULL_OBJECT, "object is null"); + bool ret = data.WriteInterfaceToken(GetDescriptor()); + CHECK_AND_RETURN_RET_LOG(ret, -1, "WriteInterfaceToken failed"); + (void)data.WriteRemoteObject(object); + int error = Remote()->SendRequest( + static_cast(AudioPolicyInterfaceCode::SET_DISTRIBUTED_ROUTING_ROLE_CALLBACK), data, reply, option); + CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, "failed error : %{public}d", error); + return reply.ReadInt32(); +} + +int32_t AudioPolicyProxy::UnsetDistributedRoutingRoleCallback() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + bool token = data.WriteInterfaceToken(GetDescriptor()); + CHECK_AND_RETURN_RET_LOG(token, ERROR, "data writeInterfaceToken failed"); + + int error = Remote()->SendRequest( + static_cast(AudioPolicyInterfaceCode::UNSET_DISTRIBUTED_ROUTING_ROLE_CALLBACK), data, reply, option); + CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, + "AudioPolicyProxy UnsetDistributedRoutingRoleCallback failed error : %{public}d", error); + return reply.ReadInt32(); +} + +int32_t AudioPolicyProxy::SetAudioDeviceRefinerCallback(const sptr &object) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + CHECK_AND_RETURN_RET_LOG(object != nullptr, ERR_NULL_OBJECT, "object is null"); + + bool ret = data.WriteInterfaceToken(GetDescriptor()); + CHECK_AND_RETURN_RET_LOG(ret, -1, "WriteInterfaceToken failed"); + + (void)data.WriteRemoteObject(object); + int32_t error = Remote()->SendRequest( + static_cast(AudioPolicyInterfaceCode::SET_AUDIO_DEVICE_REFINER_CALLBACK), data, reply, option); + CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, "SendRequest failed, error: %{public}d", error); + return reply.ReadInt32(); +} + +int32_t AudioPolicyProxy::UnsetAudioDeviceRefinerCallback() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + bool ret = data.WriteInterfaceToken(GetDescriptor()); + CHECK_AND_RETURN_RET_LOG(ret, -1, "WriteInterfaceToken failed"); + + int32_t error = Remote()->SendRequest( + static_cast(AudioPolicyInterfaceCode::UNSET_AUDIO_DEVICE_REFINER_CALLBACK), data, reply, option); + CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, "SendRequest failed, error: %{public}d", error); + return reply.ReadInt32(); +} + + +int32_t AudioPolicyProxy::RegisterSpatializationStateEventListener(const uint32_t sessionID, + const StreamUsage streamUsage, const sptr &object) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + bool ret = data.WriteInterfaceToken(GetDescriptor()); + CHECK_AND_RETURN_RET_LOG(ret, ERROR, "WriteInterfaceToken failed"); + CHECK_AND_RETURN_RET_LOG(object != nullptr, ERR_NULL_OBJECT, "SpatializationStateEventListener object is null"); + + data.WriteInt32(static_cast(sessionID)); + data.WriteInt32(static_cast(streamUsage)); + data.WriteRemoteObject(object); + int32_t error = Remote() ->SendRequest( + static_cast(AudioPolicyInterfaceCode::REGISTER_SPATIALIZATION_STATE_EVENT), data, reply, option); + CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, ERROR, "SendRequest failed , error: %{public}d", error); + + return reply.ReadInt32(); +} + +int32_t AudioPolicyProxy::UnregisterSpatializationStateEventListener(const uint32_t sessionID) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + bool ret = data.WriteInterfaceToken(GetDescriptor()); + CHECK_AND_RETURN_RET_LOG(ret, ERROR, "WriteInterfaceToken failed"); + + data.WriteInt32(static_cast(sessionID)); + int32_t error = Remote() ->SendRequest( + static_cast(AudioPolicyInterfaceCode::UNREGISTER_SPATIALIZATION_STATE_EVENT), data, reply, option); + CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, ERROR, "SendRequest failed , error: %{public}d", error); + + return reply.ReadInt32(); +} + } // namespace AudioStandard } // namespace OHOS \ No newline at end of file diff --git a/services/audio_policy/client/src/audio_policy_proxy.cpp b/services/audio_policy/client/src/audio_policy_proxy.cpp index eaf4b01df9..9b6cdf58a2 100644 --- a/services/audio_policy/client/src/audio_policy_proxy.cpp +++ b/services/audio_policy/client/src/audio_policy_proxy.cpp @@ -704,38 +704,6 @@ int32_t AudioPolicyProxy::ConfigDistributedRoutingRole(const sptr &object) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - CHECK_AND_RETURN_RET_LOG(object != nullptr, ERR_NULL_OBJECT, "object is null"); - bool ret = data.WriteInterfaceToken(GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(ret, -1, "WriteInterfaceToken failed"); - (void)data.WriteRemoteObject(object); - int error = Remote()->SendRequest( - static_cast(AudioPolicyInterfaceCode::SET_DISTRIBUTED_ROUTING_ROLE_CALLBACK), data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, "failed error : %{public}d", error); - return reply.ReadInt32(); -} - -int32_t AudioPolicyProxy::UnsetDistributedRoutingRoleCallback() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - bool token = data.WriteInterfaceToken(GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, ERROR, "data writeInterfaceToken failed"); - - int error = Remote()->SendRequest( - static_cast(AudioPolicyInterfaceCode::UNSET_DISTRIBUTED_ROUTING_ROLE_CALLBACK), data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, - "AudioPolicyProxy UnsetDistributedRoutingRoleCallback failed error : %{public}d", error); - return reply.ReadInt32(); -} - int32_t AudioPolicyProxy::ActivateAudioSession(const AudioSessionStrategy &strategy) { MessageParcel data; @@ -1991,44 +1959,6 @@ int32_t AudioPolicyProxy::UpdateSpatialDeviceState(const AudioSpatialDeviceState return reply.ReadInt32(); } -int32_t AudioPolicyProxy::RegisterSpatializationStateEventListener(const uint32_t sessionID, - const StreamUsage streamUsage, const sptr &object) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - bool ret = data.WriteInterfaceToken(GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(ret, ERROR, "WriteInterfaceToken failed"); - CHECK_AND_RETURN_RET_LOG(object != nullptr, ERR_NULL_OBJECT, "SpatializationStateEventListener object is null"); - - data.WriteInt32(static_cast(sessionID)); - data.WriteInt32(static_cast(streamUsage)); - data.WriteRemoteObject(object); - int32_t error = Remote() ->SendRequest( - static_cast(AudioPolicyInterfaceCode::REGISTER_SPATIALIZATION_STATE_EVENT), data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, ERROR, "SendRequest failed , error: %{public}d", error); - - return reply.ReadInt32(); -} - -int32_t AudioPolicyProxy::UnregisterSpatializationStateEventListener(const uint32_t sessionID) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - bool ret = data.WriteInterfaceToken(GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(ret, ERROR, "WriteInterfaceToken failed"); - - data.WriteInt32(static_cast(sessionID)); - int32_t error = Remote() ->SendRequest( - static_cast(AudioPolicyInterfaceCode::UNREGISTER_SPATIALIZATION_STATE_EVENT), data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, ERROR, "SendRequest failed , error: %{public}d", error); - - return reply.ReadInt32(); -} - int32_t AudioPolicyProxy::RegisterPolicyCallbackClient(const sptr &object, const int32_t zoneID) { MessageParcel data; @@ -2314,39 +2244,6 @@ bool AudioPolicyProxy::IsHeadTrackingDataRequested(const std::string &macAddress return reply.ReadBool(); } -int32_t AudioPolicyProxy::SetAudioDeviceRefinerCallback(const sptr &object) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - CHECK_AND_RETURN_RET_LOG(object != nullptr, ERR_NULL_OBJECT, "object is null"); - - bool ret = data.WriteInterfaceToken(GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(ret, -1, "WriteInterfaceToken failed"); - - (void)data.WriteRemoteObject(object); - int32_t error = Remote()->SendRequest( - static_cast(AudioPolicyInterfaceCode::SET_AUDIO_DEVICE_REFINER_CALLBACK), data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, "SendRequest failed, error: %{public}d", error); - return reply.ReadInt32(); -} - -int32_t AudioPolicyProxy::UnsetAudioDeviceRefinerCallback() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - bool ret = data.WriteInterfaceToken(GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(ret, -1, "WriteInterfaceToken failed"); - - int32_t error = Remote()->SendRequest( - static_cast(AudioPolicyInterfaceCode::UNSET_AUDIO_DEVICE_REFINER_CALLBACK), data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == ERR_NONE, error, "SendRequest failed, error: %{public}d", error); - return reply.ReadInt32(); -} - int32_t AudioPolicyProxy::TriggerFetchDevice(AudioStreamDeviceChangeReasonExt reason) { MessageParcel data; diff --git a/services/audio_policy/server/include/audio_policy_server.h b/services/audio_policy/server/include/audio_policy_server.h index f543ddaabd..d0b83c5c7b 100644 --- a/services/audio_policy/server/include/audio_policy_server.h +++ b/services/audio_policy/server/include/audio_policy_server.h @@ -126,6 +126,8 @@ public: float GetSystemVolumeInDb(AudioVolumeType volumeType, int32_t volumeLevel, DeviceType deviceType) override; + bool IsArmUsbDevice(const AudioDeviceDescriptor &desc) override; + int32_t SelectOutputDevice(sptr audioRendererFilter, std::vector> audioDeviceDescriptors) override; diff --git a/services/audio_policy/server/include/service/audio_device_manager.h b/services/audio_policy/server/include/service/audio_device_manager.h index 4a4d1ce0b4..c5f532e7d1 100644 --- a/services/audio_policy/server/include/service/audio_device_manager.h +++ b/services/audio_policy/server/include/service/audio_device_manager.h @@ -77,6 +77,7 @@ public: DeviceUsage GetDeviceUsage(const AudioDeviceDescriptor &desc); std::string GetConnDevicesStr(); std::string GetConnDevicesStr(const vector> &descs); + bool IsArmUsbDevice(const AudioDeviceDescriptor &desc); void OnReceiveBluetoothEvent(const std::string macAddress, const std::string deviceName); bool IsDeviceConnected(sptr &audioDeviceDescriptors); bool IsVirtualConnectedDevice(const sptr &selectedDesc); diff --git a/services/audio_policy/server/include/service/audio_policy_service.h b/services/audio_policy/server/include/service/audio_policy_service.h index ad0f3c4e01..8f430eae79 100644 --- a/services/audio_policy/server/include/service/audio_policy_service.h +++ b/services/audio_policy/server/include/service/audio_policy_service.h @@ -120,6 +120,8 @@ public: void NotifyUserSelectionEventToBt(sptr audioDeviceDescriptor); + bool IsArmUsbDevice(const AudioDeviceDescriptor &desc); + int32_t SelectOutputDevice(sptr audioRendererFilter, std::vector> audioDeviceDescriptors); int32_t SelectFastOutputDevice(sptr audioRendererFilter, @@ -1086,7 +1088,8 @@ private: mutable std::shared_mutex deviceStatusUpdateSharedMutex_; - bool isArmUsbDevice_ = false; + bool hasArmUsbDevice_ = false; + bool hasHifiUsbDevice_ = false; // Only the first usb device is supported now, hifi or arm. bool hasDpDevice_ = false; // Only the first dp device is supported. AudioDeviceManager &audioDeviceManager_; diff --git a/services/audio_policy/server/include/service/routers/privacy_priority_router.h b/services/audio_policy/server/include/service/routers/privacy_priority_router.h index 1551155d78..ccb1df5348 100644 --- a/services/audio_policy/server/include/service/routers/privacy_priority_router.h +++ b/services/audio_policy/server/include/service/routers/privacy_priority_router.h @@ -42,6 +42,8 @@ public: int32_t clientUID) override; std::unique_ptr GetRecordCaptureDevice(SourceType sourceType, int32_t clientUID) override; std::unique_ptr GetToneRenderDevice(StreamUsage streamUsage, int32_t clientUID) override; +private: + void RemoveArmUsb(vector> &descs); }; } // namespace AudioStandard } // namespace OHOS diff --git a/services/audio_policy/server/src/audio_policy_manager_stub.cpp b/services/audio_policy/server/src/audio_policy_manager_stub.cpp index 45bbb54497..b7dfa69972 100644 --- a/services/audio_policy/server/src/audio_policy_manager_stub.cpp +++ b/services/audio_policy/server/src/audio_policy_manager_stub.cpp @@ -519,6 +519,9 @@ void AudioPolicyManagerStub::SelectOutputDeviceInternal(MessageParcel &data, Mes for (int i = 0; i < size; i++) { sptr audioDeviceDescriptor = AudioDeviceDescriptor::Unmarshalling(data); CHECK_AND_RETURN_LOG(audioDeviceDescriptor != nullptr, "Unmarshalling fail."); + if (IsArmUsbDevice(*audioDeviceDescriptor)) { + audioDeviceDescriptor->deviceType_ = DEVICE_TYPE_USB_ARM_HEADSET; + } targetOutputDevice.push_back(audioDeviceDescriptor); } @@ -548,6 +551,9 @@ void AudioPolicyManagerStub::SelectInputDeviceInternal(MessageParcel &data, Mess for (int i = 0; i < size; i++) { sptr audioDeviceDescriptor = AudioDeviceDescriptor::Unmarshalling(data); CHECK_AND_RETURN_LOG(audioDeviceDescriptor != nullptr, "Unmarshalling fail."); + if (IsArmUsbDevice(*audioDeviceDescriptor)) { + audioDeviceDescriptor->deviceType_ = DEVICE_TYPE_USB_ARM_HEADSET; + } targetInputDevice.push_back(audioDeviceDescriptor); } @@ -963,6 +969,9 @@ void AudioPolicyManagerStub::GetHardwareOutputSamplingRateInternal(MessageParcel sptr audioDeviceDescriptor = AudioDeviceDescriptor::Unmarshalling(data); CHECK_AND_RETURN_LOG(audioDeviceDescriptor != nullptr, "Unmarshalling fail."); + if (IsArmUsbDevice(*audioDeviceDescriptor)) { + audioDeviceDescriptor->deviceType_ = DEVICE_TYPE_USB_ARM_HEADSET; + } int32_t result = GetHardwareOutputSamplingRate(audioDeviceDescriptor); reply.WriteInt32(result); } @@ -1043,6 +1052,9 @@ void AudioPolicyManagerStub::UnsetAvailableDeviceChangeCallbackInternal(MessageP void AudioPolicyManagerStub::ConfigDistributedRoutingRoleInternal(MessageParcel &data, MessageParcel &reply) { sptr descriptor = AudioDeviceDescriptor::Unmarshalling(data); + if (IsArmUsbDevice(*descriptor)) { + descriptor->deviceType_ = DEVICE_TYPE_USB_ARM_HEADSET; + } CastType type = static_cast(data.ReadInt32()); int32_t result = ConfigDistributedRoutingRole(descriptor, type); reply.WriteInt32(result); @@ -1086,6 +1098,9 @@ void AudioPolicyManagerStub::SetSpatializationEnabledForDeviceInternal(MessagePa { sptr audioDeviceDescriptor = AudioDeviceDescriptor::Unmarshalling(data); CHECK_AND_RETURN_LOG(audioDeviceDescriptor != nullptr, "Unmarshalling fail."); + if (IsArmUsbDevice(*audioDeviceDescriptor)) { + audioDeviceDescriptor->deviceType_ = DEVICE_TYPE_USB_ARM_HEADSET; + } bool enable = data.ReadBool(); int32_t result = SetSpatializationEnabled(audioDeviceDescriptor, enable); reply.WriteInt32(result); @@ -1115,6 +1130,10 @@ void AudioPolicyManagerStub::SetHeadTrackingEnabledForDeviceInternal(MessageParc { sptr audioDeviceDescriptor = AudioDeviceDescriptor::Unmarshalling(data); CHECK_AND_RETURN_LOG(audioDeviceDescriptor != nullptr, "Unmarshalling fail."); + + if (IsArmUsbDevice(*audioDeviceDescriptor)) { + audioDeviceDescriptor->deviceType_ = DEVICE_TYPE_USB_ARM_HEADSET; + } bool enable = data.ReadBool(); int32_t result = SetHeadTrackingEnabled(audioDeviceDescriptor, enable); reply.WriteInt32(result); diff --git a/services/audio_policy/server/src/audio_policy_server.cpp b/services/audio_policy/server/src/audio_policy_server.cpp index cb3dab325b..b448241f12 100644 --- a/services/audio_policy/server/src/audio_policy_server.cpp +++ b/services/audio_policy/server/src/audio_policy_server.cpp @@ -847,6 +847,14 @@ bool AudioPolicyServer::GetStreamMuteInternal(AudioStreamType streamType) return audioPolicyService_.GetStreamMute(streamType); } +bool AudioPolicyServer::IsArmUsbDevice(const AudioDeviceDescriptor &desc) +{ + if (desc.deviceType_ == DEVICE_TYPE_USB_ARM_HEADSET) return true; + if (desc.deviceType_ != DEVICE_TYPE_USB_HEADSET) return false; + + return audioPolicyService_.IsArmUsbDevice(desc); +} + int32_t AudioPolicyServer::SelectOutputDevice(sptr audioRendererFilter, std::vector> audioDeviceDescriptors) { diff --git a/services/audio_policy/server/src/service/audio_device_manager.cpp b/services/audio_policy/server/src/service/audio_device_manager.cpp index 8e1164f479..2f333da8e5 100644 --- a/services/audio_policy/server/src/service/audio_device_manager.cpp +++ b/services/audio_policy/server/src/service/audio_device_manager.cpp @@ -219,6 +219,15 @@ void AudioDeviceManager::MakePairedDefaultDeviceImpl(const shared_ptrdeviceId_ == desc.deviceId_; + }; + auto itr = std::find_if(connectedDevices_.begin(), connectedDevices_.end(), isPresent); + return (*itr)->deviceType_ == DEVICE_TYPE_USB_ARM_HEADSET; +} + void AudioDeviceManager::AddConnectedDevices(const shared_ptr &devDesc) { connectedDevices_.insert(connectedDevices_.begin(), devDesc); diff --git a/services/audio_policy/server/src/service/audio_policy_service.cpp b/services/audio_policy/server/src/service/audio_policy_service.cpp index de9bb9a608..c7ff2b85b2 100644 --- a/services/audio_policy/server/src/service/audio_policy_service.cpp +++ b/services/audio_policy/server/src/service/audio_policy_service.cpp @@ -845,7 +845,7 @@ bool AudioPolicyService::CheckActiveOutputDeviceSupportOffload() } return dev == DEVICE_TYPE_SPEAKER || (dev == DEVICE_TYPE_BLUETOOTH_A2DP && a2dpOffloadFlag_ == A2DP_OFFLOAD) || - (dev == DEVICE_TYPE_USB_HEADSET && !isArmUsbDevice_); + dev == DEVICE_TYPE_USB_HEADSET; } void AudioPolicyService::SetOffloadAvailableFromXML(AudioModuleInfo &moduleInfo) @@ -1062,6 +1062,13 @@ void AudioPolicyService::NotifyRemoteRenderState(std::string networkId, std::str AUDIO_DEBUG_LOG("Success"); } +bool AudioPolicyService::IsArmUsbDevice(const AudioDeviceDescriptor &desc) +{ + std::shared_lock deviceLock(deviceStatusUpdateSharedMutex_); + + return audioDeviceManager_.IsArmUsbDevice(desc); +} + bool AudioPolicyService::IsDeviceConnected(sptr &audioDeviceDescriptors) const { return audioDeviceManager_.IsDeviceConnected(audioDeviceDescriptors); @@ -1589,9 +1596,6 @@ DistributedRoutingInfo& AudioPolicyService::GetDistributedRoutingRoleInfo() std::string AudioPolicyService::GetSinkPortName(InternalDeviceType deviceType, AudioPipeType pipeType) { std::string portName = PORT_NONE; - if (deviceType == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { - deviceType = DEVICE_TYPE_USB_ARM_HEADSET; - } switch (deviceType) { case InternalDeviceType::DEVICE_TYPE_BLUETOOTH_A2DP: if (a2dpOffloadFlag_ == A2DP_OFFLOAD && IsA2dpOffloadConnected()) { @@ -1643,9 +1647,6 @@ std::string AudioPolicyService::GetSinkPortName(InternalDeviceType deviceType, A std::string AudioPolicyService::GetSourcePortName(InternalDeviceType deviceType) { std::string portName = PORT_NONE; - if (deviceType == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { - deviceType = DEVICE_TYPE_USB_ARM_HEADSET; - } switch (deviceType) { case InternalDeviceType::DEVICE_TYPE_MIC: portName = PRIMARY_MIC; @@ -2022,9 +2023,6 @@ void AudioPolicyService::UpdateActiveDeviceRoute(InternalDeviceType deviceType, { Trace trace("AudioPolicyService::UpdateActiveDeviceRoute DeviceType:" + std::to_string(deviceType)); AUDIO_INFO_LOG("Active route with type[%{public}d]", deviceType); - if (deviceType == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { - deviceType = DEVICE_TYPE_USB_ARM_HEADSET; - } std::vector> activeDevices; activeDevices.push_back(make_pair(deviceType, deviceFlag)); UpdateActiveDevicesRoute(activeDevices); @@ -2038,9 +2036,6 @@ void AudioPolicyService::UpdateActiveDevicesRoute(std::vectorrendererInfo.originalFlag != AUDIO_FLAG_NORMAL && rendererChangeInfo->rendererInfo.originalFlag != AUDIO_FLAG_FORCED_NORMAL, false, "original flag is normal"); // Switch between old and new stream as they have different hals - std::string oldDevicePortName = rendererChangeInfo->outputDeviceInfo.isArmUsbDevice ? - USB_SPEAKER : GetSinkPortName(rendererChangeInfo->outputDeviceInfo.deviceType); + std::string oldDevicePortName = GetSinkPortName(rendererChangeInfo->outputDeviceInfo.deviceType); bool isOldDeviceLocal = rendererChangeInfo->outputDeviceInfo.networkId == "" || rendererChangeInfo->outputDeviceInfo.networkId == LOCAL_NETWORK_ID; bool isNewDeviceLocal = desc->networkId_ == "" || desc->networkId_ == LOCAL_NETWORK_ID; @@ -2469,7 +2463,7 @@ bool AudioPolicyService::NotifyRecreateDirectStream(std::unique_ptrrendererInfo.pipeType); if (!IsDirectSupportedDevice(currentActiveDevice_.deviceType_) && rendererChangeInfo->rendererInfo.pipeType == PIPE_TYPE_DIRECT_MUSIC) { - if (rendererChangeInfo->outputDeviceInfo.isArmUsbDevice) { + if (rendererChangeInfo->outputDeviceInfo.deviceType == DEVICE_TYPE_USB_ARM_HEADSET) { AUDIO_INFO_LOG("old device is arm usb"); return false; } @@ -2479,10 +2473,6 @@ bool AudioPolicyService::NotifyRecreateDirectStream(std::unique_ptrrendererInfo.pipeType != PIPE_TYPE_DIRECT_MUSIC) { - if (isArmUsbDevice_) { - AUDIO_INFO_LOG("current device is arm usb"); - return false; - } AudioRendererInfo info = rendererChangeInfo->rendererInfo; if (info.streamUsage == STREAM_USAGE_MUSIC && info.rendererFlags == AUDIO_FLAG_NORMAL && info.samplingRate >= SAMPLE_RATE_48000 && info.format >= SAMPLE_S24LE) { @@ -2717,8 +2707,7 @@ bool AudioPolicyService::NotifyRecreateCapturerStream(bool isUpdateActiveDevice, CHECK_AND_RETURN_RET_LOG(capturerChangeInfo->capturerInfo.originalFlag == AUDIO_FLAG_MMAP, false, "original flag is false"); // Switch between old and new stream as they have different hals - std::string oldDevicePortName = capturerChangeInfo->inputDeviceInfo.isArmUsbDevice ? - USB_SPEAKER : GetSourcePortName(capturerChangeInfo->inputDeviceInfo.deviceType); + std::string oldDevicePortName = GetSourcePortName(capturerChangeInfo->inputDeviceInfo.deviceType); if ((strcmp(oldDevicePortName.c_str(), GetSourcePortName(currentActiveDevice_.deviceType_).c_str())) || ((capturerChangeInfo->inputDeviceInfo.networkId == LOCAL_NETWORK_ID) ^ (currentActiveDevice_.networkId_ == LOCAL_NETWORK_ID))) { @@ -3046,9 +3035,6 @@ int32_t AudioPolicyService::HandleActiveDevice(DeviceType deviceType) if (GetVolumeGroupType(currentActiveDevice_.deviceType_) != GetVolumeGroupType(deviceType)) { SetVolumeForSwitchDevice(deviceType); } - if (deviceType == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { - deviceType = DEVICE_TYPE_USB_ARM_HEADSET; - } if (isUpdateRouteSupported_) { UpdateActiveDeviceRoute(deviceType, DeviceFlag::OUTPUT_DEVICES_FLAG); } @@ -3075,7 +3061,7 @@ int32_t AudioPolicyService::HandleArmUsbDevice(DeviceType deviceType, DeviceRole { Trace trace("AudioPolicyService::HandleArmUsbDevice"); - if (deviceType == DEVICE_TYPE_USB_HEADSET) { + if (deviceType == DEVICE_TYPE_USB_ARM_HEADSET) { string deviceInfo = ""; if (g_adProxy != nullptr) { std::string identity = IPCSkeleton::ResetCallingIdentity(); @@ -3116,12 +3102,8 @@ int32_t AudioPolicyService::RehandlePnpDevice(DeviceType deviceType, DeviceRole ret = HandleSpecialDeviceType(deviceType, isConnected, address); CHECK_AND_RETURN_RET_LOG(ret == SUCCESS, ret, "Rehandle special device type failed"); - if (deviceType == DEVICE_TYPE_USB_HEADSET && !isArmUsbDevice_) { - AUDIO_INFO_LOG("rehandle device is not arm usb device, nothing to do"); - return SUCCESS; - } - - if (deviceType == DEVICE_TYPE_USB_HEADSET) { + CHECK_AND_RETURN_RET_LOG(deviceType != DEVICE_TYPE_USB_HEADSET, ret, "Hifi device, don't load module"); + if (deviceType == DEVICE_TYPE_USB_ARM_HEADSET) { if (HandleArmUsbDevice(deviceType, deviceRole, address) == SUCCESS) { return SUCCESS; } @@ -3519,10 +3501,10 @@ void AudioPolicyService::UpdateConnectedDevicesWhenConnecting(const AudioDeviceD std::vector> &descForCb) { AUDIO_INFO_LOG("UpdateConnectedDevicesWhenConnecting In, deviceType: %{public}d", updatedDesc.deviceType_); - if (IsOutputDevice(updatedDesc.deviceType_, updatedDesc.deviceRole_, isArmUsbDevice_)) { + if (IsOutputDevice(updatedDesc.deviceType_, updatedDesc.deviceRole_)) { UpdateConnectedDevicesWhenConnectingForOutputDevice(updatedDesc, descForCb); } - if (IsInputDevice(updatedDesc.deviceType_, updatedDesc.deviceRole_, isArmUsbDevice_)) { + if (IsInputDevice(updatedDesc.deviceType_, updatedDesc.deviceRole_)) { UpdateConnectedDevicesWhenConnectingForInputDevice(updatedDesc, descForCb); } } @@ -3630,7 +3612,7 @@ int32_t AudioPolicyService::HandleLocalDeviceConnected(AudioDeviceDescriptor &up } } - if (isArmUsbDevice_ && updatedDesc.deviceType_ == DEVICE_TYPE_USB_HEADSET) { + if (updatedDesc.deviceType_ == DEVICE_TYPE_USB_ARM_HEADSET) { int32_t loadOutputResult = HandleArmUsbDevice(updatedDesc.deviceType_, OUTPUT_DEVICE, updatedDesc.macAddress_); if (loadOutputResult != SUCCESS) { loadOutputResult = RehandlePnpDevice(updatedDesc.deviceType_, OUTPUT_DEVICE, updatedDesc.macAddress_); @@ -3640,7 +3622,8 @@ int32_t AudioPolicyService::HandleLocalDeviceConnected(AudioDeviceDescriptor &up loadInputResult = RehandlePnpDevice(updatedDesc.deviceType_, INPUT_DEVICE, updatedDesc.macAddress_); } if (loadOutputResult != SUCCESS && loadInputResult != SUCCESS) { - isArmUsbDevice_ = false; + hasArmUsbDevice_ = false; + updatedDesc.deviceType_ = DEVICE_TYPE_USB_HEADSET; AUDIO_ERR_LOG("Load usb failed, set arm usb flag to false"); return ERROR; } @@ -3674,7 +3657,7 @@ int32_t AudioPolicyService::HandleLocalDeviceDisconnected(const AudioDeviceDescr UpdateActiveA2dpDeviceWhenDisconnecting(updatedDesc.macAddress_); } - if (updatedDesc.deviceType_ == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { + if (updatedDesc.deviceType_ == DEVICE_TYPE_USB_ARM_HEADSET) { ClosePortAndEraseIOHandle(USB_SPEAKER); ClosePortAndEraseIOHandle(USB_MIC); } @@ -3725,16 +3708,32 @@ DeviceType AudioPolicyService::FindConnectedHeadset() int32_t AudioPolicyService::HandleSpecialDeviceType(DeviceType &devType, bool &isConnected, const std::string &address) { // usb device needs to be distinguished form arm or hifi - if (devType == DEVICE_TYPE_USB_HEADSET && isConnected) { - if (g_adProxy == nullptr) { - return ERROR; - } + if (devType == DEVICE_TYPE_USB_HEADSET) { + CHECK_AND_RETURN_RET_LOG(g_adProxy != nullptr, ERROR, "Audio server Proxy is null"); + AUDIO_INFO_LOG("has hifi:%{public}d, has arm:%{public}d", hasHifiUsbDevice_, hasArmUsbDevice_); std::string identity = IPCSkeleton::ResetCallingIdentity(); const std::string value = g_adProxy->GetAudioParameter("need_change_usb_device"); IPCSkeleton::SetCallingIdentity(identity); AUDIO_INFO_LOG("get value %{public}s from hal when usb device connect", value.c_str()); - if (value == "false") { - isArmUsbDevice_ = true; + if (isConnected) { + bool isArmConnect = (value == "false" || hasHifiUsbDevice_); + if (isArmConnect) { + hasArmUsbDevice_ = true; + devType = DEVICE_TYPE_USB_ARM_HEADSET; + CHECK_AND_RETURN_RET_LOG(!hasHifiUsbDevice_, ERROR, "Hifi device already exists, ignore this one."); + } else { + hasHifiUsbDevice_ = true; + CHECK_AND_RETURN_RET_LOG(!hasArmUsbDevice_, ERROR, "Arm device already exists, ignore this one."); + } + } else { + bool isArmDisconnect = ((hasArmUsbDevice_ && !hasHifiUsbDevice_) || + (hasArmUsbDevice_ && hasHifiUsbDevice_ && value == "true")); + if (isArmDisconnect) { + devType = DEVICE_TYPE_USB_ARM_HEADSET; + hasArmUsbDevice_ = false; + } else { + hasHifiUsbDevice_ = false; + } } } @@ -3758,7 +3757,7 @@ void AudioPolicyService::ResetToSpeaker(DeviceType devType) if (devType != currentActiveDevice_.deviceType_) { return; } - if (devType == DEVICE_TYPE_BLUETOOTH_SCO || (devType == DEVICE_TYPE_USB_HEADSET && !isArmUsbDevice_) || + if (devType == DEVICE_TYPE_BLUETOOTH_SCO || devType == DEVICE_TYPE_USB_HEADSET || devType == DEVICE_TYPE_WIRED_HEADSET || devType == DEVICE_TYPE_WIRED_HEADPHONES) { UpdateActiveDeviceRoute(DEVICE_TYPE_SPEAKER, DeviceFlag::OUTPUT_DEVICES_FLAG); } @@ -3770,9 +3769,6 @@ void AudioPolicyService::OnDeviceStatusUpdated(DeviceType devType, bool isConnec // Pnp device status update std::lock_guard deviceLock(deviceStatusUpdateSharedMutex_); - AUDIO_INFO_LOG("Device connection state updated | TYPE[%{public}d] STATUS[%{public}d], address[%{public}s]", - devType, isConnected, GetEncryptStr(macAddress).c_str()); - AudioStreamDeviceChangeReasonExt reason = AudioStreamDeviceChangeReasonExt::ExtEnum::UNKNOWN; // fill device change action for callback std::vector> descForCb = {}; @@ -3780,6 +3776,10 @@ void AudioPolicyService::OnDeviceStatusUpdated(DeviceType devType, bool isConnec int32_t result = ERROR; result = HandleSpecialDeviceType(devType, isConnected, macAddress); CHECK_AND_RETURN_LOG(result == SUCCESS, "handle special deviceType failed."); + + AUDIO_INFO_LOG("Device connection state updated | TYPE[%{public}d] STATUS[%{public}d], address[%{public}s]", + devType, isConnected, GetEncryptStr(macAddress).c_str()); + AudioDeviceDescriptor updatedDesc(devType, GetDeviceRole(devType)); UpdateLocalGroupInfo(isConnected, macAddress, deviceName, streamInfo, updatedDesc); @@ -3803,9 +3803,6 @@ void AudioPolicyService::OnDeviceStatusUpdated(DeviceType devType, bool isConnec reason = AudioStreamDeviceChangeReason::OLD_DEVICE_UNAVALIABLE; FetchDevice(true, reason); // fix pop, fetch device before unload module result = HandleLocalDeviceDisconnected(updatedDesc); - if (devType == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { - isArmUsbDevice_ = false; - } CHECK_AND_RETURN_LOG(result == SUCCESS, "Disconnect local device failed."); } @@ -4838,7 +4835,6 @@ void AudioPolicyService::UpdateDeviceInfo(DeviceInfo &deviceInfo, const sptrchannelIndexMasks_; deviceInfo.displayName = desc->displayName_; deviceInfo.connectState = desc->connectState_; - deviceInfo.isArmUsbDevice = isArmUsbDevice_; if (deviceInfo.deviceType == DEVICE_TYPE_BLUETOOTH_A2DP) { deviceInfo.a2dpOffloadFlag = a2dpOffloadFlag_; @@ -6040,7 +6036,6 @@ int32_t AudioPolicyService::GetProcessDeviceInfo(const AudioProcessConfig &confi deviceInfo.networkId = LOCAL_NETWORK_ID; deviceInfo.deviceType = currentActiveDevice_.deviceType_; deviceInfo.deviceRole = OUTPUT_DEVICE; - deviceInfo.isArmUsbDevice = isArmUsbDevice_; } else { if (config.capturerInfo.sourceType == SOURCE_TYPE_VOICE_COMMUNICATION) { return GetVoipRecordDeviceInfo(config, deviceInfo); @@ -8260,11 +8255,7 @@ bool AudioPolicyService::IsA2dpOrArmUsbDevice(const InternalDeviceType &deviceTy case DEVICE_TYPE_USB_ARM_HEADSET: return true; default: { - if (deviceType == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { - return true; - } else { - return false; - } + return false; } } } @@ -8280,15 +8271,6 @@ bool AudioPolicyService::SelectRingerOrAlarmDevices(const vector> activeDevices; for (size_t i = 0; i < descs.size(); i++) { if (IsRingerOrAlarmerDualDevicesRange(descs[i]->deviceType_)) { - if (descs.front()->deviceType_ == DEVICE_TYPE_USB_HEADSET && - descs[i]->deviceType_ == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { - descs[i]->deviceType_ = DEVICE_TYPE_USB_ARM_HEADSET; - AUDIO_INFO_LOG("usb headset is arm device, set it to arm, and just only add it, " - "devicetype[%{public}zu]:%{public}d", i, descs[i]->deviceType_); - activeDevices.push_back(make_pair(descs[i]->deviceType_, DeviceFlag::OUTPUT_DEVICES_FLAG)); - break; - } - activeDevices.push_back(make_pair(descs[i]->deviceType_, DeviceFlag::OUTPUT_DEVICES_FLAG)); AUDIO_INFO_LOG("select ringer/alarm devices devicetype[%{public}zu]:%{public}d", i, descs[i]->deviceType_); } else { @@ -8344,7 +8326,7 @@ void AudioPolicyService::DealAudioSceneOutputDevices(const AudioScene &audioScen if (!descs.empty()) { for (size_t i = 0; i < descs.size(); i++) { - if (descs[i]->getType() == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { + if (descs[i]->getType() == DEVICE_TYPE_USB_ARM_HEADSET) { AUDIO_INFO_LOG("usb headset is arm device."); activeOutputDevices.push_back(DEVICE_TYPE_USB_ARM_HEADSET); haveArmUsbDevice = true; @@ -8353,7 +8335,7 @@ void AudioPolicyService::DealAudioSceneOutputDevices(const AudioScene &audioScen } } } else { - if (currentActiveDevice_.deviceType_ == DEVICE_TYPE_USB_HEADSET && isArmUsbDevice_) { + if (currentActiveDevice_.deviceType_ == DEVICE_TYPE_USB_ARM_HEADSET) { activeOutputDevices.push_back(DEVICE_TYPE_USB_ARM_HEADSET); haveArmUsbDevice = true; } else { diff --git a/services/audio_policy/server/src/service/routers/privacy_priority_router.cpp b/services/audio_policy/server/src/service/routers/privacy_priority_router.cpp index b6cf1d1900..ab8eb30c5a 100644 --- a/services/audio_policy/server/src/service/routers/privacy_priority_router.cpp +++ b/services/audio_policy/server/src/service/routers/privacy_priority_router.cpp @@ -34,11 +34,29 @@ unique_ptr PrivacyPriorityRouter::GetMediaRenderDevice(St return desc; } +void PrivacyPriorityRouter::RemoveArmUsb(vector> &descs) +{ + auto isPresent = [] (const unique_ptr &desc) { + CHECK_AND_RETURN_RET_LOG(desc != nullptr, false, "Invalid device descriptor"); + return desc->deviceType_ == DEVICE_TYPE_USB_ARM_HEADSET; + }; + + auto removeBeginIt = std::remove_if(descs.begin(), descs.end(), isPresent); + size_t deleteNum = static_cast(descs.end() - removeBeginIt); + descs.erase(removeBeginIt, descs.end()); + AUDIO_INFO_LOG("Remove %{public}zu desc from privacy list", deleteNum); +} + unique_ptr PrivacyPriorityRouter::GetCallRenderDevice(StreamUsage streamUsage, int32_t clientUID) { vector> descs = AudioDeviceManager::GetAudioDeviceManager().GetCommRenderPrivacyDevices(); + + if (streamUsage == STREAM_USAGE_VOICE_MODEM_COMMUNICATION) { + RemoveArmUsb(descs); + } + unique_ptr desc = GetLatestConnectDeivce(descs); AUDIO_DEBUG_LOG("streamUsage %{public}d clientUID %{public}d fetch device %{public}d", streamUsage, clientUID, desc->deviceType_); diff --git a/services/audio_service/client/src/audio_device_descriptor.cpp b/services/audio_service/client/src/audio_device_descriptor.cpp index bf18d10522..6ff423ba6a 100644 --- a/services/audio_service/client/src/audio_device_descriptor.cpp +++ b/services/audio_service/client/src/audio_device_descriptor.cpp @@ -139,7 +139,7 @@ DeviceRole AudioDeviceDescriptor::getRole() const bool AudioDeviceDescriptor::Marshalling(Parcel &parcel) const { - parcel.WriteInt32(deviceType_); + parcel.WriteInt32(deviceType_ == DEVICE_TYPE_USB_ARM_HEADSET ? DEVICE_TYPE_USB_HEADSET : deviceType_); parcel.WriteInt32(deviceRole_); parcel.WriteInt32(deviceId_); diff --git a/services/audio_service/server/src/renderer_in_server.cpp b/services/audio_service/server/src/renderer_in_server.cpp index ed92d44941..8117594bee 100644 --- a/services/audio_service/server/src/renderer_in_server.cpp +++ b/services/audio_service/server/src/renderer_in_server.cpp @@ -1076,10 +1076,6 @@ bool RendererInServer::IsHighResolution() const noexcept DeviceInfo deviceInfo; bool result = PolicyHandler::GetInstance().GetProcessDeviceInfo(processConfig_, deviceInfo); CHECK_AND_RETURN_RET_LOG(result, false, "GetProcessDeviceInfo failed."); - if (deviceInfo.isArmUsbDevice) { - AUDIO_INFO_LOG("normal stream,device is arm usb"); - return false; - } } if (processConfig_.streamType != STREAM_MUSIC || processConfig_.streamInfo.samplingRate < SAMPLE_RATE_48000 || processConfig_.streamInfo.format < SAMPLE_S24LE || -- Gitee