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

Commit 934ecfbd authored by Jasmine Cha's avatar Jasmine Cha
Browse files

Effects: add new effect volume flag



Add new effect flag to monitor requested volume from
audio framework.
Pass requested volume directly if effect is volume monitor,
and others still follow an original rule by volume controller.

Bug: 123251705
Test: On/off equalizer on spotify/google music.
      Switch songs with equalizer
      Attach an effect with EFFECT_FLAG_INSERT_ANY,
                            EFFECT_FLAG_INSERT_FIRST,
			    EFFECT_FLAG_INSERT_LAST
      and check received volume.

Change-Id: I01632bebb32aa6f921c964536039d43859ae3632
Signed-off-by: default avatarJasmine Cha <chajasmine@google.com>
parent 70eb2960
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -1136,7 +1136,8 @@ status_t AudioFlinger::EffectModule::setVolume(uint32_t *left, uint32_t *right,
    // if controller flag is set (Note that controller == TRUE => EFFECT_FLAG_VOLUME_CTRL set)
    if (isProcessEnabled() &&
            ((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_IND ||
             (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_MONITOR)) {
        uint32_t volume[2];
        uint32_t *pVolume = NULL;
        uint32_t size = sizeof(volume);
@@ -1331,6 +1332,7 @@ String8 effectFlagsToString(uint32_t flags) {
    case EFFECT_FLAG_VOLUME_NONE: s.append("none"); break;
    case EFFECT_FLAG_VOLUME_CTRL: s.append("implements control"); break;
    case EFFECT_FLAG_VOLUME_IND: s.append("requires indication"); break;
    case EFFECT_FLAG_VOLUME_MONITOR: s.append("monitors volume"); break;
    default: s.append("unknown/reserved"); break;
    }
    s.append(", ");
@@ -2277,7 +2279,7 @@ bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right, boo
    }
    // then indicate volume to all other effects in chain.
    // Pass altered volume to effects before volume controller
    // and requested volume to effects after controller
    // and requested volume to effects after controller or with volume monitor flag
    uint32_t lVol = newLeft;
    uint32_t rVol = newRight;

@@ -2290,8 +2292,13 @@ bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right, boo
            lVol = *left;
            rVol = *right;
        }
        // Pass requested volume directly if this is volume monitor module
        if (mEffects[i]->isVolumeMonitor()) {
            mEffects[i]->setVolume(left, right, false);
        } else {
            mEffects[i]->setVolume(&lVol, &rVol, false);
        }
    }
    *left = newLeft;
    *right = newRight;

+3 −0
Original line number Diff line number Diff line
@@ -134,6 +134,9 @@ public:
    bool             isVolumeControl() const
                        { return (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK)
                            == EFFECT_FLAG_VOLUME_CTRL; }
    bool             isVolumeMonitor() const
                        { return (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK)
                            == EFFECT_FLAG_VOLUME_MONITOR; }
    status_t         setOffloaded(bool offloaded, audio_io_handle_t io);
    bool             isOffloaded() const;
    void             addEffectToHal_l();