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

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

Merge "VolumeShaper: Update Direct/Offload to use media time"

parents c7a1a9eb 398ffa20
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ cc_library_shared {
        "av-types-aidl-cpp",
        "effect-aidl-cpp",
        "libaudioclient_aidl_conversion",
        "libaudioflinger_timing",
        "libaudiofoundation",
        "libaudiohal",
        "libaudioprocessing",
+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@
#include <audio_utils/TimestampVerifier.h>

#include <sounddose/SoundDoseManager.h>
#include <timing/MonotonicFrameCounter.h>

#include "FastCapture.h"
#include "FastMixer.h"
+13 −3
Original line number Diff line number Diff line
@@ -6281,11 +6281,20 @@ void AudioFlinger::DirectOutputThread::processVolume_l(Track *track, bool lastTr
{
    float left, right;


    // Ensure volumeshaper state always advances even when muted.
    const sp<AudioTrackServerProxy> proxy = track->mAudioTrackServerProxy;
    const auto [shaperVolume, shaperActive] = track->getVolumeHandler()->getVolume(
            proxy->framesReleased());

    const size_t framesReleased = proxy->framesReleased();
    const int64_t frames = mTimestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL];
    const int64_t time = mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL];

    ALOGV("%s: Direct/Offload bufferConsumed:%zu  timestamp frames:%lld  time:%lld",
            __func__, framesReleased, (long long)frames, (long long)time);

    const int64_t volumeShaperFrames =
            mMonotonicFrameCounter.updateAndGetMonotonicFrameCount(frames, time);
    const auto [shaperVolume, shaperActive] =
            track->getVolumeHandler()->getVolume(volumeShaperFrames);
    mVolumeShaperActive = shaperActive;

    gain_minifloat_packed_t vlr = proxy->getVolumeLR();
@@ -6767,6 +6776,7 @@ void AudioFlinger::DirectOutputThread::flushHw_l()
    mFlushPending = false;
    mTimestampVerifier.discontinuity(discontinuityForStandbyOrFlush());
    mTimestamp.clear();
    mMonotonicFrameCounter.onFlush();
}

int64_t AudioFlinger::DirectOutputThread::computeWaitTimeNs_l() const {
+2 −0
Original line number Diff line number Diff line
@@ -1596,6 +1596,8 @@ protected:
    virtual     void        onAddNewTrack_l();

    const       audio_offload_info_t mOffloadInfo;

    audioflinger::MonotonicFrameCounter mMonotonicFrameCounter;  // for VolumeShaper
    bool mVolumeShaperActive = false;

    DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
+1 −19
Original line number Diff line number Diff line
@@ -1362,25 +1362,7 @@ VolumeShaper::Status AudioFlinger::PlaybackThread::Track::applyVolumeShaper(
        const sp<VolumeShaper::Configuration>& configuration,
        const sp<VolumeShaper::Operation>& operation)
{
    sp<VolumeShaper::Configuration> newConfiguration;

    if (isOffloadedOrDirect()) {
        const VolumeShaper::Configuration::OptionFlag optionFlag
            = configuration->getOptionFlags();
        if ((optionFlag & VolumeShaper::Configuration::OPTION_FLAG_CLOCK_TIME) == 0) {
            ALOGW("%s(%d): %s tracks do not support frame counted VolumeShaper,"
                    " using clock time instead",
                    __func__, mId,
                    isOffloaded() ? "Offload" : "Direct");
            newConfiguration = new VolumeShaper::Configuration(*configuration);
            newConfiguration->setOptionFlags(
                VolumeShaper::Configuration::OptionFlag(optionFlag
                        | VolumeShaper::Configuration::OPTION_FLAG_CLOCK_TIME));
        }
    }

    VolumeShaper::Status status = mVolumeHandler->applyVolumeShaper(
            (newConfiguration.get() != nullptr ? newConfiguration : configuration), operation);
    VolumeShaper::Status status = mVolumeHandler->applyVolumeShaper(configuration, operation);

    if (isOffloadedOrDirect()) {
        // Signal thread to fetch new volume.
Loading