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

Commit c20ad5fc authored by Shunkai Yao's avatar Shunkai Yao Committed by Automerger Merge Worker
Browse files

Merge changes I91a26704,Id77ccb0b,Ic43c375b into main am: b96aa7a6

parents 8d6c4d51 b96aa7a6
Loading
Loading
Loading
Loading
+28 −6
Original line number Diff line number Diff line
@@ -1046,10 +1046,23 @@ void EffectModule::addEffectToHal_l()
            return;
        }

        (void)getCallback()->addEffectToHal(mEffectInterface);
        status_t status = getCallback()->addEffectToHal(mEffectInterface);
        if (status == NO_ERROR) {
            mCurrentHalStream = getCallback()->io();
        }
    }
}

void HwAccDeviceEffectModule::addEffectToHal_l()
{
    if (mAddedToHal) {
        return;
    }
    status_t status = getCallback()->addEffectToHal(mEffectInterface);
    if (status == NO_ERROR) {
        mAddedToHal = true;
    }
}

// start_l() must be called with EffectChain::mutex() held
status_t EffectModule::start_l()
@@ -1153,6 +1166,16 @@ status_t EffectModule::removeEffectFromHal_l()
    return NO_ERROR;
}

status_t HwAccDeviceEffectModule::removeEffectFromHal_l()
{
    if (!mAddedToHal) {
        return NO_ERROR;
    }
    getCallback()->removeEffectFromHal(mEffectInterface);
    mAddedToHal = false;
    return NO_ERROR;
}

// round up delta valid if value and divisor are positive.
template <typename T>
static T roundUpDelta(const T &value, const T &divisor) {
@@ -3511,10 +3534,9 @@ NO_THREAD_SAFETY_ANALYSIS
            ALOGV("%s reusing HAL effect", __func__);
        } else {
            mDevicePort = *port;
            mHalEffect = new EffectModule(mMyCallback,
                                      const_cast<effect_descriptor_t *>(&mDescriptor),
                                      mMyCallback->newEffectId(), AUDIO_SESSION_DEVICE,
                                      false /* pinned */, port->id);
            mHalEffect = sp<HwAccDeviceEffectModule>::make(mMyCallback,
                    const_cast<effect_descriptor_t *>(&mDescriptor), mMyCallback->newEffectId(),
                    port->id);
            if (audio_is_input_device(mDevice.mType)) {
                mHalEffect->setInputDevice(mDevice);
            } else {
+18 −4
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ protected:
// the attached track(s) to accumulate their auxiliary channel.
class EffectModule : public IAfEffectModule, public EffectBase {
public:
    EffectModule(const sp<EffectCallbackInterface>& callabck,
    EffectModule(const sp<EffectCallbackInterface>& callback,
                    effect_descriptor_t *desc,
                    int id,
                    audio_session_t sessionId,
@@ -228,7 +228,7 @@ public:
            REQUIRES(audio_utils::EffectChain_Mutex) EXCLUDES_EffectBase_Mutex;
    bool isOffloaded_l() const final
            REQUIRES(audio_utils::EffectChain_Mutex) EXCLUDES_EffectBase_Mutex;
    void addEffectToHal_l() final REQUIRES(audio_utils::EffectChain_Mutex);
    void addEffectToHal_l() override REQUIRES(audio_utils::EffectChain_Mutex);
    void release_l(const std::string& from = "") final REQUIRES(audio_utils::EffectChain_Mutex);

    sp<IAfEffectModule> asEffectModule() final { return this; }
@@ -250,6 +250,9 @@ public:

    void dump(int fd, const Vector<String16>& args) const final;

protected:
    sp<EffectHalInterface> mEffectInterface; // Effect module HAL

private:

    // Maximum time allocated to effect engines to complete the turn off sequence
@@ -259,7 +262,7 @@ private:

    status_t start_ll() REQUIRES(audio_utils::EffectChain_Mutex, audio_utils::EffectBase_Mutex);
    status_t stop_ll() REQUIRES(audio_utils::EffectChain_Mutex, audio_utils::EffectBase_Mutex);
    status_t removeEffectFromHal_l() REQUIRES(audio_utils::EffectChain_Mutex);
    status_t removeEffectFromHal_l() override REQUIRES(audio_utils::EffectChain_Mutex);
    status_t sendSetAudioDevicesCommand(const AudioDeviceTypeAddrVector &devices, uint32_t cmdCode);
    effect_buffer_access_e requiredEffectBufferAccessMode() const {
        return mConfig.inputCfg.buffer.raw == mConfig.outputCfg.buffer.raw
@@ -271,7 +274,6 @@ private:
            REQUIRES(audio_utils::EffectChain_Mutex, audio_utils::EffectBase_Mutex);

    effect_config_t     mConfig;    // input and output audio configuration
    sp<EffectHalInterface> mEffectInterface; // Effect module HAL
    sp<EffectBufferHalInterface> mInBuffer;  // Buffers for interacting with HAL
    sp<EffectBufferHalInterface> mOutBuffer;
    status_t            mStatus;    // initialization status
@@ -318,6 +320,18 @@ private:
    std::string mEffectInterfaceDebug GUARDED_BY(audio_utils::EffectChain_Mutex);
};

class HwAccDeviceEffectModule : public EffectModule {
public:
    HwAccDeviceEffectModule(const sp<EffectCallbackInterface>& callback, effect_descriptor_t *desc,
            int id, audio_port_handle_t deviceId) :
        EffectModule(callback, desc, id, AUDIO_SESSION_DEVICE, /* pinned */ false, deviceId) {}
    void addEffectToHal_l() final REQUIRES(audio_utils::EffectChain_Mutex);

private:
    status_t removeEffectFromHal_l() final REQUIRES(audio_utils::EffectChain_Mutex);
    bool mAddedToHal = false;
};

// The EffectHandle class implements the IEffect interface. It provides resources
// to receive parameter updates, keeps track of effect control
// ownership and state and has a pointer to the EffectModule object it is controlling.
+2 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ class IAfEffectModule : public virtual IAfEffectBase {

public:
    static sp<IAfEffectModule> create(
            const sp<EffectCallbackInterface>& callabck,
            const sp<EffectCallbackInterface>& callback,
            effect_descriptor_t *desc,
            int id,
            audio_session_t sessionId,
@@ -214,6 +214,7 @@ private:

    virtual status_t stop_l() = 0;
    virtual void addEffectToHal_l() = 0;
    virtual status_t removeEffectFromHal_l() = 0;
    virtual void release_l(const std::string& from) = 0;
};