libeffects: Fix processed samples for downmix effect
In downmix effect, input and output sizes can be different,
where the output produced follows:
outputSize = (inputSize * outFrameSize/inFrameSize)
Writing a size beyond the capacity of FMQ fails the write
operation leading to no sound.
Fix the generated output sample in above mentioned ratio.
Bug: 318926783
Test: play a 8 channel file and check sound
Change-Id: Ifbe6fba90d08a2e30339117f90b994cfdb668bb4
diff --git a/media/libeffects/downmix/aidl/DownmixContext.cpp b/media/libeffects/downmix/aidl/DownmixContext.cpp
index 13e0e5a..e5d8f43 100644
--- a/media/libeffects/downmix/aidl/DownmixContext.cpp
+++ b/media/libeffects/downmix/aidl/DownmixContext.cpp
@@ -111,11 +111,12 @@
}
IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int samples) {
- LOG(DEBUG) << __func__ << " in " << in << " out " << out << " sample " << samples;
+ LOG(VERBOSE) << __func__ << " in " << in << " out " << out << " sample " << samples;
IEffect::Status status = {EX_ILLEGAL_ARGUMENT, 0, 0};
if (in == nullptr || out == nullptr ||
getCommon().input.frameCount != getCommon().output.frameCount || getInputFrameSize() == 0) {
+ LOG(ERROR) << __func__ << " either in/out buffer invalid or framecount mismatch";
return status;
}
@@ -128,7 +129,7 @@
return status;
}
- LOG(DEBUG) << __func__ << " start processing";
+ LOG(VERBOSE) << __func__ << " start processing";
bool accumulate = false;
int frames = samples * sizeof(float) / getInputFrameSize();
if (mType == Downmix::Type::STRIP) {
@@ -153,8 +154,9 @@
return status;
}
}
- LOG(DEBUG) << __func__ << " done processing";
- return {STATUS_OK, samples, samples};
+ int producedSamples = samples * getOutputFrameSize() / getInputFrameSize();
+ LOG(VERBOSE) << __func__ << " done processing generated samples " << producedSamples;
+ return {STATUS_OK, samples, producedSamples};
}
void DownmixContext::init_params(const Parameter::Common& common) {