diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-04-30 23:28:05 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-04-30 23:28:05 +0000 |
commit | f9fc279d9e18a066b982f008c28e79130189969f (patch) | |
tree | 25cec85511868e6de3a0feb9d85c434d527106c1 | |
parent | c361ac055ccb8d7253c65a71dcf4ae4cceb956da (diff) | |
parent | 46cedb56abf3ee2126ffe94bca5e29d4cd3d0292 (diff) | |
download | av-sdk-release.tar.gz |
Merge "Snap for 11785460 from 6f32f6146d97de73cc5264259169b5b29d1e3fa7 to sdk-release" into sdk-releasesdk-release
22 files changed, 282 insertions, 109 deletions
diff --git a/media/aconfig/codec_fwk.aconfig b/media/aconfig/codec_fwk.aconfig index b3c02ebcd9..6d934eedbf 100644 --- a/media/aconfig/codec_fwk.aconfig +++ b/media/aconfig/codec_fwk.aconfig @@ -101,7 +101,7 @@ flag { name: "set_state_early" namespace: "codec_fwk" description: "Bugfix flag for setting state early to avoid a race condition" - bug: "298613711" + bug: "298613712" metadata { purpose: PURPOSE_BUGFIX } diff --git a/media/codec2/hal/aidl/Android.bp b/media/codec2/hal/aidl/Android.bp index 48b6e21535..e16e2b1726 100644 --- a/media/codec2/hal/aidl/Android.bp +++ b/media/codec2/hal/aidl/Android.bp @@ -8,6 +8,7 @@ cc_library { name: "libcodec2_aidl_client", defaults: [ + "aconfig_lib_cc_static_link.defaults", "libcodec2_hal_selection", ], @@ -65,6 +66,7 @@ cc_library { ], defaults: [ + "aconfig_lib_cc_static_link.defaults", "libcodec2_hal_selection", ], diff --git a/media/codec2/hal/common/Android.bp b/media/codec2/hal/common/Android.bp index 7d7b28545a..4c9da33c3c 100644 --- a/media/codec2/hal/common/Android.bp +++ b/media/codec2/hal/common/Android.bp @@ -31,6 +31,10 @@ cc_library { ], static_libs: ["aconfig_mediacodec_flags_c_lib"], + + defaults: [ + "aconfig_lib_cc_static_link.defaults", + ], } cc_library_static { diff --git a/media/codec2/hal/common/MultiAccessUnitHelper.cpp b/media/codec2/hal/common/MultiAccessUnitHelper.cpp index 8086ef20eb..b1fa82fe5f 100644 --- a/media/codec2/hal/common/MultiAccessUnitHelper.cpp +++ b/media/codec2/hal/common/MultiAccessUnitHelper.cpp @@ -27,6 +27,7 @@ #include <C2Debug.h> #include <C2PlatformSupport.h> +static inline constexpr uint32_t MAX_SUPPORTED_SIZE = ( 10 * 512000 * 8 * 2u); namespace android { static C2R MultiAccessUnitParamsSetter( @@ -39,8 +40,6 @@ static C2R MultiAccessUnitParamsSetter( res = res.plus(C2SettingResultBuilder::BadValue(me.F(me.v.thresholdSize))); } else if (me.v.maxSize < me.v.thresholdSize) { me.set().maxSize = me.v.thresholdSize; - } else if (me.v.thresholdSize == 0 && me.v.maxSize > 0) { - me.set().thresholdSize = me.v.maxSize; } std::vector<std::unique_ptr<C2SettingResult>> failures; res.retrieveFailures(&failures); @@ -61,9 +60,9 @@ MultiAccessUnitInterface::MultiAccessUnitInterface( .withDefault(new C2LargeFrame::output(0u, 0, 0)) .withFields({ C2F(mLargeFrameParams, maxSize).inRange( - 0, c2_min(UINT_MAX, 10 * 512000 * 8 * 2u)), + 0, c2_min(UINT_MAX, MAX_SUPPORTED_SIZE)), C2F(mLargeFrameParams, thresholdSize).inRange( - 0, c2_min(UINT_MAX, 10 * 512000 * 8 * 2u)) + 0, c2_min(UINT_MAX, MAX_SUPPORTED_SIZE)) }) .withSetter(MultiAccessUnitParamsSetter) .build()); @@ -115,6 +114,18 @@ bool MultiAccessUnitInterface::getDecoderSampleRateAndChannelCount( return false; } +bool MultiAccessUnitInterface::getMaxInputSize( + C2StreamMaxBufferSizeInfo::input* const maxInputSize) const { + if (maxInputSize == nullptr || mC2ComponentIntf == nullptr) { + return false; + } + c2_status_t err = mC2ComponentIntf->query_vb({maxInputSize}, {}, C2_MAY_BLOCK, nullptr); + if (err != OK) { + return false; + } + return true; +} + //C2MultiAccessUnitBuffer class C2MultiAccessUnitBuffer : public C2Buffer { public: @@ -128,6 +139,7 @@ class C2MultiAccessUnitBuffer : public C2Buffer { MultiAccessUnitHelper::MultiAccessUnitHelper( const std::shared_ptr<MultiAccessUnitInterface>& intf, std::shared_ptr<C2BlockPool>& linearPool): + mMultiAccessOnOffAllowed(true), mInit(false), mInterface(intf), mLinearPool(linearPool) { @@ -152,6 +164,63 @@ bool MultiAccessUnitHelper::isEnabledOnPlatform() { return result; } +bool MultiAccessUnitHelper::tryReconfigure(const std::unique_ptr<C2Param> ¶m) { + C2LargeFrame::output *lfp = C2LargeFrame::output::From(param.get()); + if (lfp == nullptr) { + return false; + } + bool isDecoder = (mInterface->kind() == C2Component::KIND_DECODER) ? true : false; + if (!isDecoder) { + C2StreamMaxBufferSizeInfo::input maxInputSize(0); + if (!mInterface->getMaxInputSize(&maxInputSize)) { + LOG(ERROR) << "Error in reconfigure: " + << "Encoder failed to respond with a valid max input size"; + return false; + } + // This is assuming a worst case compression ratio of 1:1 + // In no case the encoder should give an output more than + // what is being provided to the encoder in a single call. + if (lfp->maxSize < maxInputSize.value) { + lfp->maxSize = maxInputSize.value; + } + } + lfp->maxSize = + (lfp->maxSize > MAX_SUPPORTED_SIZE) ? MAX_SUPPORTED_SIZE : + (lfp->maxSize < 0) ? 0 : lfp->maxSize; + lfp->thresholdSize = + (lfp->thresholdSize > MAX_SUPPORTED_SIZE) ? MAX_SUPPORTED_SIZE : + (lfp->thresholdSize < 0) ? 0 : lfp->thresholdSize; + C2LargeFrame::output currentConfig = mInterface->getLargeFrameParam(); + if ((currentConfig.maxSize == lfp->maxSize) + && (currentConfig.thresholdSize == lfp->thresholdSize)) { + // no need to update + return false; + } + if (isDecoder) { + bool isOnOffTransition = + (currentConfig.maxSize == 0 && lfp->maxSize != 0) + || (currentConfig.maxSize != 0 && lfp->maxSize == 0); + if (isOnOffTransition && !mMultiAccessOnOffAllowed) { + LOG(ERROR) << "Setting new configs not allowed" + << " MaxSize: " << lfp->maxSize + << " ThresholdSize: " << lfp->thresholdSize; + return false; + } + } + std::vector<C2Param*> config{lfp}; + std::vector<std::unique_ptr<C2SettingResult>> failures; + if (C2_OK != mInterface->config(config, C2_MAY_BLOCK, &failures)) { + LOG(ERROR) << "Dynamic config not applied for" + << " MaxSize: " << lfp->maxSize + << " ThresholdSize: " << lfp->thresholdSize; + return false; + } + LOG(DEBUG) << "Updated from param maxSize " + << lfp->maxSize + << " ThresholdSize " << lfp->thresholdSize; + return true; +} + std::shared_ptr<MultiAccessUnitInterface> MultiAccessUnitHelper::getInterface() { return mInterface; } @@ -163,6 +232,7 @@ bool MultiAccessUnitHelper::getStatus() { void MultiAccessUnitHelper::reset() { std::lock_guard<std::mutex> l(mLock); mFrameHolder.clear(); + mMultiAccessOnOffAllowed = true; } c2_status_t MultiAccessUnitHelper::error( @@ -181,6 +251,7 @@ c2_status_t MultiAccessUnitHelper::error( } } mFrameHolder.clear(); + mMultiAccessOnOffAllowed = true; return C2_OK; } @@ -232,16 +303,23 @@ c2_status_t MultiAccessUnitHelper::scatter( uint64_t newFrameIdx = mFrameIndex++; // TODO: Do not split buffers if component inherantly supports MultipleFrames. // if thats case, only replace frameindex. - auto cloneInputWork = [&newFrameIdx](std::unique_ptr<C2Work>& inWork, uint32_t flags) { + auto cloneInputWork = [&frameInfo, &newFrameIdx, this] + (std::unique_ptr<C2Work>& inWork, uint32_t flags) -> std::unique_ptr<C2Work> { std::unique_ptr<C2Work> newWork(new C2Work); newWork->input.flags = (C2FrameData::flags_t)flags; newWork->input.ordinal = inWork->input.ordinal; newWork->input.ordinal.frameIndex = newFrameIdx; if (!inWork->input.configUpdate.empty()) { for (std::unique_ptr<C2Param>& param : inWork->input.configUpdate) { - newWork->input.configUpdate.push_back( - std::move(C2Param::Copy(*(param.get())))); + if (param->index() == C2LargeFrame::output::PARAM_TYPE) { + if (tryReconfigure(param)) { + frameInfo.mConfigUpdate.push_back(std::move(param)); + } + } else { + newWork->input.configUpdate.push_back(std::move(param)); + } } + inWork->input.configUpdate.clear(); } newWork->input.infoBuffers = (inWork->input.infoBuffers); if (!inWork->worklets.empty() && inWork->worklets.front() != nullptr) { @@ -331,6 +409,7 @@ c2_status_t MultiAccessUnitHelper::scatter( frameInfo.mLargeFrameTuning = multiAccessParams; std::lock_guard<std::mutex> l(mLock); mFrameHolder.push_back(std::move(frameInfo)); + mMultiAccessOnOffAllowed = false; } } return C2_OK; @@ -360,6 +439,7 @@ c2_status_t MultiAccessUnitHelper::gather( std::list<MultiAccessUnitInfo>::iterator frame = mFrameHolder.begin(); while (!foundFrame && frame != mFrameHolder.end()) { + c2_status_t res = C2_OK; auto it = frame->mComponentFrameIds.find(thisFrameIndex); if (it != frame->mComponentFrameIds.end()) { foundFrame = true; @@ -369,8 +449,7 @@ c2_status_t MultiAccessUnitHelper::gather( if (work->result != C2_OK || work->worklets.empty() || !work->worklets.front() - || (frame->mLargeFrameTuning.thresholdSize == 0 - || frame->mLargeFrameTuning.maxSize == 0)) { + || frame->mLargeFrameTuning.maxSize == 0) { if (removeEntry) { frame->mComponentFrameIds.erase(it); removeEntry = false; @@ -388,10 +467,27 @@ c2_status_t MultiAccessUnitHelper::gather( addOutWork(frame->mLargeWork); frame->reset(); if (workResult != C2_OK) { - frame->mAccessUnitInfos.clear(); + frame->mComponentFrameIds.clear(); + removeEntry = false; } - } else if (C2_OK != processWorklets(*frame, work, addOutWork)) { - LOG(DEBUG) << "Error while processing work"; + } else if (C2_OK != (res = processWorklets(*frame, work, addOutWork))) { + // Upon error in processing worklets, we return the work with + // result set to the error. This should indicate the error to the + // framework and thus doing what is necessary to handle the + // error. + LOG(DEBUG) << "Error while processing worklets"; + if (frame->mLargeWork == nullptr) { + frame->mLargeWork.reset(new C2Work); + frame->mLargeWork->input.ordinal = frame->inOrdinal; + frame->mLargeWork->input.ordinal.frameIndex = + frame->inOrdinal.frameIndex; + } + frame->mLargeWork->result = res; + finalizeWork(*frame); + addOutWork(frame->mLargeWork); + frame->reset(); + frame->mComponentFrameIds.clear(); + removeEntry = false; } if (removeEntry) { LOG(DEBUG) << "Removing entry: " << thisFrameIndex @@ -528,9 +624,6 @@ c2_status_t MultiAccessUnitHelper::processWorklets(MultiAccessUnitInfo &frame, LOG(DEBUG) << "maxOutSize " << frame.mLargeFrameTuning.maxSize << " threshold " << frame.mLargeFrameTuning.thresholdSize; - if ((*worklet)->output.buffers.size() > 0) { - allocateWork(frame, true, true); - } LOG(DEBUG) << "This worklet has " << (*worklet)->output.buffers.size() << " buffers" << " ts: " << (*worklet)->output.ordinal.timestamp.peekull(); int64_t workletTimestamp = (*worklet)->output.ordinal.timestamp.peekull(); @@ -552,43 +645,39 @@ c2_status_t MultiAccessUnitHelper::processWorklets(MultiAccessUnitInfo &frame, inputSize -= (inputSize % frameSize); } while (inputOffset < inputSize) { - if (frame.mWview->offset() >= frame.mLargeFrameTuning.thresholdSize) { + if ((frame.mWview != nullptr) + && (frame.mWview->offset() >= frame.mLargeFrameTuning.thresholdSize)) { frame.mLargeWork->result = C2_OK; finalizeWork(frame, flagsForCopy); addWork(frame.mLargeWork); frame.reset(); - allocateWork(frame, true, true); } if (mInterface->kind() == C2Component::KIND_ENCODER) { if (inputSize > frame.mLargeFrameTuning.maxSize) { - LOG(ERROR) << "Enc: Output buffer too small for AU, configured with " - << frame.mLargeFrameTuning.maxSize - << " block size: " << blocks.front().size() - << "alloc size " << frame.mWview->size(); - if (frame.mLargeWork - && frame.mWview && frame.mWview->offset() > 0) { + LOG(WARNING) << "WARNING Encoder:" + << " Output buffer too small for configuration" + << " configured max size " << frame.mLargeFrameTuning.maxSize + << " access unit size " << inputSize; + if (frame.mLargeWork && (frame.mWview && frame.mWview->offset() > 0)) { + frame.mLargeWork->result = C2_OK; finalizeWork(frame, flagsForCopy); addWork(frame.mLargeWork); frame.reset(); - allocateWork(frame, true, false); } - frame.mLargeWork->result = C2_NO_MEMORY; - finalizeWork(frame, 0, true); - addWork(frame.mLargeWork); - frame.reset(); - return C2_NO_MEMORY; - } else if (inputSize > frame.mWview->size()) { + frame.mLargeFrameTuning.maxSize = inputSize; + } else if ((frame.mWview != nullptr) + && (inputSize > frame.mWview->size())) { LOG(DEBUG) << "Enc: Large frame hitting bufer limit, current size " << frame.mWview->offset(); - if (frame.mLargeWork - && frame.mWview && frame.mWview->offset() > 0) { + if (frame.mWview->offset() > 0) { + frame.mLargeWork->result = C2_OK; finalizeWork(frame, flagsForCopy); addWork(frame.mLargeWork); frame.reset(); - allocateWork(frame, true, true); } } } + allocateWork(frame, true, true); C2ReadView rView = blocks.front().map().get(); if (rView.error()) { LOG(ERROR) << "Buffer read view error"; @@ -683,26 +772,39 @@ c2_status_t MultiAccessUnitHelper::finalizeWork( frame.mWview->setOffset(0); std::shared_ptr<C2Buffer> c2Buffer = C2Buffer::CreateLinearBuffer( frame.mBlock->share(0, size, ::C2Fence())); - if (frame.mAccessUnitInfos.size() > 0) { - if (finalFlags & C2FrameData::FLAG_END_OF_STREAM) { - frame.mAccessUnitInfos.back().flags |= - C2FrameData::FLAG_END_OF_STREAM; + frame.mLargeWork->worklets.front()->output.buffers.push_back(std::move(c2Buffer)); + } + if (frame.mLargeWork->worklets.front()->output.buffers.size() > 0) { + std::shared_ptr<C2Buffer>& c2Buffer = + frame.mLargeWork->worklets.front()->output.buffers.front(); + if (c2Buffer != nullptr) { + if (frame.mAccessUnitInfos.size() > 0) { + if (finalFlags & C2FrameData::FLAG_END_OF_STREAM) { + frame.mAccessUnitInfos.back().flags |= C2FrameData::FLAG_END_OF_STREAM; + } + std::shared_ptr<C2AccessUnitInfos::output> largeFrame = + C2AccessUnitInfos::output::AllocShared( + frame.mAccessUnitInfos.size(), 0u, frame.mAccessUnitInfos); + frame.mInfos.push_back(largeFrame); + frame.mAccessUnitInfos.clear(); + } + for (auto &info : frame.mInfos) { + c2Buffer->setInfo(std::const_pointer_cast<C2Info>(info)); } - std::shared_ptr<C2AccessUnitInfos::output> largeFrame = - C2AccessUnitInfos::output::AllocShared( - frame.mAccessUnitInfos.size(), 0u, frame.mAccessUnitInfos); - frame.mInfos.push_back(largeFrame); - frame.mAccessUnitInfos.clear(); - } - for (auto &info : frame.mInfos) { - c2Buffer->setInfo(std::const_pointer_cast<C2Info>(info)); } - frame.mLargeWork->worklets.front()->output.buffers.push_back(std::move(c2Buffer)); - frame.mInfos.clear(); - frame.mBlock.reset(); - frame.mWview.reset(); + } + if (frame.mConfigUpdate.size() > 0) { + outFrameData.configUpdate.insert( + outFrameData.configUpdate.end(), + make_move_iterator(frame.mConfigUpdate.begin()), + make_move_iterator(frame.mConfigUpdate.end())); } } + frame.mConfigUpdate.clear(); + frame.mInfos.clear(); + frame.mBlock.reset(); + frame.mWview.reset(); + LOG(DEBUG) << "Multi access-unitflag setting as " << finalFlags; return C2_OK; } @@ -735,6 +837,7 @@ void MultiAccessUnitHelper::MultiAccessUnitInfo::reset() { mBlock.reset(); mWview.reset(); mInfos.clear(); + mConfigUpdate.clear(); mAccessUnitInfos.clear(); mLargeWork.reset(); } diff --git a/media/codec2/hal/common/include/codec2/common/MultiAccessUnitHelper.h b/media/codec2/hal/common/include/codec2/common/MultiAccessUnitHelper.h index bb4464c197..070a1f5fc1 100644 --- a/media/codec2/hal/common/include/codec2/common/MultiAccessUnitHelper.h +++ b/media/codec2/hal/common/include/codec2/common/MultiAccessUnitHelper.h @@ -46,6 +46,7 @@ struct MultiAccessUnitInterface : public C2InterfaceHelper { protected: bool getDecoderSampleRateAndChannelCount( uint32_t * const sampleRate_, uint32_t * const channelCount_) const; + bool getMaxInputSize(C2StreamMaxBufferSizeInfo::input* const maxInputSize) const; const std::shared_ptr<C2ComponentInterface> mC2ComponentIntf; std::shared_ptr<C2LargeFrame::output> mLargeFrameParams; C2ComponentKindSetting mKind; @@ -140,6 +141,11 @@ protected: std::vector<std::shared_ptr<const C2Info>> mInfos; /* + * Vector for holding config updates from the wrapper + */ + std::vector<std::unique_ptr<C2Param>> mConfigUpdate; + + /* * C2AccessUnitInfos for the current buffer */ std::vector<C2AccessUnitInfosStruct> mAccessUnitInfos; @@ -170,6 +176,11 @@ protected: }; /* + * Reconfigure helper + */ + bool tryReconfigure(const std::unique_ptr<C2Param> &p); + + /* * Creates a linear block to be used with work */ c2_status_t createLinearBlock(MultiAccessUnitInfo &frame); @@ -195,6 +206,14 @@ protected: uint32_t size, int64_t timestamp); + // Flag to allow dynamic on/off settings on this helper. + // Once enabled and buffers in transit, it is not possible + // to turn this module off by setting the max output value + // to 0. This is because the skip cut buffer expects the + // metadata to be always present along with a valid buffer. + // This flag is used to monitor that state of this module. + bool mMultiAccessOnOffAllowed; + bool mInit; // Interface of this module diff --git a/media/codec2/sfplugin/Android.bp b/media/codec2/sfplugin/Android.bp index 362373e3cf..7076bacda9 100644 --- a/media/codec2/sfplugin/Android.bp +++ b/media/codec2/sfplugin/Android.bp @@ -91,6 +91,10 @@ cc_library_shared { "libcodec2_client", ], + defaults: [ + "aconfig_lib_cc_static_link.defaults", + ], + sanitize: { cfi: true, misc_undefined: [ diff --git a/media/codec2/vndk/Android.bp b/media/codec2/vndk/Android.bp index 9f57bfd1c2..dc06ee6400 100644 --- a/media/codec2/vndk/Android.bp +++ b/media/codec2/vndk/Android.bp @@ -53,6 +53,7 @@ cc_library { ], defaults: [ + "aconfig_lib_cc_static_link.defaults", "libcodec2_hal_selection", ], diff --git a/media/libaudiohal/impl/EffectProxy.cpp b/media/libaudiohal/impl/EffectProxy.cpp index 9aa02e2fc1..fb4658f19d 100644 --- a/media/libaudiohal/impl/EffectProxy.cpp +++ b/media/libaudiohal/impl/EffectProxy.cpp @@ -82,8 +82,7 @@ ndk::ScopedAStatus EffectProxy::destroy() { ndk::ScopedAStatus EffectProxy::setOffloadParam(const effect_offload_param_t* offload) { const auto& itor = std::find_if(mSubEffects.begin(), mSubEffects.end(), [&](const auto& sub) { const auto& desc = sub.descriptor; - return offload->isOffload == - (desc.common.flags.hwAcceleratorMode == Flags::HardwareAccelerator::TUNNEL); + return offload->isOffload == desc.common.flags.offloadIndication; }); if (itor == mSubEffects.end()) { ALOGE("%s no %soffload sub-effect found", __func__, offload->isOffload ? "" : "non-"); @@ -93,7 +92,7 @@ ndk::ScopedAStatus EffectProxy::setOffloadParam(const effect_offload_param_t* of } mActiveSubIdx = std::distance(mSubEffects.begin(), itor); - ALOGI("%s: active %soffload sub-effect %zu descriptor: %s", __func__, + ALOGI("%s: active %soffload sub-effect %zu: %s", __func__, offload->isOffload ? "" : "non-", mActiveSubIdx, ::android::audio::utils::toString(mSubEffects[mActiveSubIdx].descriptor.common.id.uuid) .c_str()); @@ -163,7 +162,7 @@ ndk::ScopedAStatus EffectProxy::close() { ndk::ScopedAStatus EffectProxy::getDescriptor(Descriptor* desc) { *desc = mSubEffects[mActiveSubIdx].descriptor; - desc->common.id.uuid = desc->common.id.proxy.value(); + desc->common = mDescriptorCommon; return ndk::ScopedAStatus::ok(); } @@ -185,42 +184,35 @@ ndk::ScopedAStatus EffectProxy::buildDescriptor(const AudioUuid& uuid, return ndk::ScopedAStatus::ok(); } +// Sub-effects are required to have identical features, so here we return the SW sub-effect +// descriptor, with the implementation UUID replaced with proxy UUID, and flags setting respect all +// sub-effects. Descriptor::Common EffectProxy::buildDescriptorCommon( const AudioUuid& uuid, const std::vector<Descriptor>& subEffectDescs) { - // initial flag values before we know which sub-effect to active (with setOffloadParam) - // align to HIDL EffectProxy flags - Descriptor::Common common = {.flags = {.type = Flags::Type::INSERT, - .insert = Flags::Insert::LAST, - .volume = Flags::Volume::CTRL}}; - + Descriptor::Common swCommon; + const Flags& firstFlag = subEffectDescs[0].common.flags; + bool offloadExist = false; for (const auto& desc : subEffectDescs) { - if (desc.common.flags.hwAcceleratorMode == Flags::HardwareAccelerator::TUNNEL) { - common.flags.hwAcceleratorMode = Flags::HardwareAccelerator::TUNNEL; - } - - // set indication if any sub-effect indication was set - common.flags.offloadIndication |= desc.common.flags.offloadIndication; - common.flags.deviceIndication |= desc.common.flags.deviceIndication; - common.flags.audioModeIndication |= desc.common.flags.audioModeIndication; - common.flags.audioSourceIndication |= desc.common.flags.audioSourceIndication; - // Set to NONE if any sub-effect not supporting any Volume command - if (desc.common.flags.volume == Flags::Volume::NONE) { - common.flags.volume = Flags::Volume::NONE; + if (desc.common.flags.offloadIndication) { + offloadExist = true; + } else { + swCommon = desc.common; } - // set to AUXILIARY if any sub-effect is of AUXILIARY type - if (desc.common.flags.type == Flags::Type::AUXILIARY) { - common.flags.type = Flags::Type::AUXILIARY; + if (desc.common.flags.audioModeIndication != firstFlag.audioModeIndication || + desc.common.flags.audioSourceIndication != firstFlag.audioSourceIndication || + desc.common.flags.sinkMetadataIndication != firstFlag.sinkMetadataIndication || + desc.common.flags.sourceMetadataIndication != firstFlag.sourceMetadataIndication || + desc.common.flags.deviceIndication != firstFlag.deviceIndication) { + ALOGW("Inconsistent flags %s vs %s", desc.common.flags.toString().c_str(), + firstFlag.toString().c_str()); } } - // copy type UUID from any of sub-effects, all sub-effects should have same type - common.id.type = subEffectDescs[0].common.id.type; + swCommon.flags.offloadIndication = offloadExist; // replace implementation UUID with proxy UUID. - common.id.uuid = uuid; - common.id.proxy = std::nullopt; - common.name = "Proxy"; - common.implementor = "AOSP"; - return common; + swCommon.id.uuid = uuid; + swCommon.id.proxy = std::nullopt; + return swCommon; } // Handle with active sub-effect first, only send to other sub-effects when success diff --git a/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp b/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp index 3b2f344fe8..64cc7ed3d8 100644 --- a/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp +++ b/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp @@ -188,7 +188,6 @@ status_t EffectsFactoryHalAidl::createEffect(const effect_uuid_t* uuid, int32_t aidlEffect = ndk::SharedRefBase::make<EffectProxy>( aidlUuid, mProxyUuidDescriptorMap.at(aidlUuid) /* sub-effect descriptor list */, mFactory); - mProxyList.emplace_back(std::static_pointer_cast<EffectProxy>(aidlEffect)); } else { RETURN_STATUS_IF_ERROR( statusTFromBinderStatus(mFactory->createEffect(aidlUuid, &aidlEffect))); @@ -205,15 +204,9 @@ status_t EffectsFactoryHalAidl::createEffect(const effect_uuid_t* uuid, int32_t } status_t EffectsFactoryHalAidl::dumpEffects(int fd) { - status_t ret = OK; - // record the error ret and continue dump as many effects as possible - for (const auto& proxy : mProxyList) { - if (status_t temp = BAD_VALUE; proxy && (temp = proxy->dump(fd, nullptr, 0)) != OK) { - ret = temp; - } - } + // TODO: b/333803769 improve the effect dump implementation RETURN_STATUS_IF_ERROR(mFactory->dump(fd, nullptr, 0)); - return ret; + return OK; } status_t EffectsFactoryHalAidl::allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) { diff --git a/media/libaudiohal/impl/EffectsFactoryHalAidl.h b/media/libaudiohal/impl/EffectsFactoryHalAidl.h index 73089b0088..3b8628c8fd 100644 --- a/media/libaudiohal/impl/EffectsFactoryHalAidl.h +++ b/media/libaudiohal/impl/EffectsFactoryHalAidl.h @@ -84,9 +84,6 @@ class EffectsFactoryHalAidl final : public EffectsFactoryHalInterface { // Query result of pre and post processing from effect factory const std::vector<Processing> mAidlProcessings; - // list of the EffectProxy instances - std::list<std::shared_ptr<EffectProxy>> mProxyList; - virtual ~EffectsFactoryHalAidl() = default; status_t getHalDescriptorWithImplUuid( const ::aidl::android::media::audio::common::AudioUuid& uuid, diff --git a/media/libaudiohal/impl/StreamHalAidl.cpp b/media/libaudiohal/impl/StreamHalAidl.cpp index 97c9659a36..70e7949491 100644 --- a/media/libaudiohal/impl/StreamHalAidl.cpp +++ b/media/libaudiohal/impl/StreamHalAidl.cpp @@ -379,10 +379,12 @@ status_t StreamHalAidl::resume(StreamDescriptor::Reply* reply) { return INVALID_OPERATION; } return OK; - } else if (state == StreamDescriptor::State::PAUSED) { + } else if (state == StreamDescriptor::State::PAUSED || + state == StreamDescriptor::State::TRANSFER_PAUSED || + state == StreamDescriptor::State::DRAIN_PAUSED) { return sendCommand(makeHalCommand<HalCommand::Tag::start>(), reply); } else { - ALOGE("%s: unexpected stream state: %s (expected IDLE or PAUSED)", + ALOGE("%s: unexpected stream state: %s (expected IDLE or one of *PAUSED states)", __func__, toString(state).c_str()); return INVALID_OPERATION; } diff --git a/media/libeffects/data/Android.bp b/media/libeffects/data/Android.bp new file mode 100644 index 0000000000..2acf229d8e --- /dev/null +++ b/media/libeffects/data/Android.bp @@ -0,0 +1,19 @@ +// Copyright (C) 2024 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +prebuilt_etc { + name: "framework-audio_effects.xml", + src: "audio_effects.xml", + filename: "audio_effects.xml", +} diff --git a/media/libeffects/visualizer/aidl/Visualizer.cpp b/media/libeffects/visualizer/aidl/Visualizer.cpp index 9c2b71ef13..9b493d43a8 100644 --- a/media/libeffects/visualizer/aidl/Visualizer.cpp +++ b/media/libeffects/visualizer/aidl/Visualizer.cpp @@ -72,7 +72,7 @@ const Descriptor VisualizerImpl::kDescriptor = { .uuid = getEffectImplUuidVisualizer(), .proxy = std::nullopt}, .flags = {.type = Flags::Type::INSERT, - .insert = Flags::Insert::LAST, + .insert = Flags::Insert::FIRST, .volume = Flags::Volume::NONE}, .name = VisualizerImpl::kEffectName, .implementor = "The Android Open Source Project"}, diff --git a/media/libheif/OWNERS b/media/libheif/OWNERS new file mode 100644 index 0000000000..a61ad21e7f --- /dev/null +++ b/media/libheif/OWNERS @@ -0,0 +1,2 @@ +include platform/frameworks/av:/media/janitors/avic_OWNERS +include platform/frameworks/av:/media/janitors/codec_OWNERS
\ No newline at end of file diff --git a/media/libstagefright/Android.bp b/media/libstagefright/Android.bp index 886285e7c2..c9a2eea93d 100644 --- a/media/libstagefright/Android.bp +++ b/media/libstagefright/Android.bp @@ -318,6 +318,10 @@ cc_library { "aconfig_mediacodec_flags_c_lib", ], + defaults: [ + "aconfig_lib_cc_static_link.defaults", + ], + static_libs: [ "android.media.codec-aconfig-cc", "libstagefright_esds", diff --git a/media/libstagefright/data/media_codecs_sw.xml b/media/libstagefright/data/media_codecs_sw.xml index bfa361cd7e..d50bc1e643 100644 --- a/media/libstagefright/data/media_codecs_sw.xml +++ b/media/libstagefright/data/media_codecs_sw.xml @@ -139,6 +139,7 @@ <Limit name="bitrate" range="1-40000000" /> </Variant> <Feature name="adaptive-playback" /> + <Feature name="dynamic-color-aspects" /> <Attribute name="software-codec" /> </MediaCodec> <MediaCodec name="c2.android.hevc.decoder" type="video/hevc" variant="slow-cpu,!slow-cpu"> @@ -160,6 +161,7 @@ <Limit name="bitrate" range="1-5000000" /> </Variant> <Feature name="adaptive-playback" /> + <Feature name="dynamic-color-aspects" /> <Attribute name="software-codec" /> </MediaCodec> <MediaCodec name="c2.android.vp8.decoder" type="video/x-vnd.on2.vp8" variant="slow-cpu,!slow-cpu"> @@ -178,6 +180,7 @@ <Limit name="bitrate" range="1-40000000" /> </Variant> <Feature name="adaptive-playback" /> + <Feature name="dynamic-color-aspects" /> <Attribute name="software-codec" /> </MediaCodec> <MediaCodec name="c2.android.vp9.decoder" type="video/x-vnd.on2.vp9" variant="slow-cpu,!slow-cpu"> @@ -197,6 +200,7 @@ <Limit name="bitrate" range="1-5000000" /> </Variant> <Feature name="adaptive-playback" /> + <Feature name="dynamic-color-aspects" /> <Attribute name="software-codec" /> </MediaCodec> <MediaCodec name="c2.android.av1.decoder" type="video/av01" variant="slow-cpu,!slow-cpu"> @@ -216,6 +220,7 @@ <Limit name="bitrate" range="1-5000000" /> </Variant> <Feature name="adaptive-playback" /> + <Feature name="dynamic-color-aspects" /> <Feature name="low-latency" /> <Attribute name="software-codec" /> </MediaCodec> @@ -235,6 +240,7 @@ <Limit name="bitrate" range="1-5000000" /> </Variant> <Feature name="adaptive-playback" /> + <Feature name="dynamic-color-aspects" /> <Feature name="low-latency" /> <Attribute name="software-codec" /> </MediaCodec> diff --git a/services/audiopolicy/engine/common/Android.bp b/services/audiopolicy/engine/common/Android.bp index d7eb2c8170..878e0e9021 100644 --- a/services/audiopolicy/engine/common/Android.bp +++ b/services/audiopolicy/engine/common/Android.bp @@ -61,4 +61,7 @@ cc_library_static { "com.android.media.audio-aconfig-cc", "server_configurable_flags", ], + defaults: [ + "aconfig_lib_cc_static_link.defaults", + ], } diff --git a/services/audiopolicy/engineconfigurable/Android.bp b/services/audiopolicy/engineconfigurable/Android.bp index aaf89a0380..2c3c4bee30 100644 --- a/services/audiopolicy/engineconfigurable/Android.bp +++ b/services/audiopolicy/engineconfigurable/Android.bp @@ -53,4 +53,7 @@ cc_library_shared { "libutils", "libxml2", ], + defaults: [ + "aconfig_lib_cc_static_link.defaults", + ], } diff --git a/services/audiopolicy/enginedefault/Android.bp b/services/audiopolicy/enginedefault/Android.bp index 1563d5f257..f5958bae02 100644 --- a/services/audiopolicy/enginedefault/Android.bp +++ b/services/audiopolicy/enginedefault/Android.bp @@ -40,4 +40,7 @@ cc_library_shared { "libutils", "libxml2", ], + defaults: [ + "aconfig_lib_cc_static_link.defaults", + ], } diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index 271860478d..58b3e510c9 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -3649,19 +3649,18 @@ bool Camera3Device::RequestThread::threadLoop() { cleanUpFailedRequests(/*sendRequestError*/ true); // Check if any stream is abandoned. checkAndStopRepeatingRequest(); + // Inform waitUntilRequestProcessed thread of a failed request ID + wakeupLatestRequest(/*failedRequestId*/true, latestRequestId); return true; } else if (res != OK) { cleanUpFailedRequests(/*sendRequestError*/ false); + // Inform waitUntilRequestProcessed thread of a failed request ID + wakeupLatestRequest(/*failedRequestId*/true, latestRequestId); return false; } // Inform waitUntilRequestProcessed thread of a new request ID - { - Mutex::Autolock al(mLatestRequestMutex); - - mLatestRequestId = latestRequestId; - mLatestRequestSignal.signal(); - } + wakeupLatestRequest(/*failedRequestId*/false, latestRequestId); // Submit a batch of requests to HAL. // Use flush lock only when submitting multilple requests in a batch. @@ -4393,12 +4392,7 @@ void Camera3Device::RequestThread::cleanUpFailedRequests(bool sendRequestError) hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_REQUEST, captureRequest->mResultExtras); } - { - Mutex::Autolock al(mLatestRequestMutex); - - mLatestFailedRequestId = captureRequest->mResultExtras.requestId; - mLatestRequestSignal.signal(); - } + wakeupLatestRequest(/*failedRequestId*/true, captureRequest->mResultExtras.requestId); } // Remove yet-to-be submitted inflight request from inflightMap @@ -5060,6 +5054,20 @@ status_t Camera3Device::RequestThread::setHalInterface( return OK; } +void Camera3Device::RequestThread::wakeupLatestRequest( + bool latestRequestFailed, + int32_t latestRequestId) { + Mutex::Autolock al(mLatestRequestMutex); + + if (latestRequestFailed) { + mLatestFailedRequestId = latestRequestId; + } else { + mLatestRequestId = latestRequestId; + } + mLatestRequestSignal.signal(); +} + + /** * PreparerThread inner class methods */ diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h index 9a2f2b15c0..1820702349 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.h +++ b/services/camera/libcameraservice/device3/Camera3Device.h @@ -1026,6 +1026,11 @@ class Camera3Device : const sp<CaptureRequest> &request, const CameraMetadata& injectedSessionParams); + /** + * signal mLatestRequestmutex + **/ + void wakeupLatestRequest(bool latestRequestFailed, int32_t latestRequestId); + protected: virtual bool threadLoop(); diff --git a/services/mediaresourcemanager/test/Android.bp b/services/mediaresourcemanager/test/Android.bp index 6a64823052..5dfec3050d 100644 --- a/services/mediaresourcemanager/test/Android.bp +++ b/services/mediaresourcemanager/test/Android.bp @@ -29,6 +29,9 @@ cc_test { "libactivitymanager_aidl", "server_configurable_flags", ], + defaults: [ + "aconfig_lib_cc_static_link.defaults", + ], include_dirs: [ "frameworks/av/include", "frameworks/av/services/mediaresourcemanager", |