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

Commit 70c6c72c authored by François Gaffie's avatar François Gaffie Committed by Eric Laurent
Browse files

audio: effect: cannot control device effect if already created by default



-map emplace add and destroy newly added handle if key is present
-HalHandle is recreated (replaced first then previous is deleted, thus
leading to remove the effect in the end).

Bug: 268441977
Test: make

Change-Id: I94ef3e72cdc994ea9dde4f915624b1a76e449310
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@renault.com>
parent 71e4ee61
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -3340,6 +3340,9 @@ status_t DeviceEffectProxy::onCreatePatch(
    }
    if (status == NO_ERROR || status == ALREADY_EXISTS) {
        Mutex::Autolock _l(mProxyLock);
        size_t erasedHandle = mEffectHandles.erase(patchHandle);
        ALOGV("%s %s effecthandle %p for patch %d",
                __func__, (erasedHandle == 0 ? "adding" : "replacing"), handle.get(), patchHandle);
        mEffectHandles.emplace(patchHandle, handle);
    }
    ALOGW_IF(status == BAD_VALUE,
@@ -3372,6 +3375,9 @@ status_t DeviceEffectProxy::checkPort(const AudioFlinger::PatchPanel::Patch& pat

    if (mDescriptor.flags & EFFECT_FLAG_HW_ACC_TUNNEL) {
        Mutex::Autolock _l(mProxyLock);
        if (mHalEffect != nullptr && mDevicePort.id == port->id) {
            ALOGV("%s reusing HAL effect", __func__);
        } else {
            mDevicePort = *port;
            mHalEffect = new EffectModule(mMyCallback,
                                      const_cast<effect_descriptor_t *>(&mDescriptor),
@@ -3383,7 +3389,7 @@ status_t DeviceEffectProxy::checkPort(const AudioFlinger::PatchPanel::Patch& pat
                mHalEffect->setDevices({mDevice});
            }
            mHalEffect->configure();

        }
        *handle = new EffectHandle(mHalEffect, nullptr, nullptr, 0 /*priority*/,
                                   mNotifyFramesProcessed);
        status = (*handle)->initCheck();