diff --git a/frameworks/native/audiopolicy/include/audio_policy_manager.h b/frameworks/native/audiopolicy/include/audio_policy_manager.h index 04e63588365b51bfaddf96ef8a2d169a45ea32c3..b54b299ed64b86fca1d748d11716efe86e9f0063 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 7c9e6a32ed3ac7f288e52621be09b0e2c694eae8..ee6a919645b1bcf74c2ce6005ad7c05525969c6d 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 199bf12cc59f947da90850138027b6f7c6c46c29..81df79ec1d4bed925c019a83733d480b84bbb1df 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 5e6a23a39988fa695a9ea280e5d001d503478719..24a4cb2169bbd27e89bf0535f8b60b32ddb51e5c 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 2a7f04bfd386f7b2800cdade5e80a23dded530c7..28e0cfdb854a68d13fb0ed95f56ad0fd1a36605d 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 fdee4a4eedc45425ec7071d54c0f897496896a99..2dd4c8c074c2c9bb12b36b098a6d9df1f789c658 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 9489c83ea299f64a9394e508a895f253514c1404..92532e6420b65966397e4f5f5abace3329642069 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 cea3c1b3cf7be1618235152fb45a35f0d9591658..cfd84038ae0b0e789f1c88d5df9de48a97e51dc3 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();