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

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

Update mutex annotation for debug information and setVolumeInternal

Bug: 315995877
Test: atest CtsMediaAudioTestCases
Change-Id: Id77ccb0b03466b92c4caa4d00c2a2ea668df8c0e
parent 50148829
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1373,12 +1373,12 @@ status_t EffectModule::setVolume_l(uint32_t* left, uint32_t* right, bool control
            ((mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_CTRL ||
             (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_IND ||
             (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_MONITOR)) {
        status = setVolumeInternal(left, right, controller);
        status = setVolumeInternal_ll(left, right, controller);
    }
    return status;
}

status_t EffectModule::setVolumeInternal(
status_t EffectModule::setVolumeInternal_ll(
        uint32_t *left, uint32_t *right, bool controller) {
    if (mVolume.has_value() && *left == mVolume.value()[0] && *right == mVolume.value()[1] &&
            !controller) {
+6 −5
Original line number Diff line number Diff line
@@ -266,8 +266,9 @@ private:
                ? EFFECT_BUFFER_ACCESS_WRITE : EFFECT_BUFFER_ACCESS_ACCUMULATE;
    }

    status_t setVolumeInternal(uint32_t* left, uint32_t* right,
                               bool controller /* the volume controller effect of the chain */);
    status_t setVolumeInternal_ll(uint32_t* left, uint32_t* right,
                                  bool controller /* the volume controller effect of the chain */)
            REQUIRES(audio_utils::EffectChain_Mutex, audio_utils::EffectBase_Mutex);

    effect_config_t     mConfig;    // input and output audio configuration
    sp<EffectHalInterface> mEffectInterface; // Effect module HAL
@@ -292,12 +293,12 @@ private:
    template <typename MUTEX>
    class AutoLockReentrant {
    public:
        AutoLockReentrant(MUTEX& mutex, pid_t allowedTid)
        AutoLockReentrant(MUTEX& mutex, pid_t allowedTid) ACQUIRE(audio_utils::EffectBase_Mutex)
            : mMutex(gettid() == allowedTid ? nullptr : &mutex)
        {
            if (mMutex != nullptr) mMutex->lock();
        }
        ~AutoLockReentrant() {
        ~AutoLockReentrant() RELEASE(audio_utils::EffectBase_Mutex) {
            if (mMutex != nullptr) mMutex->unlock();
        }
    private:
@@ -314,7 +315,7 @@ private:
    // here is used to indicate the volume to apply before this effect.
    std::optional<std::vector<uint32_t>> mReturnedVolume;
    // TODO: b/315995877, remove this debugging string after root cause
    std::string mEffectInterfaceDebug;
    std::string mEffectInterfaceDebug GUARDED_BY(audio_utils::EffectChain_Mutex);
};

// The EffectHandle class implements the IEffect interface. It provides resources