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

Commit b009ad58 authored by Shunkai Yao's avatar Shunkai Yao
Browse files

Avoid create preprocessing effect for playback port

Also not create postprocessing effect for input port

Bug: 279816789
Test: run gts -m GtsAudioTestCases -t com.google.android.audio.gts.DeviceEffectTest
Test: Build on pixel and test audio with effects
Test: Verified on partner platform

Change-Id: I3b6a05cb6533d18eca0689a42219010c5bbcf06a
parent ffd9771b
Loading
Loading
Loading
Loading
+13 −10
Original line number Original line Diff line number Diff line
@@ -3375,8 +3375,18 @@ status_t AudioFlinger::DeviceEffectProxy::checkPort(const PatchPanel::Patch& pat
    ALOGV("%s type %d device type %d address %s device ID %d patch.isSoftware() %d",
    ALOGV("%s type %d device type %d address %s device ID %d patch.isSoftware() %d",
            __func__, port->type, port->ext.device.type,
            __func__, port->type, port->ext.device.type,
            port->ext.device.address, port->id, patch.isSoftware());
            port->ext.device.address, port->id, patch.isSoftware());
    if (port->type != AUDIO_PORT_TYPE_DEVICE || port->ext.device.type != mDevice.mType
    if (port->type != AUDIO_PORT_TYPE_DEVICE || port->ext.device.type != mDevice.mType ||
        || port->ext.device.address != mDevice.address()) {
        port->ext.device.address != mDevice.address()) {
        return NAME_NOT_FOUND;
    }
    if (((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) &&
        (audio_port_config_has_input_direction(port))) {
        ALOGI("%s don't create postprocessing effect on record port", __func__);
        return NAME_NOT_FOUND;
    }
    if (((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC) &&
        (!audio_port_config_has_input_direction(port))) {
        ALOGI("%s don't create preprocessing effect on playback port", __func__);
        return NAME_NOT_FOUND;
        return NAME_NOT_FOUND;
    }
    }
    status_t status = NAME_NOT_FOUND;
    status_t status = NAME_NOT_FOUND;
@@ -3407,20 +3417,12 @@ status_t AudioFlinger::DeviceEffectProxy::checkPort(const PatchPanel::Patch& pat
    } else if (patch.isSoftware() || patch.thread().promote() != nullptr) {
    } else if (patch.isSoftware() || patch.thread().promote() != nullptr) {
        sp <ThreadBase> thread;
        sp <ThreadBase> thread;
        if (audio_port_config_has_input_direction(port)) {
        if (audio_port_config_has_input_direction(port)) {
            if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
                ALOGI("%s don't create postprocessing effect on record thread", __func__);
                return NAME_NOT_FOUND;
            }
            if (patch.isSoftware()) {
            if (patch.isSoftware()) {
                thread = patch.mRecord.thread();
                thread = patch.mRecord.thread();
            } else {
            } else {
                thread = patch.thread().promote();
                thread = patch.thread().promote();
            }
            }
        } else {
        } else {
            if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC) {
                ALOGI("%s don't create preprocessing effect on playback thread", __func__);
                return NAME_NOT_FOUND;
            }
            if (patch.isSoftware()) {
            if (patch.isSoftware()) {
                thread = patch.mPlayback.thread();
                thread = patch.mPlayback.thread();
            } else {
            } else {
@@ -3436,6 +3438,7 @@ status_t AudioFlinger::DeviceEffectProxy::checkPort(const PatchPanel::Patch& pat
    } else {
    } else {
        status = BAD_VALUE;
        status = BAD_VALUE;
    }
    }

    if (status == NO_ERROR || status == ALREADY_EXISTS) {
    if (status == NO_ERROR || status == ALREADY_EXISTS) {
        Status bs;
        Status bs;
        if (isEnabled()) {
        if (isEnabled()) {