From e910bfd0d19f9fcb7fca78f9f99a65dfe912e104 Mon Sep 17 00:00:00 2001 From: Shunkai Yao Date: Thu, 18 Apr 2024 04:36:42 +0000 Subject: Use customized event flag for data FMQ not_empty to avoid conflict Bug: 335547630 Test: atest --test-mapping hardware/interfaces/audio/aidl/vts:presubmit Change-Id: I0f5776edd58748195df61e4dae911df30f40e5b0 Merged-In: I0f5776edd58748195df61e4dae911df30f40e5b0 --- media/libaudiohal/impl/EffectHalAidl.cpp | 21 +++++++++++++++++---- media/libeffects/downmix/aidl/EffectDownmix.cpp | 5 ++++- .../dynamicsproc/aidl/DynamicsProcessing.cpp | 10 ++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/media/libaudiohal/impl/EffectHalAidl.cpp b/media/libaudiohal/impl/EffectHalAidl.cpp index c35a60edf0..3fe20464ea 100644 --- a/media/libaudiohal/impl/EffectHalAidl.cpp +++ b/media/libaudiohal/impl/EffectHalAidl.cpp @@ -57,7 +57,9 @@ using ::aidl::android::aidl_utils::statusTFromBinderStatus; using ::aidl::android::hardware::audio::effect::Descriptor; using ::aidl::android::hardware::audio::effect::IEffect; using ::aidl::android::hardware::audio::effect::IFactory; +using ::aidl::android::hardware::audio::effect::kEventFlagDataMqNotEmpty; using ::aidl::android::hardware::audio::effect::kEventFlagDataMqUpdate; +using ::aidl::android::hardware::audio::effect::kEventFlagNotEmpty; using ::aidl::android::hardware::audio::effect::kReopenSupportedVersion; using ::aidl::android::hardware::audio::effect::State; @@ -199,6 +201,7 @@ status_t EffectHalAidl::process() { efState & kEventFlagDataMqUpdate) { ALOGV("%s %s V%d receive dataMQUpdate eventFlag from HAL", __func__, effectName.c_str(), halVersion); + mConversion->reopen(); } auto statusQ = mConversion->getStatusMQ(); @@ -224,12 +227,22 @@ status_t EffectHalAidl::process() { floatsToWrite, mInBuffer->audioBuffer(), inputQ->availableToWrite()); return INVALID_OPERATION; } - efGroup->wake(aidl::android::hardware::audio::effect::kEventFlagNotEmpty); + + // for V2 audio effect HAL, expect different EventFlag to avoid bit conflict with FMQ_NOT_EMPTY + efGroup->wake(halVersion >= kReopenSupportedVersion ? kEventFlagDataMqNotEmpty + : kEventFlagNotEmpty); IEffect::Status retStatus{}; - if (!statusQ->readBlocking(&retStatus, 1) || retStatus.status != OK || - (size_t)retStatus.fmqConsumed != floatsToWrite || retStatus.fmqProduced == 0) { - ALOGE("%s read status failed: %s", __func__, retStatus.toString().c_str()); + if (!statusQ->readBlocking(&retStatus, 1)) { + ALOGE("%s %s V%d read status from status FMQ failed", __func__, effectName.c_str(), + halVersion); + return INVALID_OPERATION; + } + if (retStatus.status != OK || (size_t)retStatus.fmqConsumed != floatsToWrite || + retStatus.fmqProduced == 0) { + ALOGE("%s read status failed: %s, consumed %d (of %zu) produced %d", __func__, + retStatus.toString().c_str(), retStatus.fmqConsumed, floatsToWrite, + retStatus.fmqProduced); return INVALID_OPERATION; } diff --git a/media/libeffects/downmix/aidl/EffectDownmix.cpp b/media/libeffects/downmix/aidl/EffectDownmix.cpp index de60ca4921..883d41d629 100644 --- a/media/libeffects/downmix/aidl/EffectDownmix.cpp +++ b/media/libeffects/downmix/aidl/EffectDownmix.cpp @@ -177,7 +177,10 @@ void DownmixImpl::process() { * in the life cycle of workerThread (threadLoop). */ uint32_t efState = 0; - if (!mEventFlag || ::android::OK != mEventFlag->wait(kEventFlagNotEmpty, &efState)) { + if (!mEventFlag || + ::android::OK != mEventFlag->wait(mDataMqNotEmptyEf, &efState, 0 /* no timeout */, + true /* retry */) || + !(efState & mDataMqNotEmptyEf)) { LOG(ERROR) << getEffectName() << __func__ << ": StatusEventFlag invalid"; } diff --git a/media/libeffects/dynamicsproc/aidl/DynamicsProcessing.cpp b/media/libeffects/dynamicsproc/aidl/DynamicsProcessing.cpp index fdc16e38d7..836e034c8a 100644 --- a/media/libeffects/dynamicsproc/aidl/DynamicsProcessing.cpp +++ b/media/libeffects/dynamicsproc/aidl/DynamicsProcessing.cpp @@ -213,11 +213,12 @@ ndk::ScopedAStatus DynamicsProcessingImpl::open(const Parameter::Common& common, RETURN_OK_IF(mState != State::INIT); mImplContext = createContext(common); RETURN_IF(!mContext || !mImplContext, EX_NULL_POINTER, "createContextFailed"); - int version = 0; - RETURN_IF(!getInterfaceVersion(&version).isOk(), EX_UNSUPPORTED_OPERATION, + RETURN_IF(!getInterfaceVersion(&mVersion).isOk(), EX_UNSUPPORTED_OPERATION, "FailedToGetInterfaceVersion"); mImplContext->setVersion(version); mEventFlag = mImplContext->getStatusEventFlag(); + mDataMqNotEmptyEf = + mVersion >= kReopenSupportedVersion ? kEventFlagDataMqNotEmpty : kEventFlagNotEmpty; if (specific.has_value()) { RETURN_IF_ASTATUS_NOT_OK(setParameterSpecific(specific.value()), "setSpecParamErr"); @@ -231,8 +232,9 @@ ndk::ScopedAStatus DynamicsProcessingImpl::open(const Parameter::Common& common, mState = State::IDLE; mContext->dupeFmq(ret); - RETURN_IF(createThread(getEffectName()) != RetCode::SUCCESS, EX_UNSUPPORTED_OPERATION, - "FailedToCreateWorker"); + RETURN_IF(createThread(getEffectNameWithVersion()) != RetCode::SUCCESS, + EX_UNSUPPORTED_OPERATION, "FailedToCreateWorker"); + LOG(INFO) << getEffectNameWithVersion() << __func__; return ndk::ScopedAStatus::ok(); } -- cgit v1.2.3