Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb1f9a30 authored by Jaideep Sharma's avatar Jaideep Sharma
Browse files

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
parent 0f41381a
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -111,11 +111,12 @@ void DownmixContext::reset() {
}

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 @@ IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int sample
        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 @@ IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int sample
            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) {