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

Commit 229f94d5 authored by jiabin's avatar jiabin Committed by Jiabin Huang
Browse files

Initialize volume level of volume control effect as lowest level.

When a volume control effect is attached, set the volume as lowest level
for safer ramping.

Bug: 242159880
Test: repo steps from the bug
Change-Id: I084bb99106e7e06232db107b8e288bf5416d26cc
Merged-In: I084bb99106e7e06232db107b8e288bf5416d26cc
parent ad6bda8f
Loading
Loading
Loading
Loading
+25 −17
Original line number Diff line number Diff line
@@ -1054,6 +1054,13 @@ status_t AudioFlinger::EffectModule::configure()
                    &size,
                    &cmdStatus);
        }

        if (isVolumeControl()) {
            // Force initializing the volume as 0 for volume control effect for safer ramping
            uint32_t left = 0;
            uint32_t right = 0;
            setVolumeInternal(&left, &right, true /*controller*/);
        }
    }

    // mConfig.outputCfg.buffer.frameCount cannot be zero.
@@ -1427,15 +1434,17 @@ status_t AudioFlinger::EffectModule::setVolume(uint32_t *left, uint32_t *right,
            ((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)) {
        uint32_t volume[2];
        uint32_t *pVolume = NULL;
        uint32_t size = sizeof(volume);
        volume[0] = *left;
        volume[1] = *right;
        if (controller) {
            pVolume = volume;
        status = setVolumeInternal(left, right, controller);
    }
    return status;
}
        status = mEffectInterface->command(EFFECT_CMD_SET_VOLUME,

status_t AudioFlinger::EffectModule::setVolumeInternal(
        uint32_t *left, uint32_t *right, bool controller) {
    uint32_t volume[2] = {*left, *right};
    uint32_t *pVolume = controller ? volume : nullptr;
    uint32_t size = sizeof(volume);
    status_t status = mEffectInterface->command(EFFECT_CMD_SET_VOLUME,
                                                size,
                                                volume,
                                                &size,
@@ -1444,7 +1453,6 @@ status_t AudioFlinger::EffectModule::setVolume(uint32_t *left, uint32_t *right,
        *left = volume[0];
        *right = volume[1];
    }
    }
    return status;
}

+2 −0
Original line number Diff line number Diff line
@@ -302,6 +302,8 @@ private:
                ? EFFECT_BUFFER_ACCESS_WRITE : EFFECT_BUFFER_ACCESS_ACCUMULATE;
    }

    status_t setVolumeInternal(uint32_t *left, uint32_t *right, bool controller);


    effect_config_t     mConfig;    // input and output audio configuration
    sp<EffectHalInterface> mEffectInterface; // Effect module HAL