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

Commit 73fc2df5 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Effects: set hw volume if effect chain doesn't have volume control"...

Merge "Effects: set hw volume if effect chain doesn't have volume control" into rvc-dev am: 40598a66 am: bcbfe793

Change-Id: I7b42ac7f6b6b9112521a4cd2cd04658c50045099
parents 34128ba5 bcbfe793
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1395,7 +1395,11 @@ status_t AudioFlinger::EffectModule::setVolume(uint32_t *left, uint32_t *right,

void AudioFlinger::EffectChain::setVolumeForOutput_l(uint32_t left, uint32_t right)
{
    if (mEffectCallback->isOffloadOrDirect() && !isNonOffloadableEnabled_l()) {
    // for offload or direct thread, if the effect chain has non-offloadable
    // effect and any effect module within the chain has volume control, then
    // volume control is delegated to effect, otherwise, set volume to hal.
    if (mEffectCallback->isOffloadOrDirect() &&
        !(isNonOffloadableEnabled_l() && hasVolumeControlEnabled_l())) {
        float vol_l = (float)left / (1 << 24);
        float vol_r = (float)right / (1 << 24);
        mEffectCallback->setVolumeForOutput(vol_l, vol_r);
@@ -2296,6 +2300,13 @@ void AudioFlinger::EffectChain::setAudioSource_l(audio_source_t source)
    }
}

bool AudioFlinger::EffectChain::hasVolumeControlEnabled_l() const {
    for (const auto &effect : mEffects) {
        if (effect->isVolumeControlEnabled()) return true;
    }
    return false;
}

// setVolume_l() must be called with ThreadBase::mLock or EffectChain::mLock held
bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right, bool force)
{
+3 −0
Original line number Diff line number Diff line
@@ -596,6 +596,9 @@ private:

    void setThread(const sp<ThreadBase>& thread);

    // true if any effect module within the chain has volume control
    bool hasVolumeControlEnabled_l() const;

    void setVolumeForOutput_l(uint32_t left, uint32_t right);

    mutable  Mutex mLock;        // mutex protecting effect list