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

Commit 40598a66 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

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

parents fb471f4f d505c647
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line 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)
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_l = (float)left / (1 << 24);
        float vol_r = (float)right / (1 << 24);
        float vol_r = (float)right / (1 << 24);
        mEffectCallback->setVolumeForOutput(vol_l, vol_r);
        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
// 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)
bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right, bool force)
{
{
+3 −0
Original line number Original line Diff line number Diff line
@@ -596,6 +596,9 @@ private:


    void setThread(const sp<ThreadBase>& thread);
    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);
    void setVolumeForOutput_l(uint32_t left, uint32_t right);


    mutable  Mutex mLock;        // mutex protecting effect list
    mutable  Mutex mLock;        // mutex protecting effect list