From 5ad3757ba02099ec654e93a537362f368ca8ef02 Mon Sep 17 00:00:00 2001 From: yue Date: Sat, 13 Sep 2025 09:45:27 +0800 Subject: [PATCH] BT_SPP913 Signed-off-by: yue --- .../include/audio_policy_manager.h | 2 ++ .../source/va_capture_source.cpp | 2 +- services/audio_policy/BUILD.gn | 3 +++ .../src/audio_policy_manager_device.cpp | 9 +++++++ ...Impl.h => va_device_broker_wrapper_impl.h} | 0 ....cpp => va_device_broker_wrapper_impl.cpp} | 26 +++++++++---------- .../src/va_device_controller_stub_impl.cpp | 17 +++++++----- .../stub/src/va_input_stream_stub_impl.cpp | 14 +++++----- .../src/va_device_manager_unit_test.cpp | 2 +- 9 files changed, 46 insertions(+), 29 deletions(-) rename services/audio_policy/client/stub/include/{va_device_broker_wrapper_Impl.h => va_device_broker_wrapper_impl.h} (100%) rename services/audio_policy/client/stub/src/{va_device_broker_wrapper_Impl.cpp => va_device_broker_wrapper_impl.cpp} (69%) diff --git a/frameworks/native/audiopolicy/include/audio_policy_manager.h b/frameworks/native/audiopolicy/include/audio_policy_manager.h index 04e6358836..b54b299ed6 100644 --- a/frameworks/native/audiopolicy/include/audio_policy_manager.h +++ b/frameworks/native/audiopolicy/include/audio_policy_manager.h @@ -37,6 +37,7 @@ #include "audio_combine_denoising_manager.h" #include "audio_stream_descriptor.h" #include "sle_audio_operation_callback_stub_impl.h" +#include "va_device_broker_wrapper_impl.h" #include "audio_capturer_options.h" namespace OHOS { @@ -702,6 +703,7 @@ public: int32_t UpdateDeviceInfo(const std::shared_ptr &deviceDesc, const DeviceInfoUpdateCommand command); int32_t SetSleAudioOperationCallback(const std::shared_ptr &callback); + int32_t GetVADeviceBroker(std::shared_ptr &vaBroker); bool IsCollaborativePlaybackSupported(); int32_t SetCollaborativePlaybackEnabledForDevice( const std::shared_ptr &selectedAudioDevice, bool enabled); diff --git a/frameworks/native/hdiadapter_new/source/va_capture_source.cpp b/frameworks/native/hdiadapter_new/source/va_capture_source.cpp index 7c9e6a32ed..ee6a919645 100644 --- a/frameworks/native/hdiadapter_new/source/va_capture_source.cpp +++ b/frameworks/native/hdiadapter_new/source/va_capture_source.cpp @@ -100,7 +100,7 @@ int32_t VACaptureSource::CreateCapture() std::shared_ptr attribute = MakeVAStreamAttributeFromIAudioSourceAttr(); sptr inputStreamRemote; int ret = deviceController_->OpenInputStream(*prop, *attribute, inputStreamRemote); - CHECK_AND_RETURN_RET_LOG(ret == SUCCESS, ERR_OPERATION_FAILED, "openInputStream failed ret = %{pubilc}d", ret); + CHECK_AND_RETURN_RET_LOG(ret == SUCCESS, ERR_OPERATION_FAILED, "openInputStream failed ret = %{public}d", ret); CHECK_AND_RETURN_RET_LOG(inputStreamRemote != nullptr, ERR_OPERATION_FAILED, "inputStreamRemote is nullptr"); inputStream_ = iface_cast(inputStreamRemote); diff --git a/services/audio_policy/BUILD.gn b/services/audio_policy/BUILD.gn index 199bf12cc5..81df79ec1d 100644 --- a/services/audio_policy/BUILD.gn +++ b/services/audio_policy/BUILD.gn @@ -577,6 +577,9 @@ audio_ohos_library("audio_policy_client") { "client/stub/src/audio_policy_manager_listener_stub_impl.cpp", "client/stub/src/audio_zone_client.cpp", "client/stub/src/sle_audio_operation_callback_stub_impl.cpp", + "client/stub/src/va_device_broker_wrapper_impl.cpp", + "client/stub/src/va_device_controller_stub_impl.cpp", + "client/stub/src/va_input_stream_stub_impl.cpp", "server/src/audio_client_tracker_callback_service.cpp", "server/src/audio_spatialization_state_change_listener.cpp", ] diff --git a/services/audio_policy/client/service/src/audio_policy_manager_device.cpp b/services/audio_policy/client/service/src/audio_policy_manager_device.cpp index 5e6a23a399..24a4cb2169 100644 --- a/services/audio_policy/client/service/src/audio_policy_manager_device.cpp +++ b/services/audio_policy/client/service/src/audio_policy_manager_device.cpp @@ -680,5 +680,14 @@ int32_t AudioPolicyManager::SetSleAudioOperationCallback(const std::shared_ptrSetSleAudioOperationCallback(object); } + +int32_t AudioPolicyManager::GetVADeviceBroker(std::shared_ptr &vaBroker) +{ + auto vaBrokerWrapper = std::make_shared(); + CHECK_AND_RETURN_RET_LOG(vaBrokerWrapper != nullptr, ERROR, "vaBrokerWrapper is null"); + vaBroker = vaBrokerWrapper; + + return SUCCESS; +} } // namespace AudioStandard } // namespace OHOS diff --git a/services/audio_policy/client/stub/include/va_device_broker_wrapper_Impl.h b/services/audio_policy/client/stub/include/va_device_broker_wrapper_impl.h similarity index 100% rename from services/audio_policy/client/stub/include/va_device_broker_wrapper_Impl.h rename to services/audio_policy/client/stub/include/va_device_broker_wrapper_impl.h diff --git a/services/audio_policy/client/stub/src/va_device_broker_wrapper_Impl.cpp b/services/audio_policy/client/stub/src/va_device_broker_wrapper_impl.cpp similarity index 69% rename from services/audio_policy/client/stub/src/va_device_broker_wrapper_Impl.cpp rename to services/audio_policy/client/stub/src/va_device_broker_wrapper_impl.cpp index 2a7f04bfd3..28e0cfdb85 100644 --- a/services/audio_policy/client/stub/src/va_device_broker_wrapper_Impl.cpp +++ b/services/audio_policy/client/stub/src/va_device_broker_wrapper_impl.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "VADeviceBrokerWrapperImpl" #endif -#include "va_device_broker_wrapper_Impl.h" +#include "va_device_broker_wrapper_impl.h" #include "va_device_controller_stub_impl.h" #include "iv_a_device_broker.h" @@ -36,17 +36,17 @@ VADeviceBrokerWrapperImpl::~VADeviceBrokerWrapperImpl() int32_t VADeviceBrokerWrapperImpl::OnDevicesConnected( const VADevice& device, const std::shared_ptr& controllerCallback) { - CHECK_AND_RETURN_RET_LOG(controllerCallback != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(controllerCallback != nullptr, ERR_INVALID_PARAM, "controllerCallback is nullptr"); const sptr gsp = GetAudioPolicyProxyFromSamgr(); - CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "get audio policy proxy failed"); sptr brokerObject; gsp->GetVADeviceBroker(brokerObject); - CHECK_AND_RETURN_RET_LOG(brokerObject != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(brokerObject != nullptr, ERR_OPERATION_FAILED, "get broker object failed"); sptr ivaBroker = iface_cast(brokerObject); - CHECK_AND_RETURN_RET_LOG(ivaBroker != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(ivaBroker != nullptr, ERR_OPERATION_FAILED, "get iva broker failed"); auto controllerStubImpl = new (std::nothrow) VADeviceControllerStubImpl(); - CHECK_AND_RETURN_RET_LOG(controllerStubImpl != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(controllerStubImpl != nullptr, ERR_OPERATION_FAILED, "new controller stub failed"); controllerStubImpl->SetVADeviceControllerCallback (controllerCallback); sptr controllerStubImplObject = controllerStubImpl->AsObject(); @@ -60,30 +60,30 @@ int32_t VADeviceBrokerWrapperImpl::OnDevicesConnected( int32_t VADeviceBrokerWrapperImpl::OnDevicesDisconnected(const VADevice& device) { const sptr gsp = GetAudioPolicyProxyFromSamgr(); - CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "get audio policy proxy failed"); sptrbrokerObject; gsp->GetVADeviceBroker(brokerObject); - CHECK_AND_RETURN_RET_LOG(brokerObject != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(brokerObject != nullptr, ERR_OPERATION_FAILED, "get broker object failed"); sptr ivaBroker = iface_cast(brokerObject); - CHECK_AND_RETURN_RET_LOG(ivaBroker != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(ivaBroker != nullptr, ERR_OPERATION_FAILED, "get iva broker failed"); - ivaBroker->OnDeviceDisconnected(device); + ivaBroker->OnDevicesDisconnected(device); return SUCCESS; } const sptr VADeviceBrokerWrapperImpl::GetAudioPolicyProxyFromSamgr(bool block) { auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - CHECK_AND_RETURN_RET_LOG(samgr != nullptr, nullptr); + CHECK_AND_RETURN_RET_LOG(samgr != nullptr, nullptr, "get system ability failed"); sptr object = nullptr; if (!block) { object = samgr->CheckSystemAbility(AUDIO_POLICY_SERVICE_ID); } else { object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID); } - CHECK_AND_RETURN_RET_LOG(object != nullptr, nullptr); + CHECK_AND_RETURN_RET_LOG(object != nullptr, nullptr, "get audio policy service failed"); sptr apProxy= iface_cast(object); - CHECK_AND_RETURN_RET_LOG(apProxy != nullptr, nullptr); + CHECK_AND_RETURN_RET_LOG(apProxy != nullptr, nullptr, "get audio policy proxy failed"); return apProxy; } } //namespace AudioStandard diff --git a/services/audio_policy/client/stub/src/va_device_controller_stub_impl.cpp b/services/audio_policy/client/stub/src/va_device_controller_stub_impl.cpp index fdee4a4eed..2dd4c8c074 100644 --- a/services/audio_policy/client/stub/src/va_device_controller_stub_impl.cpp +++ b/services/audio_policy/client/stub/src/va_device_controller_stub_impl.cpp @@ -35,7 +35,7 @@ VADeviceControllerStubImpl::~VADeviceControllerStubImpl() int32_t VADeviceControllerStubImpl::SetVADeviceControllerCallback( const std::shared_ptr &callback) { - CHECK_AND_RETURN_RET_LOG(callback != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(callback != nullptr, ERR_INVALID_PARAM, "callback is null"); std::lock_guard lock(vaDeviceControllerMutex_); vaDeviceControllerCallback_ = callback; @@ -47,14 +47,15 @@ int32_t VADeviceControllerStubImpl::OpenInputStream(const VAAudioStreamProperty sptr &inputStream) { std::unique_lock lock(vaDeviceControllerMutex_); - CHECK_AND_RETURN_RET_LOG(vaDeviceControllerCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG( + vaDeviceControllerCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaDeviceControllerCallback_ is null"); lock.unlock(); - + std::shared_ptr inputStreamCallback; vaDeviceControllerCallback_->OpenInputStream(prop, attr, inputStreamCallback); - CHECK_AND_RETURN_RET_LOG(inputStreamCallback != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(inputStreamCallback != nullptr, ERR_OPERATION_FAILED, "inputStreamCallback is null"); auto vaInputStreamStubImpl = sptr::MakeSptr(); - CHECK_AND_RETURN_RET_LOG(vaInputStreamStubImpl != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(vaInputStreamStubImpl != nullptr, ERR_OPERATION_FAILED, "vaInputStreamStubImpl is null"); vaInputStreamStubImpl->SetVAInputStreamCallback(inputStreamCallback); inputStream = vaInputStreamStubImpl->AsObject(); if (inputStream == nullptr) { @@ -67,7 +68,8 @@ int32_t VADeviceControllerStubImpl::OpenInputStream(const VAAudioStreamProperty int32_t VADeviceControllerStubImpl::GetParameters(const std::string& key, std::string& value) { std::unique_lock lock(vaDeviceControllerMutex_); - CHECK_AND_RETURN_RET_LOG(vaDeviceControllerCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG( + vaDeviceControllerCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaDeviceControllerCallback_ is null"); lock.unlock(); vaDeviceControllerCallback_->GetParameters(key, value); @@ -78,7 +80,8 @@ int32_t VADeviceControllerStubImpl::GetParameters(const std::string& key, std::s int32_t VADeviceControllerStubImpl::SetParameters(const std::string& key, const std::string& value) { std::unique_lock lock(vaDeviceControllerMutex_); - CHECK_AND_RETURN_RET_LOG(vaDeviceControllerCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG( + vaDeviceControllerCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaDeviceControllerCallback_ is null"); lock.unlock(); vaDeviceControllerCallback_->SetParameters(key, value); diff --git a/services/audio_policy/client/stub/src/va_input_stream_stub_impl.cpp b/services/audio_policy/client/stub/src/va_input_stream_stub_impl.cpp index 9489c83ea2..92532e6420 100644 --- a/services/audio_policy/client/stub/src/va_input_stream_stub_impl.cpp +++ b/services/audio_policy/client/stub/src/va_input_stream_stub_impl.cpp @@ -33,42 +33,42 @@ VAInputStreamStubImpl::~VAInputStreamStubImpl() int32_t VAInputStreamStubImpl::SetVAInputStreamCallback( const std::shared_ptr &callback) { - CHECK_AND_RETURN_RET_LOG(callback != nullptr, ERR_INVALID_PARAM); + CHECK_AND_RETURN_RET_LOG(callback != nullptr, ERR_INVALID_PARAM, "callback is null"); vaInputStreamCallback_ = callback; return SUCCESS; } int32_t VAInputStreamStubImpl::GetStreamProperty(VAAudioStreamProperty& streamProp) { - CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaInputStreamCallback_ is nullptr"); vaInputStreamCallback_->GetStreamProperty(streamProp); return SUCCESS; } int32_t VAInputStreamStubImpl::RequestSharedMem(const VASharedMemInfo& memInfo) { - CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaInputStreamCallback_ is nullptr"); vaInputStreamCallback_->RequestSharedMem(memInfo); return SUCCESS; } int32_t VAInputStreamStubImpl::Start() { - CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaInputStreamCallback_ is nullptr"); vaInputStreamCallback_->Start(); return SUCCESS; } int32_t VAInputStreamStubImpl::Stop() { - CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaInputStreamCallback_ is nullptr"); vaInputStreamCallback_->Stop(); return SUCCESS; } int32_t VAInputStreamStubImpl::Close() { - CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaInputStreamCallback_ is nullptr"); vaInputStreamCallback_->Close(); return SUCCESS; } @@ -76,7 +76,7 @@ int32_t VAInputStreamStubImpl::Close() int32_t VAInputStreamStubImpl::GetCapturePosition(uint64_t &attr_1, uint64_t &attr_2) { - CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERROR); + CHECK_AND_RETURN_RET_LOG(vaInputStreamCallback_ != nullptr, ERR_ILLEGAL_STATE, "vaInputStreamCallback_ is nullptr"); vaInputStreamCallback_->GetCapturePosition(attr_1, attr_2); return SUCCESS; } diff --git a/services/audio_policy/test/unittest/va_device_manager_unit_test/src/va_device_manager_unit_test.cpp b/services/audio_policy/test/unittest/va_device_manager_unit_test/src/va_device_manager_unit_test.cpp index cea3c1b3cf..cfd84038ae 100644 --- a/services/audio_policy/test/unittest/va_device_manager_unit_test/src/va_device_manager_unit_test.cpp +++ b/services/audio_policy/test/unittest/va_device_manager_unit_test/src/va_device_manager_unit_test.cpp @@ -184,7 +184,7 @@ HWTEST_F(VADeviceManagerUnitTest, VADeviceManagerUnitTest_008, TestSize.Level1) streamProp.channelLayout_ = CH_LAYOUT_2POINT1; streamProp.sampleRate_ = 44100; streamProp.samplesPerCycle_ = 1024; - vaDevice->->configuration_.properties_.push_back(streamProp); + vaDevice->configuration_.properties_.push_back(streamProp); auto desc = vaDeviceManager.ConvertVADeviceToDescriptor(vaDevice); auto streamInfo = desc->audioStreamInfo_.front(); -- Gitee