Merge "Update work buffer size with input/output frame size change" into main am: db9b8f08da

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2925168

Change-Id: Iad11a01b21cc735bed9df9e2fe0d4c96093c18c3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Shunkai Yao 2024-01-29 19:20:09 +00:00 committed by Automerger Merge Worker
commit 4ce527e8a9
3 changed files with 11 additions and 2 deletions

View file

@ -46,7 +46,7 @@ EffectContext::EffectContext(size_t statusDepth, const Parameter::Common& common
::android::status_t status =
EventFlag::createEventFlag(mStatusMQ->getEventFlagWord(), &mEfGroup);
LOG_ALWAYS_FATAL_IF(status != ::android::OK || !mEfGroup, " create EventFlagGroup failed ");
mWorkBuffer.reserve(std::max(inBufferSizeInFloat, outBufferSizeInFloat));
mWorkBuffer.resize(std::max(inBufferSizeInFloat, outBufferSizeInFloat));
}
// reset buffer status by abandon input data in FMQ
@ -82,6 +82,10 @@ float* EffectContext::getWorkBuffer() {
return static_cast<float*>(mWorkBuffer.data());
}
size_t EffectContext::getWorkBufferSize() const {
return mWorkBuffer.size();
}
std::shared_ptr<EffectContext::StatusMQ> EffectContext::getStatusFmq() const {
return mStatusMQ;
}
@ -206,6 +210,8 @@ RetCode EffectContext::updateIOFrameSize(const Parameter::Common& common) {
mInputFrameSize = iFrameSize;
mOutputFrameSize = oFrameSize;
if (needUpdateMq) {
mWorkBuffer.resize(std::max(common.input.frameCount * mInputFrameSize / sizeof(float),
common.output.frameCount * mOutputFrameSize / sizeof(float)));
return notifyDataMqUpdate();
}
return RetCode::SUCCESS;

View file

@ -327,7 +327,9 @@ void EffectImpl::process() {
return;
}
auto processSamples = inputMQ->availableToRead();
assert(mImplContext->getWorkBufferSize() >=
std::max(inputMQ->availableToRead(), outputMQ->availableToWrite()));
auto processSamples = std::min(inputMQ->availableToRead(), outputMQ->availableToWrite());
if (processSamples) {
inputMQ->read(buffer, processSamples);
IEffect::Status status = effectProcessImpl(buffer, buffer, processSamples);

View file

@ -49,6 +49,7 @@ class EffectContext {
std::shared_ptr<DataMQ> getOutputDataFmq() const;
float* getWorkBuffer();
size_t getWorkBufferSize() const;
// reset buffer status by abandon input data in FMQ
void resetBuffer();